posterior_forecast: Forecast with parameter uncertainty (posterior fan)

View source: R/posterior_forecast.R

posterior_forecastR Documentation

Forecast with parameter uncertainty (posterior fan)

Description

Produces 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))

Arguments

est

A qpm_estimate (method "bayes").

horizon

Forecast horizon in quarters.

ndraws

Number of posterior draws to propagate.

bands

Coverage levels for the fan.

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


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")


qpmR documentation built on Sept. 29, 2026, 5:10 p.m.