particle_filter: Bootstrap Particle Filter

View source: R/particle-filter.R

particle_filterR Documentation

Bootstrap Particle Filter

Description

Evaluates the log-likelihood of a DSGE model using the bootstrap (sequential importance resampling) particle filter. Unlike the Kalman filter, this method is valid for fully nonlinear models and does not require a linearized solution.

Usage

particle_filter(y, H, M, Z, n_particles = 1000L, meas_sd = 0.001, seed = NULL)

Arguments

y

Matrix of observed data (T x n_obs), demeaned if appropriate.

H

State transition matrix (n_s x n_s) from solve_dsge().

M

Shock impact matrix (n_s x n_shocks).

Z

Observation matrix (n_obs x n_s), i.e. D %*% G.

n_particles

Integer. Number of particles. Default 1000.

meas_sd

Numeric scalar or vector (length n_obs). Standard deviation of measurement error added to each observation equation. A small positive value (e.g., 0.001) stabilises the filter when the model has exact observations. Default 0.001.

seed

Optional integer random seed.

Details

The bootstrap particle filter proceeds as follows each period t:

  1. Propagate: draw proposed particles by simulating the transition equation from the filtered particles at t-1.

  2. Weight: assign importance weights proportional to the observation density p(y_t | x_t^{(i)}).

  3. Normalise: rescale weights to sum to one.

  4. Log-likelihood contribution: \log \bar{w}_t where \bar{w}_t is the average unnormalised weight.

  5. Resample: systematic resampling when the effective sample size drops below n_particles / 2.

Value

A list with:

loglik

Scalar log-likelihood estimate.

filtered_states

Matrix (T x n_s) of weighted particle means.

ess

Vector (length T) of effective sample sizes.

n_particles

Number of particles used.

See Also

particle_filter_loglik, bayes_particle


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