** Chapter 11.3 ** for W.H. Greene, Econometric Analysis 6th ed. ***************** * (c) Noel Roy 2003, 2008 * * NONLINEAR REGRESSIONS AND NONLINEAR LEAST SQUARES * * This tutorial will review Non-linear regression (NL command) in SHAZAM. * *=============================================================================== * * 11.3 APPLICATIONS * * 11.3.1 (p. 294) Example 11.5 A Nonlinear Consumption Function * READ (TableF5-1.prn) Year qtr GDP C Inv G Y CPI M1 r / SKIPLINES=1 * * Estimate the linear model * OLS C Y * * Now the non-linear model. The NL command provides * general features for the estimation of nonlinear models. The command is * invoked as * NL neq / NCOEF= options * EQ equation * ... * EQ equation * COEF coef1 value1 coef2 value2 ... * END * The model can be a single equation or a system of equations; * the number of equations is specified as neq. The NCOEF= specifies * the number of coefficients to be estimated, and is mandatory. * The EQ command following the NL command gives the form of each equation * in the model. The COEF command specifies the starting values of any of the * coefficients, and may be omitted (in which case the default starting value * is unity). The END command must be used at the end of the series of commands. * NL 1 / NCOEF=3 PCOV COEF=X EQ C=ALPHA+BETA*Y**GAMMA END * * The PCOV option prints an estimate of the covariance matrix after * convergence. The COEF= option saves the vector of coefficient estimates * in a named vactor (as in the OLS command). Other features of the NL command * are described in Chapter 22 of the Shazam manual. * * YOU SHOULD NOT ASSUME CONVERGENCE. By default, SHAZAM will * terminate after 100 iterations and report results obtained at * that time (this can be modified with the ITER= option). SHAZAM also reports * intermediate results at every 15 iterations on the value of the * log-likelihood, coefficient estimates, and the gradient vector * (which is the first derivative of the log-likelihood function with * respect to the coefficient estimate vector). If estimation converges, * the gradiant vector should become "small" relative to the vector * of coefficients. An examination of the intermediate * output may give some indication of the nature of the problem * in the event that estimation does not converge. * * If convergence does not occur, you can try (1) increasing the number * of iterations with the ITER= option, (2) trying a new set of * starting values (COEF command), and (3) trying a different iteration * algorithm (METHOD= option). SHAZAM uses the DPF variable-metric * algorithm by default (see p. 1071 of the textbook), but can also use * the DPF and BFGS methods. * * The TEST command is available with the NL command. * TEST GAMMA=1 * * Test the hypothesis that the MPC equals 1. Note that, following the text, * the most recent value of Y will be considered (i.e. Y2000.4=6634.9). * TEST BETA*GAMMA*6634.9**(GAMMA-1)=1 * * Even if convergence takes place, all that can be assured is convergence * to a LOCAL maximum. It is good practice in non-linear estimation to * try several starting values for the coefficients in order to ensure * tHat convergence to a GLOBAL maximum has occurred. In the present * case, since the estimate for GAMMA is greater than 1, it would be * worthwhile to try a starting value less than 1, say 0.5. * GENR NEWY=Y**0.5 ?OLS C NEWY /COEF=NEWB * * An alternative to the COEF command is to read starting values * into a vector and specify this vector with the START= option. * The starting values must be placed in the order they appear * in the EQ command. * DIM ST 3 GEN1 ST(1)=NEWB(2) GEN1 ST(2)=NEWB(1) GEN1 ST(3)=0.5 NL 1 / NCOEF=3 PCOV START=ST ITER=250 EQ C=ALPHA+BETA*Y**GAMMA END * * *=============================================================================== * Example 11.6 (p. 296) Multicollinearity in Nonlinear Regression * * Compute the pseudoregressors (see p. 290) and calculate the correlation * coefficient. The coefficient vector has been * saved in X. * GENR X02 = Y**X(3) GENR X03 = X(2)*X02*LOG(Y) STAT X02 X03 /PCOR * * Compute the condition number. * * The PC command is used to extract the principal components from a set of * data, and with the SCALE option can be used to create the * scaled product matrix whose characteristic roots are used to compute the * consition number. Multicollinearity may be a problem if a component * corresponding to a high condition index contributes strongly to the variance * of more than one variable. The EVAL= option stores the vector of eigenvalues * in the variable specified. The PC command is further specified in Chapter * 35 of the SHAZAM Manual. * GENR X01 = 1 PC X01 X02 X03 /SCALE EVAL=LAMBDA * * Now compute the condition number CONDNO. The MININ= and MAXIM= options * with the STAT command store the minimum and maximum values of the variables * listed in the variables specified.A condition number in excess of 20 is * considered to indicate a problematic data set. * SAMPLE 1 3 STAT LAMBDA / MINIM=LAMBMIN MAXIM=LAMBMAX GEN1 CONDNO=SQRT(LAMBMAX/LAMBMIN) PRINT CONDNO * STOP * *=============================================================================== * * Updated September 25, 2008