[R] dynamic regression

Achim Zeileis Achim.Zeileis at wu-wien.ac.at
Fri Jul 30 18:03:39 CEST 2004


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 at 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
>




More information about the R-help mailing list