** Chapter 14.3.2 ** for W.H. Greene, Econometric Analysis 6th ed. ***************** * (c) Noel Roy 2003, 2008 * * 14.3 SEMIPARAMETRIC ESTIMATION * 14.3.2 Least Absolute Deviations Estimation * * *=============================================================================== * Example 14.4 (p. 408) LAD Estimation of a Cobb-Douglas Production Function * SAMPLE 1 25 FORMAT (A8, A5, 4F13.0) READ (TableF14-1.prn) STATE1 STATE2 Output Capital L Num / SKIPLINES=1 FORMAT * * * Set up the regression variables. * GENR LnY=LOG(Output/Num) GENR LnK=LOG(Capital/Num) GENR LnL=LOG(L/Num) * * Compute OLS estimates and a residual plot * OLS LnY LnK LnL / RESID=E LIST * * Remove the two outliers from the sample. SKIPIF (ABS(E).GT.0.3) OLS LnY LnK LnL * Restore original sample. DELETE SKIP$ * * LAD estimation is performed by the ROBUST command. See chapter 26 * of the SHAZAM Manual. * ROBUST LnY LnK LnL /RESID=E COV=SIGMA COEF=b * * The standard errors that SHAZAM computes is based on an estimator that * is quite different from anything the textbook suggests (see p. 306 of the * Manual). * * We can compute the bootstrap and kernel density estimates as follows. * * Save the X'X inverse matrix for later use. MATRIX XXINV=SIGMA/$SIG2 * The Bootstrap method can be replicated as follows: GEN1 N=$N GEN1 K=$K * Set the size of the new covariance matrix. DIM VAR K K MATRIX VAR=0 * Set the bootstrap for 500 replications. GEN1 NREP=500 * Copy the data vectors to a matrix. COPY LNY LNK LNL DATA * Turn off DO-loop printing or you will get lots of output. SET NODOECHO SET NOOUTPUT DO #=1,NREP * Sample from the data matrix with replacement. MATRIX NEWDATA=SAMP(DATA,25) MATRIX Y=NEWDATA(0,1) MATRIX X1=NEWDATA(0,2) MATRIX X2=NEWDATA(0,3) * Set up the new data series. GENR NEWY=Y GENR NEWK=X1 GENR NEWL=X2 * Run a new LAD regression. Set the bandwidth at a high value to * avoid failures in the covariance matrix estimation (this does not * affect the coefficient estimates). ROBUST NEWY NEWK NEWL /COEF=NEWB DIFF=6 * Update the covariance matrix. MATRIX VAR=(NEWB-B)*(NEWB-B)'+VAR ENDO SET OUTPUT MATRIX BOOTSIG=VAR/NREP * Print the bootstrap covariance matrix. PRINT BOOTSIG * Print the bootstrap standard errors and t-ratios. MATRIX BOOTSE=SQRT(DIAG(BOOTSIG)) MATRIX BOOTT=B/BOOTSE PRINT BOOTSE BOOTT * Because the bootstrap depends on random sampling, and 500 replications * is not a large number, your estimates may not agree exactly with those * in the textbook. * * Now calculate the Kernel density estimates of the covariance matrix. ?STAT E /STDEV=s * Calculate the Stata bandwidth parameter. GEN1 h=.9*s/N**.2 * Calculate the Kernel function values based on the logistic density function. GENR EXPEH=EXP(-E/h) GENR KER=EXPEH/(1+EXPEH)**2/h * Calculate f(0)hat, as the mean of KER. STAT KER/MEAN=f0 * This estimate differs from the value (1.5467) in the textbook, * perhaps because a different kernel function is used. * Estimate the covariance matrix by the Koenker method (footnote 4, * p. 407) MATRIX KERSIGMA=.25/f0**2*XXINV PRINT KERSIGMA * Print the bootstrap standard errors and t-ratios. MATRIX KERNSE=SQRT(DIAG(KERSIGMA)) MATRIX KERNT=B/KERNSE PRINT KERNSE KERNT * * As can be seen (and in contrast to the conclusion drawn in the testbook), * the three different estimates vary widely, probably because the sample * size is small. STOP * *=============================================================================== * Updated November 24, 2008