where , the lag-1 autocorrelation in the residuals from the OLS fit. These transformed version of the response and predictor incorporate information from the previous time period in the modeling process, thus addressing the autocorrelation. Below is the regression of on fit using a function I wrote called cochrane.orcutt() which takes a simple linear regression model fit to these data as an argument. > tooth.com = cochrane.orcutt(tooth.lm) > Call: lm(formula = ytprime ~ xtprime) Residuals: Min 1Q Median 3Q Max -0.56115 -0.24889 -0.05455 0.25247 0.83009 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 15.8043 0.9502 16.63 5.95e-12 *** xtprime -24.1310 1.9093 -12.64 4.53e-10 *** --- Signif. codes: 0 0.001 0.01 0.05 0.1 1 ‘***’ ‘**’ ‘*’ ‘.’ ‘ ’ Residual standard error: 0.3956 on 17 degrees of freedom Multiple R-squared: 0.9038, Adjusted R-squared: 0.8981 F-statistic: 159.7 on 1 and 17 DF, p-value: 4.535e-10 > dwtest(tooth.com) Durbin-Watson test data: tooth.com DW = 1.9326, p-value = 0.3896 alternative hypothesis: true autocorrelation is greater than 0 We can see that the Cochrane-Orcutt Method has eliminated the autocorrelation in the residuals (Durbin-Watson p-value = .3896). > acf(resid(tooth.com)) We can see from the ACF plot of the residuals there is no significant autocorrelation in the residuals from the model fit using the Cochrane-Olcutt method. Another approach to dealing with autocorrelation in a OLS regression is to include lags of the response series and the predictors series in the regression model. Equations 3.119 and 3.120 in the text give two models for doing this. The first incorporates first order
where , the lag-1 autocorrelation in the residuals from the OLS fit. These transformed version of the response and predictor incorporate information from the previous time period in the modeling process, thus addressing the autocorrelation. Below is the regression of on fit using a function I wrote called cochrane.orcutt() which takes a simple linear regression model fit to these data as an argument. > tooth.com = cochrane.orcutt(tooth.lm) > Call: lm(formula = ytprime ~ xtprime) Residuals: Min 1Q Median 3Q Max -0.56115 -0.24889 -0.05455 0.25247 0.83009 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 15.8043 0.9502 16.63 5.95e-12 *** xtprime -24.1310 1.9093 -12.64 4.53e-10 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 0.3956 on 17 degrees of freedom Multiple R-squared: 0.9038, Adjusted R-squared: 0.8981 F-statistic: 159.7 on 1 and 17 DF, p-value: 4.535e-10 > dwtest(tooth.com) Durbin-Watson test data: tooth.com DW = 1.9326, p-value = 0.3896 alternative hypothesis: true autocorrelation is greater than 0 We can see that the Cochrane-Orcutt Method has eliminated the autocorrelation in the residuals (Durbin-Watson p-value = .3896). > acf(resid(tooth.com)) We can see from the ACF plot of the residuals there is no significant autocorrelation in the residuals from the model fit using the Cochrane-Olcutt method. Another approach to dealing with autocorrelation in a OLS regression is to include lags of the response series and the predictors series in the regression model. Equations 3.119 and 3.120 in the text give two models for doing this. The first incorporates first order
Ch%203%20-%20Computing%20Handout%20in%20R.docx