Description Usage Arguments Details Value Author(s) References Examples
Creates a sequence of pseudo out-of-sample forecasts.
1 2 | recursive_forecasts(model, dataset, R,
window = c("recursive", "rolling", "fixed"),...)
|
model |
A function that takes |
dataset |
A data frame with more than |
R |
An integer: the size of the estimation window. |
window |
One of "rolling", "recursive", or "fixed" describing the estimation strategy |
... |
Additional arguments to pass to |
Uses model
to create a sequence of forecasts or forecast errors for
observations R+1
,...,nrow(dataset)
.
For the "rolling" window, each forecast comes from the model estimated
with the previous R
observations. For the "recursive" window, each
forecast uses all of the previous observations. And for the "fixed"
window, each forecast uses the first R
observations.
A vector of length nrow(dataset) - R
, containing the forecasts.
Gray Calhoun gcalhoun@iastate.edu
Calhoun, G. 2011, Documentation appendix: An asymptotically normal out-of-sample test of equal predictive accuracy for nested models. Unpublished manuscript.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | d <- data.frame(x = rnorm(15), y = rnorm(15))
ols <- function(d) lm(y ~ x, data = d)
## Basic Usage:
recursive_forecasts(ols, d, 4, "recursive")
## Illustrate different estimation windows by comparing forecasts for
## observation 11 (note that the forecast for observation 11 will be the
## 7th element that apply.oos returns in this example)
newd <- d[11,]
all.equal(predict(lm(y ~ x, data = d[7:10,]), d[11,]),
recursive_forecasts(ols, d, 4, "rolling")[7])
all.equal(predict(lm(y ~ x, data = d[1:10,]), d[11,]),
recursive_forecasts(ols, d, 4, "recursive")[7])
all.equal(predict(lm(y ~ x, data = d[1:4,]), d[11,]),
recursive_forecasts(ols, d, 4, "fixed")[7])
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.