smooth_states: Smoothed State Estimates from an Estimated DSGE Model

View source: R/smoother.R

smooth_states.dsge_solutionR Documentation

Smoothed State Estimates from an Estimated DSGE Model

Description

Computes the Rauch-Tung-Striebel (RTS) smoother to produce optimal state estimates using all available observations. Compared to the filtered states (which only use past data), smoothed states also incorporate future observations.

Usage

## S3 method for class 'dsge_solution'
smooth_states(x, data, ...)

smooth_states(x, ...)

## S3 method for class 'dsge_fit'
smooth_states(x, ...)

## S3 method for class 'dsge_bayes'
smooth_states(x, ...)

Arguments

x

A dsge_fit or dsge_bayes object.

data

Matrix or data frame of observed data with columns matching the model's observable names. Required when x is a dsge_solution; ignored for dsge_fit / dsge_bayes objects (which carry their own data).

...

Additional arguments (currently unused).

Details

The smoother uses the state-space representation:

x_{t+1} = H x_t + M \varepsilon_{t+1}

y_t = Z x_t

where Z = D \cdot G. The smoothed states are the expectation of the state vector conditional on all observations: x_{t|T} = E[x_t | y_1, \ldots, y_T].

For Bayesian models, the smoother is evaluated at the posterior mean.

Value

An object of class "dsge_smoothed" containing:

smoothed_states

T x n_s matrix of smoothed state estimates.

filtered_states

T x n_s matrix of filtered state estimates.

smoothed_obs

T x n_obs matrix of smoothed observable fits.

residuals

T x n_obs matrix of observation residuals.

state_names

Character vector of state variable names.

obs_names

Character vector of observed variable names.

steady_state

Steady-state values (if available).

Examples


m <- dsge_model(
  obs(y ~ z),
  state(z ~ rho * z),
  start = list(rho = 0.5)
)
set.seed(1)
e <- rnorm(100)
z <- numeric(100); for (i in 2:100) z[i] <- 0.8 * z[i-1] + e[i]
fit <- estimate(m, data = data.frame(y = z))
sm <- smooth_states(fit)



dsge documentation built on Sept. 25, 2026, 5:08 p.m.