* Reference: Chapters 15 and 16 of * Jeffrey M. Wooldridge, Introductory Econometrics: A Modern Approach, * South-Western College Publishing, 2000. * The PAR command is used to increase the memory allocation for * SHAZAM. This is required for the matrix calculations used * to calculate heteroskedasticity-robust standard errors * (see Section 15.6). PAR 7500 SAMPLE 1 753 READ (MROZ.shd) inlf hours kidslt6 kidsge6 age educ wage repwage & hushrs husage huseduc huswage faminc mtr motheduc & fatheduc unem city exper nwifeinc lwage expersq SET MISSVALU=-999 SET SKIPMISS NOWARNMISS NOWARNSKIP * Restrict the sample to persons in the labour force. SKIPIF (inlf.EQ.0) * Example 15.1 * Equation (15.15) p. 467 OLS lwage educ * Equation (15.17) p. 467 * The INST command is used for Instrumental Variables estimation. * The command format is described in the chapter * TWO-STAGE LEAST SQUARES AND SYSTEMS OF EQUATIONS * in the SHAZAM User's Reference Manual. INST lwage educ (fatheduc) * Example 15.5 * Equation (15.40), p. 478 OLS lwage educ exper expersq * Equation (15.41), p. 478 OLS educ exper expersq motheduc fatheduc / RESID=V2 TEST TEST motheduc=0 TEST fatheduc=0 END * 2SLS estimation * The SHAZAM output for the 2SLS command is identical to the * INST command. 2SLS lwage educ exper expersq (exper expersq motheduc fatheduc) / RESID=U1 * Example 15.7, p. 483. * Include the residuals (V2) from the reduced form estimation in the * structural equation. A test for endogeneity is the t-statistic * reported for the coefficient on V2. OLS lwage educ exper expersq V2 * Example 15.8, p. 486. * Testing Overidentifying Restrictions. * Regress the 2SLS residuals (U1) on all exogenous variables. OLS U1 exper expersq motheduc fatheduc * Calculate the test statistic and p-value - the temporary variables * $N and $R2 store the number of observations and R-square from * the previous estimation command. GEN1 teststat=$N*$R2 * Turn off the SKIPIF command SET NOSKIP GEN1 q=2-1 SAMPLE 1 1 DISTRIB teststat / TYPE=CHI DF=q CDF=CDF GEN1 p_value=1-CDF PRINT teststat p_value SAMPLE 1 753 * Set the SKIPIF commands previously specified to restrict the * sample to working women. SET SKIP * Now add husband's education to the IV list 2SLS lwage educ exper expersq (exper expersq motheduc fatheduc huseduc) / & RESID=U1 OLS U1 exper expersq motheduc fatheduc huseduc GEN1 teststat=$N*$R2 SET NOSKIP GEN1 q=3-1 SAMPLE 1 1 DISTRIB teststat / TYPE=CHI DF=q CDF=CDF GEN1 p_value=1-CDF PRINT teststat p_value SAMPLE 1 753 SET SKIP * Section 15.6, p. 486. * Testing for Heteroskedasticity * Run an auxiliary regression GENR U1SQ=U1**2 * The regressors are all the exogenous variables. OLS U1SQ exper expersq motheduc fatheduc huseduc / ANOVA * The ANOVA option reports the F statistic and p-value for a test of the * overall significance of the regression. On the SHAZAM output * this appears in the section labelled: * ANALYSIS OF VARIANCE - FROM MEAN * Now calculate heteroskedasticity-robust standard errors. * On the OLS command this is available with the HETCOV option. * For 2SLS the calculations can be implemented with MATRIX commands. * The matrix manipulations may require the use of the PAR command * to increase SHAZAM memory. 2SLS lwage educ exper expersq (exper expersq motheduc fatheduc huseduc) / & RESID=U1 COEF=BETA STDERR=SE2SLS GEN1 DF1=$DF GEN1 K=$K GENR U1SQ=U1**2 * SKIPIF commands are in effect -- therefore, use the COPY * command to save the results. COPY U1SQ U2 GENR one=1 * Copy regressors into the matrix X COPY educ exper expersq one X * Copy instruments into the matrix Z COPY exper expersq motheduc fatheduc huseduc one Z SET NOSKIP * Calculate heteroskedasticity-consistent standard errors MATRIX X=Z*(INV(Z'Z)*(Z'*X)) MATRIX XINV=INV(X'X) MATRIX HC=XINV*(X'DIAG(U2)*X)*XINV * Calculate the corrected standard errors and t-ratios MATRIX HSE=SQRT(DIAG(HC)) SAMPLE 1 K GENR T=BETA/HSE * Get p-values * Take the absolute value of the t-ratios. GENR TRA=ABS(T) * Use the DISTRIB command - save the CDF in the variable CDF1 DISTRIB TRA / TYPE=T DF=DF1 CDF=CDF1 * Get the p-value for a 2-sided test. GENR PVAL=2*(1-CDF1) * Print the results FORMAT(4(A8,1X)) READ NAMES / FORMAT BYVAR educ exper expersq one NAMEFMT(1X,A8,2X,5(2X,A8)) FORMAT(1X,A8,4F10.4,F10.5) PRINT NAMES BETA SE2SLS HSE T PVAL / FORMAT * The column SE2SLS are the 2SLS standard errors and the * column HSE gives the heteroskedasticity-robust standard errors. * The columns T and PVAL are the t-statistics and p-values * based on the HSE standard errors. SAMPLE 1 753 SET SKIP * Examples 16.3, 16.5 * Obtain average hours worked STAT hours / mean=avghrs * Equation (16.24), p. 513. * The DN option specifies that a divisor of N is used for the * estimation of the error variance. 2SLS hours lwage educ age kidslt6 nwifeinc & (educ age kidslt6 nwifeinc exper expersq) / DN * Estimate a labor supply elasticity at the average hours worked. TEST lwage/avghrs * Estimate a labor supply elasticity at 800 hours worked. TEST lwage/800 * Test that lwage is endogenous OLS lwage educ age kidslt6 nwifeinc exper expersq / RESID=V2 * Include the residuals (V2) from the reduced form estimation in the * structural equation. A test for endogeneity is the t-statistic * reported for the coefficient on V2. OLS hours lwage educ age kidslt6 nwifeinc V2 * Equation (16.25), p. 513. 2SLS lwage hours educ exper expersq & (educ age kidslt6 nwifeinc exper expersq) / DN * An equivalent estimation approach is to use the SYSTEM command. * The ITER=0 option gives equation estimation by 2SLS. SYSTEM 2 educ age kidslt6 nwifeinc exper expersq / DN ITER=0 OLS hours lwage educ age kidslt6 nwifeinc OLS lwage hours educ exper expersq TEST lwage:1/avghrs TEST lwage:1/800 END * An alternative estimation method is 3SLS. SYSTEM 2 educ age kidslt6 nwifeinc exper expersq / DN OLS hours lwage educ age kidslt6 nwifeinc OLS lwage hours educ exper expersq TEST lwage:1/avghrs TEST lwage:1/800 END STOP