sample 1 21 * Read the Theil (1971) data set for Klein's Model I read (klein.txt) w2 t g time1 plag klag xlag c i w1 p w1w2 xx 2sls c plag p w1w2 (w2 t g time1 plag klag xlag) / DN COEF=BETA RESID=U GEN1 DF1=$DF GEN1 K=$K GENR U2=U*U GENR ONE=1 * Copy regressors into the matrix X COPY plag p w1w2 one X * Copy instruments into the matrix Z COPY w2 t g time1 plag klag xlag one Z * 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) FORMAT (F10.3,F10.4,F10.3,F10.5) PRINT BETA HSE T PVAL / FORMAT STOP