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

From: Carlo Fezzi <fezzi_at_stat.unibo.it>
Date: Wed 15 Jun 2005 - 00:35:49 EST


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



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 Received on Wed Jun 15 00:42:07 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:36 EST