[prev in list] [next in list] [prev in thread] [next in thread]
List: r-help
Subject: [R] gls with serial correlation
From: Wayne Jones <JonesW () kssg ! com>
Date: 2003-11-21 12:55:51
[Download RAW message or body]
Hello there fellow R users,
Im trying to fit a gls model to data which has serial correlation in the
errors e(t)=p*e(t-1).
However I dont seem to be having much luck in erradicating the
autocorrelation in the residuals.
I have created the following example.
library(nlme)
x<-rnorm(100)
y<-3+2*x
y<-y+arima.sim(100,model=list(ar=(0.6)))+rnorm(100,0,0.2)
#Create a data set with first order serial correlation in the residuals.
my.mat<-as.data.frame(cbind(y,x))
acf(lm(y~x,my.mat)$residuals) #fit a linear model and observe the
residuals.
acf(as.numeric(gls(y~x,my.mat,correlation = corAR1())$residuals)); # fit a
gls model with correlated error terms and observe autocorrelation of
residuals
Further more if I use time series fitting I get a different result.
library(ts)
acf(arima(as.ts(y),xreg=x,order=c(1,0,0))$residuals) # fit a time series
model and observe the residuals
I must be doing something wrong.
Am I using the correct correlation structure (corAr1).
Thanks in advance,
Wayne
Dr Wayne R. Jones
Senior Statistician / Research Analyst
KSS Limited
St James's Buildings
79 Oxford Street
Manchester M1 6SS
Tel: +44(0)161 609 4084
Mob: +44(0)7810 523 713
KSS Ltd
Seventh Floor St James's Buildings 79 Oxford Street Manchester M1 6SS England
Company Registration Number 2800886
Tel: +44 (0) 161 228 0040 Fax: +44 (0) 161 236 6305
mailto:kssg@kssg.com http://www.kssg.com
The information in this Internet email is confidential and m...{{dropped}}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic