* Reference: Chapters 3, 5, 7, 8, 9 and 17 of * Jeffrey M. Wooldridge, Introductory Econometrics: A Modern Approach, * South-Western College Publishing, 2000. SAMPLE 1 2725 READ (CRIME1.shd) narr86 nfarr86 nparr86 pcnv avgsen tottime & ptime86 qemp86 inc86 durat black hispan born60 pcnvsq pt86sq inc86sq * Example 3.5, pp. 80-81. OLS narr86 pcnv ptime86 qemp86 * Find the effect on the number of arrests for 100 men if the percentage * of arrests that leads to conviction increases by 0.5. TEST 100*.5*pcnv * Find the effect of a longer prison term. TEST 12*ptime86 * Add another explanatory variable to the model. OLS narr86 pcnv avgsen ptime86 qemp86 * Example 5.3, p. 173. OLS narr86 pcnv avgsen tottime ptime86 qemp86 * Test the null hypothesis that avgsen and tottime have no effect * on narr86. The TEST command calculates a F-test statistic. TEST TEST avgsen=0 TEST tottime=0 END * Now calculate the LM statistic described in the textbook. * (i) Estimate the restricted model. OLS narr86 pcnv ptime86 qemp86 / RESID=U GEN1 KR=$K * (ii) Regress the residuals on all independent variables. OLS U pcnv avgsen tottime ptime86 qemp86 * Note that the above is an artificial regression and * therefore the "elasticities at means" do not have a * meaningful interpretation. A result of the OLS method * is that the mean of the OLS residuals is 0. Therefore, * the calculation of the elasticity at means has a divide * by 0 problem. * (iii) Calculate the LM test statistic GEN1 LM=$N*$R2 GEN1 KU=$K * (iv) Calculate a p-value GEN1 q=KU-KR SAMPLE 1 1 DISTRIB LM / TYPE=CHI DF=q CDF=cdf GEN1 p_value=1-cdf PRINT LM q p_value * Example 7.12 SAMPLE 1 2725 * Define a dummy variable * The DUM function on the GENR command creates a dummy variable * that is 1 when the argument is positive. * The adjustment by 0.5 is to ensure no rounding errors affect * the calculation. GENR arr86=DUM(narr86-0.5) * Equation (7.31), p. 237. OLS arr86 pcnv avgsen tottime ptime86 qemp86 * Equation (7.32), p. 237. OLS arr86 pcnv avgsen tottime ptime86 qemp86 black hispan * Example 8.3 * Equation (8.9), p. 255. GENR avgsensq=avgsen**2 * Report OLS standard errors OLS narr86 pcnv avgsen avgsensq ptime86 qemp86 inc86 black hispan * Report Heteroskedasticity-Robust standard errors OLS narr86 pcnv avgsen avgsensq ptime86 qemp86 inc86 black hispan / HETCOV * Estimate the turning point TEST -avgsen/(2*avgsensq) * Test of significance - Heteroskedasticity-Robust F statistic TEST TEST avgsen=0 TEST avgsensq=0 END * Now calculate the Heteroskedasticity-Robust LM statistic described * in the textbook. * Define a list of included independent variables under the null. XVARS: pcnv ptime86 qemp86 inc86 black hispan SET NOOUTPUT * 1. Estimate the restricted model. OLS narr86 [XVARS] / RESID=U * 2. Artificial regressions OLS avgsen [XVARS] / RESID=R1 OLS avgsensq [XVARS] / RESID=R2 * 3. Generate products GENR R1U=R1*U GENR R2U=R2*U * 4. Another artificial regression. GENR ONE=1 OLS ONE R1U R2U / NOCONSTANT * Calculate the LM test statistic GEN1 LM=$N-$SSE GEN1 q=$K * Calculate a p-value SAMPLE 1 1 DISTRIB LM / TYPE=CHI DF=q CDF=cdf GEN1 p_value=1-cdf SET OUTPUT PRINT LM q p_value * Example 9.1 SAMPLE 1 2725 * Table 9.1, Column (1), p. 280. OLS narr86 pcnv avgsen tottime ptime86 qemp86 inc86 black hispan * Table 9.1, Column (2), p. 280. OLS narr86 pcnv pcnvsq avgsen tottime ptime86 pt86sq qemp86 & inc86 inc86sq black hispan * Note: Do not use the TAB key when preparing SHAZAM commands. * Use the space bar to format commands. * Test of significance TEST TEST pcnvsq=0 TEST pt86sq=0 TEST inc86sq=0 END * Example 17.3 * Table 17.3, Column (1), p. 550. OLS narr86 pcnv avgsen tottime ptime86 qemp86 inc86 black hispan born60 * Poisson Regression - the MLE command is described in the chapter * MAXIMUM LIKELIHOOD ESTIMATION OF NON-NORMAL MODELS in the * SHAZAM User's Reference Manual. * Use SHAZAM Version 9 with a release date of AUG 2001 or later. MLE narr86 pcnv avgsen tottime ptime86 qemp86 inc86 black hispan born60 / & TYPE=EPOISSON PREDICT=YHAT RESID=UHAT COEF=BETA STDERR=SE * On the SHAZAM output, the R-Squared reported in Table 17.3, * Column (2), p. 550 is obtained as: * SQUARED CORR. COEF. BETWEEN OBSERVED AND PREDICTED * Calculate the error variance that incorporates a heteroskedasticity * adjustment (top of p. 549). GEN1 NOBS=$N GEN1 K=$K GENR E2=UHAT*UHAT/YHAT STAT E2 / SUMS=SSE * A degrees of freedom adjustment (N-K-1 in the denominator) is not * needed. GEN1 SIG=SQRT(SSE/NOBS) PRINT SIG * Now calculate standard errors corrected for heteroskedasticity * (bottom of p. 549). SAMPLE 1 K GENR SEHET=SIG*SE GENR T=BETA/SE GENR THET=BETA/SEHET * P-values GENR THET1=ABS(THET) DISTRIB THET1 / TYPE=NORMAL CDF=cdf1 * Get the p-value for a 2-sided test. GENR P_HET=2*(1-cdf1) * Print the results FORMAT(6(A8,1X)) READ NAMES / FORMAT BYVAR pcnv avgsen tottime ptime86 qemp86 inc86 black hispan born60 constant NAMEFMT(1X,A8,6X,4(4X,A8)) FORMAT(1X,A8,5X,3F12.4,F12.5) PRINT NAMES BETA T THET P_HET / FORMAT STOP