Nonlinear Regression — part 1

Variable transformations allow fitting some curvilinear relationships using the familiar techniques of intrinsically linear models. Intrinsically nonlinear models, on the other hand, require a different class of fitting techniques. The nl command performs nonlinear regression by iterative least squares. This section illustrates with the artificial examples in nonlin.dta:

The nonlin.dta data are manufactured, with y variables defined as various nonlinear functions of x, plus random Gaussian errors. y1, for example, represents the exponential growth process

y1 = 10 x 1.03 x

Estimating these parameters from the data, nl obtains

y1 = 11.20 x 1.03 x

which is reasonably close to the true model.

The predict command obtains predicted values and residuals for a nonlinear model estimated by nl. Figure 8.9 graphs predicted values from the previous example, showing the close fit (R 2 = .96) between model and data.

. predict yhatl . graph twoway scatter yl x

|| line yhatl x, sort

|| , legend(off) ytitle(“y! = 10 * 1.03Ax + e”) xtitle(“x”)

Instead of writing out the model in our nl command, we could have obtained the same result by typing

. nl exp2: y1 x

The exp2 in this command calls a brief program named nlexp2.ado, which defines the two- parameter exponential growth function. Stata includes several such programs, for the following functions:

exp3   3-parameter exponential: y = b 0 + b J b 2 x

exp2   2-parameter exponential: y = b j b 2 x

exp2a 2-parameter negative exponential: y = b j (J – b 2 x )

log4    4-parameter logistic; b 0 starting level and (b 0 + b J ) asymptotic upper limit: y = b 0 + b j /(J + exp(-b 2 (x-b 3 )))

log3    3-parameter logistic; 0 starting level and b j asymptotic upper limit: y = bj /(J + exp(-b2 (x -b3 )))

gom4 4-parameter Gompertz; b 0 starting level and (b 0 + b J ) asymptotic upper limit: y = b0 + bj exp(-exp(-b2 (x -b3 )))

gom3 3-parameter Gompertz; 0 starting level and b J asymptotic upper limit: y = bj exp(exp(b2 (xb3 )))

Users can write further nlfunction programs of their own; consult nlexp3.ado, nlgom4.ado or others above for examples. help nl describes many further options for specifying and estimating models.

nonlin.dta contains examples corresponding to exp2 (y1), exp2a (y2), log4 (y3) and gom4 (y4) functions. Figure 8.J0 shows curves fit by nl to y2, y3 and y4 from these data.

Source: Hamilton Lawrence C. (2012), Statistics with STATA: Version 12, Cengage Learning; 8th edition.

Leave a Reply

Your email address will not be published. Required fields are marked *