* * Examples 11.4 and 11.5, page 409 and 412 * Goldfeld-Quandt and Breusch-Pagan-Godfrey test * open data table11-3.prn data(format=prn,org=columns) 1 30 * * Goldfeld-Quandt test * linreg ry 1 13 # constant rx compute rss1=%rss,df1=%ndf linreg ry 18 30 # constant rx compute rss2=%rss,df2=%ndf compute lambda=(rss2/df2)/(rss1/df1) cdf(title="Goldfeld-Quandt Test") ftest lambda df2 df1 * * This data set provides the sorted data. In general, you won't have that. The * following shows how to generate a sorted data set * * It's a good idea to work with copies of the data series, not the original x,y * variables * set rx = x set ry = y * * The order instruction below sorts rx and does a parallel sort on ry. * order rx / ry * * Breusch-Godfrey-Pagan test * linreg y # constant x * * Divide through by the ML estimate of the residual variance * set p = %resids**2/%sigmasq linreg p # constant x * * The total SS of p is %variance*(%nobs-1). (LINREG makes %variance equal to the * sample variance of the dependent variable), so ess=total SS-residual sum of * squares. * compute ess=%variance*(%nobs-1)-%rss compute theta=ess/2 cdf(title="Breusch-Godfrey-Pagan test") chisqr theta 1