DlmFitResult from dlmFit (provides G, F, W, last smoothed state)
Forecast horizon (number of steps ahead)
Optionalopts: DlmForecastOptionsOptional forecast options (obsStd, dtype, covariates)
Predicted state means, covariances, and observation predictions for steps 1…h
Forecast h steps ahead from the end of a fitted DLM.
Starting from the last smoothed state (
fit.x[:][n-1],fit.C[:][:][-1]), iterates the state-space model forward h times with no observations:x_pred(k+1) = G · x_pred(k) (state mean) C_pred(k+1) = G · C_pred(k) · G' + W (state covariance) yhat(k) = FF_k · x_pred(k) (observation mean) ystd(k) = sqrt(FF_k · C_pred(k) · FF_k' + s²) (observation std)
This is the standard Kalman prediction step with no measurement update — equivalent to appending NaN observations and running dlmFit on the extended series, but cheaper (O(h) vs O(n+h)) because it skips the full filter+smoother pass over the already-fitted data.
Equivalence with NaN-extended dlmFit: Appending NaN values to
yand callingdlmFiton the extended series produces numerically identicalyhat/ystdfor the appended steps, because the RTS smoother propagates no new information backwards through NaN steps. Use that pattern instead when:DlmFitResult(e.g. for plotting continuity).All model types are supported: local level/trend, full/trigonometric seasonal, AR(p), and covariate (β) models. Covariate states (static β blocks in G/W) are propagated correctly; pass X_forecast for their observation contributions.
The jittable core uses
lax.scanover h steps, capturing G and W as constants. The scan input is a time-varying FF_scan [h,1,m] so that covariate F rows are included inside the same compiled body.