* Reference: Chapter 5 of * Ernst R. Berndt, The Practice of Econometrics, Addison-Wesley, 1991. SAMPLE 1 550 READ (CPS78) ED SOUTH NONWH HISP FE MARR MARRFE EX EXSQ UNION & LNWAGE AGE NDEP MANUF CONSTR MANAG SALES CLER SERV PROF / SKIPLINES=2 * Exercise 8, p. 208. * (c) Test for heteroskedasticity OLS LNWAGE FE UNION NONWH HISP ED EX EXSQ / RESID=E * The HET option on the DIAGNOS command reports a variety of test * statistics for heteroskedasticity following on OLS regression. * The list of regressors include dummy variables. * The NOWHITE option with the DIAGNOS / HET command excludes * test approaches that are not valid when dummy variables are * in the regression equation. DIAGNOS / HET NOWHITE * Now use SHAZAM commands to construct another test statistic * for heteroskedasticity (the Koenker test). * Generate squared residuals. GENR E2=E*E * Copy the regressors to the matrix X COPY FE UNION NONWH HISP ED EX EXSQ X * Run an auxiliary regression with the the squared residuals * as the regressand. The ? prefix instructs SHAZAM to * suppress the estimation output. ?OLS E2 X * The test statistic (N)*(R-SQUARE) can be compared with * a chi-square distribution. Calculate the test statistic: GEN1 HET=$N*$R2 GEN1 DF=$K-1 * p-value DISTRIB HET / TYPE=CHI DF=DF GEN1 pval=1-$CDF PRINT HET pval * Now set-up an auxiliary regression with squares and cross-products. * This must be done to ensure that duplicate regressors are not * included in the regression. * Generate cross-product terms in the matrix XCP * Exclude NONWH*HISP - this variable is 0 for all observations. * Also include: ED*EX, ED*EXSQ, EX*EXSQ. GEN1 NVAR=1 GENR XCP=(X:1)*(X:2) GEN1 A=3 SET NODOECHO DO #=1,6 GEN1 I1=# DO %=A,7 GEN1 I2=% GENR XX=(X:#)*(X:%) IF (.NOT.((I1.EQ.3).AND.(I2.EQ.4))) MATRIX XCP=XCP|XX ENDO GEN1 A=#+2 ENDO * $COLS = number of interaction terms. PRINT $COLS * Generate some square terms GENR XSQ1=ED*ED GENR XSQ2=EXSQ*EXSQ * Run the auxiliary regression. OLS E2 X XCP XSQ1 XSQ2 * Calculate the test statistic GEN1 HET=$N*$R2 GEN1 DF=$K-1 * p-value DISTRIB HET / TYPE=CHI DF=DF GEN1 pval=1-$CDF PRINT HET pval * (a) Compute heteroskedasticity-consistent standard errors OLS LNWAGE FE UNION NONWH HISP ED EX EXSQ / HETCOV * (b) GLS OLS E2 FE UNION NONWH HISP ED EX EXSQ OLS E2 ED EX / PREDICT=EEHAT ANOVA * Check if the fitted values are all positive -- that is, check that * the MINIMUM value is positive. STAT EEHAT * On the OLS command the WEIGHT= option assumes that the error variance * is inversely proportional to the weight variable. GENR WGHT=1/EEHAT OLS LNWAGE FE UNION NONWH HISP ED EX EXSQ / WEIGHT=WGHT STOP