View source: R/regime-forecast-v5.R
| craft_predict | R Documentation |
Uses a fitted CRAFT model to transform the latest trajectory, estimate future regime probabilities, sample future-trajectory analogues, and fit smooth forecast distributions.
craft_predict(
object,
newdata = NULL,
n_draws = NULL,
seed = NULL,
type = c("all", "trajectory_draws", "distributions", "probabilities", "labels")
)
object |
A fitted CRAFT object returned by |
newdata |
Optional matrix or data frame containing the most recent series history. If supplied, it must contain the fitted asset columns and more rows than the fitted trajectory window. If |
n_draws |
Optional number of sampled future-trajectory draws. Defaults to the number of draws stored in |
seed |
Optional random seed for sampling. |
type |
Prediction output type. |
For type = "all", an object of class craft_prediction, a list
with latest_regime_labels, latest_regime_probabilities, trajectory_draws,
sampler_trace, corr_by_horizon, return_dists,
level_dists, and diagnostics. Other type values return
the requested subset.
set.seed(1)
series <- data.frame(
a = cumprod(1 + rnorm(80, 0.001, 0.01)),
b = cumprod(1 + rnorm(80, 0.0005, 0.012))
)
fit <- craft_fit(
series,
window = 5,
n_draws = 50,
n_factors = 1,
min_segment = 5,
max_regimes_per_factor = 3,
n_testing = 0,
verbose = FALSE
)
pred <- craft_predict(fit, n_draws = 25, seed = 1)
names(pred$return_dists)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.