[R] AR(1) and gls

2007-03-13 Thread Kate Stark
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)?

Thanks in advance,

Kate

==
Kate Stark  |  PhD candidate
Institute of Antarctic  Southern Ocean Studies 
Tasmanian Aquaculture  Fisheries Institute
University of Tasmania.

__
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.


Re: [R] AR(1) and gls

2007-03-13 Thread Gad Abraham
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.