Re: [R] dynamic regression

From: Achim Zeileis <Achim.Zeileis_at_wu-wien.ac.at>
Date: Sat 31 Jul 2004 - 02:03:39 EST

On Fri, 30 Jul 2004 08:13:05 -0700 (PDT) bob mccall wrote:

> Greetings:
>
> Is there an simple way to do dynamic regressions in R?
> >From what I've seen, one must use arima() and construct the X matrix
> >with lagged values etc. and modify Y as well.

If you want OLS regression with lagged regressors you could also transform your data using lag() and window() and then use lm(). E.g. for a multiplicative SARIMA(1,0,0)(1,0,0) model for the seatbelt data you could do something like:

data(UKDriverDeaths)
seatbelt <- log10(UKDriverDeaths)
seatbelt <- cbind(seatbelt, lag(seatbelt, k = -1),   lag(seatbelt, k = -12))
colnames(seatbelt) <- c("y", "ylag1", "ylag12") seatbelt <- window(seatbelt, start = c(1970, 1), end = c(1984, 12))

lm(y ~ ylag1 + ylag12, data = seatbelt)

hth,
Z

> Thanks,
>
> Bob
>
>
> ---------------------------------
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>



R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Jul 31 02:52:34 2004

This archive was generated by hypermail 2.1.8 : Wed 03 Nov 2004 - 22:55:23 EST