[R] How to account for autoregressive terms?

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu May 22 13:34:55 CEST 2008


Please do not send HTML (as the posting guide asks) -- it has made your 
code unreadable.

Also, without seeing an example we don't know if the 'completely 
different' is in the output or corresponds to very different fitted 
models.

There is no 'armaFit' in R: it seems you may be using package fArma or 
armafit from package timsac.

What you have missed is arima() in base R, and perhaps (it is less often 
useful for this model) gls() in the recommended package nlme.

I suggest you try arima(), and if that does not solve this follow the 
footer of this message.

On Thu, 22 May 2008, Daphne Renault wrote:

> Hi,
>
> how to estimate a the following model in R:
>
> y(t)=beta0+beta1*x1(t)+beta2*x2(t)+...+beta5*x5(t)+beta6*y(t-1)+beta7*y(t-2)+beta8*y(t-3)
>
>
> 1) using "lm" :
> dates <- as.Date(data.df[,1])
> selection<-which(dates>=as.Date("1986-1-1") & dates<=as.Date("2007-12-31"))
> dep <- ts(data.df[selection,c("dep")])
> indep.ret1 <- ts(data.df[selection,c("RET1")])
> indep.ret2 <- ts(data.df[selection,c("RET2")])
> indep.ret3 <- ts(data.df[selection,c("RET3")])
> indep.ret4 <- ts(data.df[selection,c("RET4")])
> indep.ret5 <- ts(data.df[selection,c("RET5")])
> d<-ts.union(dep,indep.ret1,indep.ret2,indep.ret3,indep.ret4,indep.ret5,dep.lag1=lag(dep,-1),dep.lag2=lag(dep,-2),dep.lag3=lag(dep,-3))
> fit1 <- lm(dep~indep.ret1+indep.ret2+indep.ret3+indep.ret4+indep.ret5+dep.lag1+dep.lag2+dep.lag3,data=d)
> summary(fit1)
> #coeftest(fit1,vcov=NeweyWest)
>
> 2) using armaFit:
> fit2<-armaFit(dep~ar(3),xreg=ts(data.df[selection,c("RET1","RET2","RET3","RET4","RET5")]),data=ts(data.df[selection,-1]))
> summary(fit2)
>
> The results of 1) and 2) are completely different. Does anybody have an explanation for this?
>
> The dependent and some independent variables are autocorrelated because of overlapping observations (but do not posess a unit root). Therefore I have added lagged dependent variables as additional regressors to resolve the problem of autocorrelation in the dependent variables. To account for residual autocorrelation in the residuals I want to use the procedure of Newey West. Is this idea absolute nonsense?
>
> Kind regards,
> Daphne
>
>
>
>
>
>
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org 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.
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list