* White Estimator with Credit Card Expenditure Model * * Keywords: * regression, ols, heteroskedasticity, credit card, expenditure, white, * davidson-mackinnon, wald, test * * Description: * We illustrate how to correct for Heteroskedasticity in the OLS Model for * Monthly Credit Card Expenditure using White's and Davidson-MacKinnon * standard errors and how to do a Wald test * * Author(s): * Noel Roy * Skif Pankov * * Source: * William H. Greene, Econometric Analysis - 7th Edition * Pearson International Edition, Chapter 9, Example 9.2 (page 314) * * Reading the datafile and retrieving names of the variables read (TableF9-1.shd) / names * Generating the square of income genr income2=income**2 * Using only those observations for which avgexp is nonzero. * The skipif (expression) command will cause subsequent commands to skip * observations for which the value of the expression is positive or true set nowarnskip skipif (avgexp .eq. 0) * Running an OLS regression of avgexp on age, ownrent, income and income2, * specifying to save the estimated residuals and standard errors ols avgexp age ownrent income income2 / resid=u stderr=se * Testing the joint significance of income and income2 test test income test income2 end * Running an OLS regression of avgexp on age, ownrent, income and income2, * specifying to use white's heteroscedastic-consistent covariance matrix * estimation to correct estimates for an unknown form of heteroscedasticity ols avgexp age ownrent income income2 / hetcov stderr=white * Computing the Wald test statistic using the robust covariance matrix * (the F-statistic is also given, even though it is not applicable here) test test income=0 test income2=0 end * Davidson/MacKinnon (1) (dm1) can be calculated by multiplying the White * standard errors by the square root of n/(n-k) * Davidson/MacKinnon (2) dm2 can be calculated by copying the independent * variables (including the constant) into the matrix labelled x genr con=1 copy age ownrent income income2 con x * Calculating the "hat" values xi'inv(x'x)xi. matrix hii=diag(x*inv(x'x)*x') * Scaling the squared residuals by their true variances mii=1-hii genr u2=u**2 copy u2 e2 matrix s0=e2/(1-hii) * Calculating the adjusted standard errors, with the ei squared * scaled by mii matrix dm2=sqrt(diag(inv(x'x)*x'*diag(s0)*x*inv(x'x))) * Presenting all four standard errors together, replicating table 9.1 gen1 mult = $n/$df sample 1 5 genr dm1 = sqrt(mult)*white print se white dm1 dm2 stop