| validate_forecast | R Documentation |
Experimental. The rolling-origin design follows standard time-series cross-validation practice, but unlike the estimators in this package it has no external reference implementation to validate against, and its interface, defaults, and reported metrics may change in a future release.
Performs rolling-origin one-step prediction from fit_var() or
fit_graphical_var(). Each split fits the estimator on earlier blocks and
predicts current variables in the next block from their lag-1 values. Scaling
and within-person centring parameters are learned from the training split
only, then applied to the assessment split before prediction.
validate_forecast(
data,
vars,
estimator = c("var", "graphical_var"),
id = NULL,
day = NULL,
beep = NULL,
initial = NULL,
assess = 1L,
step = 1L,
n_splits = NULL,
block_size = NULL,
scale = TRUE,
center_within = TRUE,
delete_missings = TRUE,
keep_fits = FALSE,
...
)
data |
A |
vars |
Character vector of variable names. |
estimator |
|
id |
Character. Name of the person-ID column, or |
day |
Character. Name of the day/session column, or |
beep |
Character. Name of the measurement-occasion column, or |
initial |
Integer number of ordered blocks in the first training split. Default uses 60 percent of blocks, leaving at least one assessment block. |
assess |
Integer number of blocks to assess per split. Default |
step |
Integer number of blocks to advance between splits. Default |
n_splits |
Optional maximum number of rolling splits. |
block_size |
Integer or |
scale |
Logical. Whether to standardize using training-split means and
SDs. Default |
center_within |
Logical. Whether to centre within person using
training-split person means when more than one id is present. Default
|
delete_missings |
Logical. Drop incomplete current/lagged assessment
rows. Default |
keep_fits |
Logical. Store fitted split models? Default |
... |
Further arguments passed to the estimator. |
A forecast_result with $predictions, $metrics, $splits,
$failures, and optionally $fits.
set.seed(1)
d <- data.frame(id = 1, day = rep(1:5, each = 12),
beep = rep(1:12, 5),
A = rnorm(60), B = rnorm(60), C = rnorm(60))
fc <- validate_forecast(d, vars = c("A", "B", "C"), id = "id",
day = "day", beep = "beep",
initial = 3, n_splits = 2, scale = FALSE)
fc$metrics
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.