Forecast with parameter uncertainty (posterior fan)
Source:R/posterior_forecast.R
posterior_forecast.RdProduces a forecast whose fan bands integrate over the posterior:
for each sampled parameter draw the model is re-solved, the data
re-filtered (so the initial state reflects that draw), and a path
sampled from the resulting Gaussian predictive; pointwise band
quantiles are then taken across draws. The bands therefore combine
future-shock uncertainty with parameter uncertainty — they are wider
than the fixed-parameter fans of qpm_forecast().
Usage
posterior_forecast(est, horizon = 12, ndraws = 200, bands = c(0.5, 0.7, 0.9))Value
A qpm_forecast-compatible object (posterior-mean path,
quantile bands, smoothed history from the posterior-mean model);
$posterior records the number of draws used.
Examples
# \donttest{
m <- qpm_model(variables = vars(x = "x"), shocks = shocks(e),
equations = eqs(x ~ rho * x[-1] + e),
params = list(rho = 0.5))
obs <- simulate(qpm_solve(qpm_calibrate(m, rho = 0.8)), nsim = 100, seed = 1)
est <- qpm_estimate(m, obs, priors(rho = beta(0.5, 0.2)),
iter = 300, chains = 1, seed = 2, verbose = FALSE)
fc <- posterior_forecast(est, horizon = 8, ndraws = 15)
plot(fc, vars = "x")
# }