* Reference: Chapter 17 of * Jeffrey M. Wooldridge, Introductory Econometrics: A Modern Approach, * South-Western College Publishing, 2000. SAMPLE 1 1445 READ (RECID.shd) black alcohol drugs super married felon workprg & property person priors educ rules age tserved follow durat & cens ldurat * Example 17.4 * Set the number of parameters GEN1 K=12 * Apply OLS and save the estimated coefficients in BETA for use as * starting values for the maximum likelihood estimation. DIM BETA K OLS ldurat workprg priors tserved felon alcohol drugs black married & educ age / COEF=BETA GEN1 BETA:12=SQRT($sig2) * Define an equation in a SHAZAM character string. * Description of character strings is in the chapter SHAZAM PROCEDURES * in the SHAZAM User's Reference Manual. * Note that the expression is enclosed by brackets -- this is to * ensure correct evaluation of the expression when it is used later on * the EQ command. XB:(B1*workprg+B2*priors+B3*tserved+B4*felon+B5*alcohol+B6*drugs+B7*black+ & B8*married+B9*educ+B10*age+B0) GENR const=-LOG(2*$PI) * Now use the NL command for maximum likelihood estimation. * The LOGDEN option specifies that the log-density of a single * observation (based on Equations (17.35) and (17.36), p. 553) is * entered on the EQ command. Note that the use of this option * requires careful checking and testing of both the specification * of the log-likelihood function and the SHAZAM commands that * program the formula. * NCDF(z) is the standard normal cumulative distribution function. * Starting values are specified with the START= option on the NL command. NL 1 / NCOEF=K LOGDEN START=BETA PITER=1 COEF=BMLE STDERR=SEMLE EQ cens*LOG(1-NCDF((ldurat-[XB])/sig))+ & (1-cens)*(const-LOG(sig**2)-((ldurat-[XB])/sig)**2)/2 END * The estimation output says: ALGORITHM USES NUMERIC DERIVATIVES * Analytic derivatives are not evaluated because of the use of the * NCDF function in the EQ specification. * On the EQ command the argument for the LOG function is not guaranteed * to be positive. This results in the following warning message: * ...WARNING...ILLEGAL LOG IN OBS. 219, VALUE REPLACED BY ZERO * The choice of good starting values can be important to avoid these * warning messages. The warning messages disappear after iteration 2 * to suggest that the estimation is moving to parameter estimates * that are giving acceptable results. * At the final iteration the values of the GRADIENT appear * close to zero to suggest that model convergence is successful. * Note that differences in the reported standard errors compared to * Table 17.4, p. 554 may result from differences in the numerical * algorithms used by econometrics software. * Estimate the expected percentage difference in time until the next * arrest for a man serving time for a felony compared to a man * serving time for a non-felony (bottom of p. 553). * An interpretation of the coefficients is discussed in * Peter Kennedy, 1981, "Estimation with Correctly Interpreted Dummy * Variables in Semi-Logarithmic Equations," American Economic Review, * p. 801. GEN1 BF=BMLE:4 GEN1 SEF=SEMLE:4 * The calculation is a corrected form of Equation (7.10), p. 219. GEN1 P = 100*(EXP(BF - SEF*SEF/2) - 1) PRINT BF SEF P * The estimation algorithm used by the NL command does not guarantee * convergence to a global maximum. * Therefore, try the estimation again with different starting values. * The previous estimation set starting values based on the results * from OLS estimation. * Another choice demonstrated below is to set all the slope parameters * to zero. DIM BETA1 K STAT ldurat / MEAN=mu STDEV=std GEN1 BETA1:11=mu GEN1 BETA1:12=std NL 1 / NCOEF=K LOGDEN START=BETA1 EQ cens*LOG(1-NCDF((ldurat-[XB])/sig))+ & (1-cens)*(const-LOG(sig**2)-((ldurat-[XB])/sig)**2)/2 END STOP