[R] Dyn or Dynlm and out of sample forecasts

Gabor Grothendieck ggrothendieck at gmail.com
Mon May 15 18:08:45 CEST 2006


Try this:

# test data
set.seed(1)
y <- ts(1:10 + rnorm(10, 0, 0.1))

# fit model
library(dyn)
y.lm <- dyn$lm(y ~ lag(y,-1))

# use predict
tail(predict(y.lm, list(y = y)), 1)

# or multiply by coefficients giving same result
coef(y.lm) %*% c(1, tail(y,1))

# Now try it using quantile regression
library(quantreg)
y.rq <- dyn$rq(y ~ lag(y,-1))
tail(predict(y.rq, list(y = y)), 1)
coef(y.rq) %*% c(1, tail(y,1))

On 5/15/06, Kerpel, John <John.Kerpel at infores.com> wrote:
> All:
>
>
>
> How do I obtain one step ahead out-of-sample forecasts from a model
> using "dyn" or "dynlm" ?
>
>
>
> Thanks!
>
>
>
> Best,
>
>
>
> John
>
>
>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.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