* * HETEROTEST.RPF * Example of tests for heteroscedasticity * From RATS User's Guide, Section 3.4 * * Adapted from Wooldridge(2009), "Introductory Econometrics, 4th * edition", Example 8.4 from pages 273-274. * open data hprice1.raw data(format=free,org=columns) 1 88 price assess bdrms lotsize sqrft \$ colonial lprice lassess llotsize lsqrft * * Because we keep re-estimating this (possibly over different samples), * we define an EQUATION. * equation linff price # constant lotsize sqrft bdrms * linreg(equation=linff) * set usq = %resids^2 linreg usq # constant lotsize sqrft bdrms exclude(title="Breusch-Pagan Test for Heteroscedasticity") # lotsize sqrft bdrms cdf(title="Breusch-Pagan Test, LM Form") chisqr %trsquared 3 * * The LM test can also be done using the procedure @RegWhiteTest with * the option type=bp. You need to do this right after the regression * that you want to test. * linreg(equation=linff) @RegWhiteTest(type=bp) * * Harvey test * linreg(equation=linff) set logusq = log(%resids^2) set llotsize = log(lotsize) linreg logusq # constant llotsize cdf(title="Harvey Test") chisqr %trsquared 1 * * White's test (the hard way, not recommended) * linreg(equation=linff) set usq = %resids^2 set lotsq = lotsize^2 set sqrftsq = sqrft^2 set bdrmssq = bdrms^2 set lotxsqrft = lotsize*sqrft set lotxbdrms = lotsize*bdrms set sqftxbdrms = sqrft*bdrms * linreg usq # constant lotsize sqrft bdrms \$ lotsq sqrftsq bdrmssq lotxsqrft lotxbdrms sqftxbdrms cdf(title="White Heteroscedasticity Test") chisqr \$ %trsquared %nobs-%ndf-1 * * Using @RegWhiteTest (recommended) * linreg(equation=linff) @RegWhiteTest * * Goldfeld-Quandt test (on lot size) * order(ranks=lotranks) lotsize linreg(equation=linff,smpl=lotranks<=36) compute rss1=%rss,ndf1=%ndf linreg(equation=linff,smpl=lotranks>=53) compute rss2=%rss,ndf2=%ndf cdf(title="Goldfeld-Quandt Test") ftest \$ (rss2/ndf2)/(rss1/ndf1) ndf2 ndf1