[R] problems with the fitted values of the function gls

Carlo Fezzi fezzi at stat.unibo.it
Tue Jun 14 16:35:49 CEST 2005


Dear helpers,
I am a beginner user of R and probably I am not using properly the
function gls() of the library â€œnlmeâ€.

I estimated a model with AR(1) residuals but apparently the fitted and
the predicted values arenâ€™t constructed considering the autocorrelation
of the residuals.

It seems that instead of having:

yt hat = (b hat)â€™ xt  + Phi (ut-1 hat) 

the program gives just:

yt hat = (b hat)â€™ xt

To understand better this issue I tried to fit a model for a simulated
AR(1) process with the following code:

--------
library(tseries)
library(nlme)

set.seed(2)
ar1sim <- arima.sim ( list (order = c (1,0,0), ar = 0.5), n = 200 )

reg <- gls ( ar1sim ~ 1, correlation = corAR1() )

plot(ar1sim)
points(predict(reg), type = â€œlâ€, col = â€œredâ€)
---------

And I obtained the plot of the fitted values (just the intercept)
compared with the actual ones.

Probably I am doing something wrong, because I donâ€™t think that the
function should behave in this way, but I donâ€™t understand what.

Thank you so much for your help,

Carlo Fezzi




More information about the R-help mailing list