Kate Stark wrote: > Hi there, > > I am using gls from the nlme library to fit an AR(1) regression model. > > I am wondering if (and how) I can separate the auto-correlated and random > components of the residuals? Id like to be able to plot the fitted values + > the autocorrelated error (i.e. phi * resid(t-1)), to compare with the > observed values. > > I am also wondering how I might go about calculating confidence (or > prediction) intervals around these "new" fitted values (i.e. fitted "new" = > fitted + autocorrelated error component)?
Since no one else has answered, I'll put in my 2c. Why not use the arima() function? Once you've fitted the AR(1) to it, you can extract the coefficients and the residuals, and look at the ACF and PACF of the residuals to see whether they are autocorrelated or not. tsdiag() is also useful. If an AR(1) captures all of the autocorrelation in the data, then the residuals will be iid. arima() also gives you standard errors for each estimated coefficient. To get a prediction from the model, you can use arima.sim(). One simple way to get prediction intervals about the point prediction is to sample by calling arima.sim() repeatedly and then calculate quantiles. -- Gad Abraham Department of Mathematics and Statistics The University of Melbourne Parkville 3010, Victoria, Australia email: [EMAIL PROTECTED] web: http://www.ms.unimelb.edu.au/~gabraham ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.