Re: [R] How to account for autoregressive terms?

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Thu, 22 May 2008 12:34:55 +0100 (BST)

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 &lt;- as.Date(data.df[,1])
> selection&lt;-which(dates&gt;=as.Date("1986-1-1") &amp; dates&lt;=as.Date("2007-12-31"))
> dep &lt;- ts(data.df[selection,c("dep")])
> indep.ret1 &lt;- ts(data.df[selection,c("RET1")])
> indep.ret2 &lt;- ts(data.df[selection,c("RET2")])
> indep.ret3 &lt;- ts(data.df[selection,c("RET3")])
> indep.ret4 &lt;- ts(data.df[selection,c("RET4")])
> indep.ret5 &lt;- ts(data.df[selection,c("RET5")])
> d&lt;-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 &lt;- 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&lt;-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

______________________________________________
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.
Received on Thu 22 May 2008 - 11:36:55 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 22 May 2008 - 12:30:41 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive