* * Dougherty, Introduction to Econometrics, 4th ed * Example from Section 12.1 * Testing for serial correlation * open data demand.xls calendar(a) 1959:1 data(format=xls,org=columns) 1959:01 2003:01 adm book busi clot date dent doc dpi flow food furn gas gaso \$ hous legl mags mass opht padm pbook pbusi pclot pdent pdoc pflow pfood pfurn pgas pgaso phous plegl \$ pmags pmass pop popht prelg ptele ptob ptoys ptpe relg tele time tob toys tpe * set prelfood = 100.0*pfood/ptpe set lgfood = log(food) set lgdpi = log(dpi) set lgprfood = log(prelfood) * linreg lgfood # constant lgdpi lgprfood set u = %resids linreg u # constant u{1} linreg u # constant lgdpi lgprfood u{1} cdf(title="Breusch-Godfrey Test") chisqr %trsquared 1 * linreg lgfood # constant lgdpi lgprfood lgfood{1} set u = %resids * linreg u # constant u{1} linreg u # constant lgdpi lgprfood lgfood{1} u{1} cdf(title="Breusch-Godfrey Test") chisqr %trsquared 1 * linreg lgfood # constant lgdpi lgprfood lgfood{1} * * The Durbin H can be computed using %rho, %nobs and %stderrs (here %stderrs(4) is * the standard error on the 4th coefficient, which is the lagged dependent * variable). * compute durbinh=%rho*sqrt(%nobs/(1-%nobs*%stderrs(4)^2)) * cdf(title="Durbin-H test") normal durbinh