View source: R/trajectory-forecast.R
| trajectory_forecast | R Documentation |
Fits one smoothed empirical forecast distribution per column in a data frame of sampled future-trajectory draws. Optionally reconstructs returns or differences into forecast levels.
trajectory_forecast(
trajectory_draws,
last_level = NULL,
recon_mode = NULL,
probs = seq(0.001, 0.999, length.out = 1000),
spar = NULL,
density_spar = NULL,
eps = 1e-06,
enforce_monotone = TRUE,
plot_result = FALSE,
min_obs = 10L,
min_unique = 10L,
jitter_if_needed = TRUE,
jitter_scale = 1e-08,
zero_density_outside = TRUE,
seed = 1L,
verbose = FALSE,
return_diagnostics = TRUE
)
trajectory_draws |
Data frame of sampled future-trajectory draws, with one variable per column. |
last_level |
Optional scalar or vector of latest observed levels used to reconstruct forecast levels. |
recon_mode |
Optional reconstruction mode: |
probs |
Probability grid passed to |
spar |
Optional quantile smoothing parameter. |
density_spar |
Optional density smoothing parameter. |
eps |
Small positive numerical tolerance. |
enforce_monotone |
Logical. If |
plot_result |
Logical. If |
min_obs |
Minimum observations used for each fitted distribution. Shorter samples are bootstrapped. |
min_unique |
Minimum unique values before jittering is considered. |
jitter_if_needed |
Logical. If |
jitter_scale |
Scale of jitter relative to the sample scale. |
zero_density_outside |
Logical. If |
seed |
Optional random seed used for augmentation and jitter. |
verbose |
Logical. If |
return_diagnostics |
Logical. If |
A named list of distribution objects. Diagnostics and settings are attached as attributes when requested.
set.seed(1)
trajectory_draws <- data.frame(a = rnorm(40, 0.01, 0.02), b = rnorm(40, -0.01, 0.03))
fc <- trajectory_forecast(
trajectory_draws,
probs = seq(0.05, 0.95, length.out = 30),
verbose = FALSE
)
fc$a$qfun(0.5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.