^DATE: 4-24-91/Danuso ^nonlin.hlp - HELP WITH NONLIN.ADO ^NONLINEAR REGRESSION The program uses a modified Gauss-Newton iterative method of estimating the parameters of a nonlinear function using least squares. The user does not need to provide derivatives; the program uses a Taylor-series algorithm. ^nonlin^ is menu-driven. After loading the data into memory, one simply types '^nonlin^' and answers a series of questions. ^EXAMPLE ON NEXT PAGE: ^. infile yvar xvar using nltest1 (9 observations read) ^. list yvar xvar 1. .04 5 2. .06 12 3. .08 25 4. .1 35 5. .15 42 6. .2 48 7. .25 60 8. .3 75 9. .5 120 ^. nonlin NONLINEAR REGRESSION Menu: 0. Exit 1. Model Fit 2. Frequency distribution of residuals (Yo-Yp) 3. Graph Yp vs. Yo 4. Graph of residuals vs. Yp 5. Graph of residuals vs. Xi 6. Graph of Yp vs. Xi ^Choice: .^ 1 ^Cases (1=all): .^ 1 ^Variable Y : .^ yvar ^List of Xi : .^ xvar ^Function : .^ 1/(%b1+%b2*exp(%b3*xvar)) ^# parameters : .^ 3 ^Initial value for b1.^ 2 ^Initial value for b2.^ 30 ^Initial value for b3.^ -0.04 ^How many iterations:.^ 4 A detailed description of the questions and possible answers follows: ^Choice Choose '^1^' if you wish to estimate a model. The other choices are shown on the opening menu and should be self-explanatory. ^Cases Choose '^1^' if you wish to select all of the observations. Alternatively, you may type a condition just as you would after an ^if^ on an ordinary Stata command. Typing '^xvar==1^', for instance, would use only observations for which the value of xvar is 1. ^Variable Y Type the name of the dependent variable. ^List of variable Xi Type the list of independent variables just as you would on the Stata command line: Ex: ^xvar1 xvar2 xvar3^ ^Model Type the right hand side of the regression function using the names ^%b1^,^%b2^,^%b3^, etc., for the names of the parameters to be estimated. For example, the logistic function ^yvar=1/(C+A*exp(B*xvar))^ would be typed as '^1/(%b1+%b2*exp(%b3*xvar))^'. ^How many parameters Type the number of parameters; in the example above we use %b1, %b2, and %b3, so we type '^3^'. ^Initial value for b1 ^Initial value for b2, etc. Type an estimate for each of the parameters. These will be used as the starting values. ^How many iterations Type the initial number of iterations you wish to perform. You will be asked later if you wish to perform additional iterations. ^nonlin^ will then perform thte indicated number of iterations unless the estimates are clearly inappropriate or the model is inconsistent. ^nonlin^ is fairly sensitive to starting values that are relatively distant from the true parameters. After the iteration run, the following selection menu will appear: ^Other initial values->p; Out->u; Continue->c: Type '^p^' if you wish to have new parameter estimates Type '^u^' if you wish to see the output Type '^c^' if you want to proceed through more iterations. ^nonlin^ does not provide a convergence criterion - at each iteration run, the current parameter estimates are shown and it is left to you to decide when the process has converged. Choice '^p^' allows you to enter new starting values and restart the estimation. Choice '^u^' will display the results after asking whether you also wish them listed on the printer. Choice '^c^' will perform more iterations. The following is an example run using a logistic model. The output is continued from the previous example - we have just typed that we want '^4^' iterations: Iteration n. 1 B1= 1.7541885 B2= 25.007356 B3= -.03914615 Iteration n. 2 B1= 1.7808726 B2= 25.737273 B3= -.03927536 Iteration n. 3 B1= 1.7809655 B2= 25.739122 B3= -.039262 Iteration n. 4 B1= 1.7809352 B2= 25.738384 B3= -.03926107 ^Other initial values ->p; Out ->u; Continue ->c :. c ^How many iterations: . 1 Iteration n. 5 B1= 1.7809337 B2= 25.738358 B3= -.03926103 Other initial values ->p; Out ->u; Continue ->c :. u Print of the results (y/n): . n =====NONLINEAR REGRESSION RESULTS===== File: N. of iterations: 5 Variable Y : yvar Variables Xi: xvar Model: yvar=1/(1.7809336+25.738356*exp(-.03926103*xvar)) Data selection: if 1 Residual statistics: Residual Average = -.00053143 Stand. Dev. = .01430633 Skewness = .14967284 Kurtosis = 2.3239515 ------------------------------------------------------------ Variation d.f. SS MS ------------------------------------------------------------ Model 3 .48496016 .16165339 Residual 6 .00163991 .00027332 Total 9 .48660007 .05406667 Corr Total 8 .173 .021625 ------------------------------------------------------------ RSq = .9905 ------------------------------------------------------------ Parameter Standard Error t Prob. t ------------------------------------------------------------ b1 1.7809336 .11585868 15.371603 4.791e-06 b2 25.738356 4.8631533 5.2925241 .00184296 b3 -.03926103 .00414855 -9.4637958 .00007924 ------------------------------------------------------------ === CORRELATION COEFFICIENT AMONG PARAMETERS === | a1 a2 a3 --------+--------------------------- a1| 1.0000 a2| 0.6164 1.0000 a3| -0.7874 -0.9346 1.0000 ^END