* R. Carter Hill, William E. Griffiths and Guay C. Lim, * Principles of Econometrics, Third Edition, Wiley, 2008. * A demonstration of the SHAZAM calculations for: * (1) the Newey-West variance estimator (Chapter 9.3.1, page 235) * (2) the residual correlogram (Chapter 9.4.1, page 240) SAMPLE 1 34 READ (bangla.shd) PRICE AREA GENR LA=LOG(AREA) GENR LP=LOG(PRICE) * On the OLS command the AUTCOV= option is used for calculating * Newey-West standard errors (p. 235). GEN1 L=1 OLS LA LP / LOGLOG RSTAT AUTCOV=L RESID=E * The numeric estimates of the standard errors reported by SHAZAM * are different from the textbook. * The commands below use matrix operations to demonstrate the SHAZAM * calculation method for the Newey-West standard errors. * Further details are in the SHAZAM User's Reference Manual. GEN1 N=$N GEN1 K=$K GENR E2=E*E GENR ONE=1 COPY LP ONE X MATRIX XX=INV(X'X) DIM S0 K K SET NODOECHO DO #=1,N MATRIX S0=S0 + E2(#) * X(#,0)'X(#,0) ENDO MATRIX S0=S0/N DO #=1,L GEN1 BEG=#+1 GEN1 W=1-(#/(L+1)) DO %=BEG,N MATRIX OMEGA=E(%)*E(%-#)*X(%,0)'*X(%-#,0)/N MATRIX S0=S0 + W*(OMEGA+OMEGA') ENDO ENDO MATRIX AUTCOV=N*XX*S0*XX * Get the Newey-West Standard Errors and check that they * are identical to the standard errors reported by the * OLS / AUTCOV= command. MATRIX SE=SQRT(DIAG(AUTCOV)) PRINT SE * ------------------------------------------------------------ OLS LA LP * The ACF option on the DIAGNOS command reports the residual * correlogram, p. 240. DIAGNOS / ACF * Demonstrate the calculations. GEN1 SSE=$SSE DIM COR 6 DO #=1,6 GEN1 N1=1+# SAMPLE N1 34 GENR EE=E*LAG(E,#) STAT EE / SUMS=ES GEN1 COR:#=ES/SSE ENDO SAMPLE 1 6 GENR LAG=TIME(0) PRINT LAG COR STOP