* LAD Estimation of a Cobb-Douglas Production Function * * Keywords: * regression, ols, lad, cobb-douglas, bootstrap, kernel, koenker * * Description: * We illustrate how to estimate a Cobb-Douglas Production Function using * the Least Absolute Deviation (LAD) using bootstrap, kernel density and * Koenker method * * Author(s): * Noel Roy * Skif Pankov * * Source: * William H. Greene, Econometric Analysis - 7th Edition * Pearson International Edition, Chapter 7, Example 7.9 (page 245) * sample 1 25 format (a8, a5, 4f13.0) * Reading the datafile and naming the variables, specifying to ignore the * first line of the file and to use the formatting specified above read (TableF7-2.shd) state1 state2 output capital l num / skiplines=1 format * Generating logs of variables genr lny=log(output/num) genr lnk=log(capital/num) genr lnl=log(l/num) * Running an OLS regression of lny on lnk and lnl, saving residuals in e ols lny lnk lnl / resid=e list * Remove the two outliers from the sample skipif (abs(e).gt.0.3) ols lny lnk lnl * Restoring original sample delete skip\$ * Performing LAD estimation by the robust command, specifying to save * residuals, estimated coefficients and covariance matrix robust lny lnk lnl / resid=e cov=sigma coef=b * Computing the bootstrap and kernel density estimates as follows: * * Saving 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 * Setting the size of the new covariance matrix. dim var k k matrix var=0 * Setting the bootstrap for 500 replications. gen1 nrep=500 * Copying the data vectors to a matrix copy lny lnk lnl data * Turn off do-loop printing to avoid excessive output set nodoecho set nooutput * Starting a do loop do #=1,nrep * Sampling 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) * Setting up the new data series genr newy=y genr newk=x1 genr newl=x2 * Running a new lad regression robust newy newk newl / coef=newb diff=6 * Updating the covariance matrix matrix var=(newb-b)*(newb-b)'+var endo set output matrix bootsig=var/nrep * Printing the bootstrap covariance matrix print bootsig * Printing the bootstrap standard errors and t-ratios matrix bootse=sqrt(diag(bootsig)) matrix boott=b/bootse print bootse boott * Calculating the kernel density estimates of the covariance matrix ?stat e /stdev=s * Calculating the bandwidth parameter gen1 h=.9*s/n**.2 * Calculating the kernel function values based on the logistic density function genr expeh=exp(-e/h) genr ker=expeh/(1+expeh)**2/h * Calculating f(0)hat, as the mean of ker stat ker/mean=f0 * Estimating the covariance matrix by the Koenker method matrix kersigma=.25/f0**2*xxinv print kersigma * Printing the bootstrap standard errors and t-ratios matrix kernse=sqrt(diag(kersigma)) matrix kernt=b/kernse print kernse kernt stop * Notes: * Estimates may differ from those in the book due to differences in the kernel * functions being used. Further, due to small sample size, three estimates * difffer significantly