* Testing Credit Card Expenditure Model for Heteroskedasticity * * Keywords: * regression, ols, heteroskedasticity, credit card, expenditure, white, * breusch-pagan, 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.3 (page 317) * * 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 * Doing diagnostic tests for Heteroskedasticity of the previous estimated model diagnos / het * Diagnos command fails to compute the White test statistic, because not * all of the variables in the set of x and its squares and cross-products are * unique (Income squared appears twice, and Ownrent being a binary * dummy has the same value as its square). DIAGNOS fails because of * perfect multicollinearity in the regressors). However, the White test can * be computed manually: genr u2=u**2 genr age2=age**2 genr income3=income**3 genr income4=income**4 genr ageinc=age*income genr ageinc2=age*income2 genr ageown=age*ownrent genr owninc=ownrent*income genr owninc2=ownrent*income2 ?ols u2 age ownrent income income2 income3 income4 age2 ageinc ageinc2 ageown owninc owninc2 * The test statistic is N R-squared, and is asymptotically chi-squared: gen1 chistat=$n*$r2 gen1 df=$k-1 print chistat * Finding the p-value of chistat distrib chistat / type=chi df=df * The diagnos / het command produces Breusch-Pagan/Godfrey (B-P-G) * test statistics. Example however uses the alternative hypothesis that * the variance is a quadratic function in income. For this alternative * hypothesis, the test statistics must be computed manually: ?ols avgexp age ownrent income income2 /resid=e genr ee=e**2 gen1 sse=$sse * Computing the gi vector genr g=ee/(sse/$n)-1 * The LM statistic is 1/2 the SSR of the regression of gi on (1,zi) ?ols g income income2 gen1 bp=.5*$ssr gen1 DF=$K-1 distrib bp / type=chi df=df * Computing the Koenker-Bassett LM statistic KB. genr diff=ee-sse/$n genr brackets=diff**2 ?stat brackets / mean=v * Making diff a vector. copy diff a genr i=1 * Z is the matrix of independent variables in the stochastic equation. copy i income income2 z * KB is the LM statistic matrix kb=(1/v)*a'z*(inv(z'z))*z'a distrib kb / type=chi df=df * The Bera-Jarque test for normality can be applied to the OLS residuals * by the / gf option ols avgexp age ownrent income income2 / gf stop