View source: R/particle-filter.R
| particle_filter | R Documentation |
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.
particle_filter(y, H, M, Z, n_particles = 1000L, meas_sd = 0.001, seed = NULL)
y |
Matrix of observed data (T x n_obs), demeaned if appropriate. |
H |
State transition matrix (n_s x n_s) from |
M |
Shock impact matrix (n_s x n_shocks). |
Z |
Observation matrix (n_obs x n_s), i.e. |
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. |
The bootstrap particle filter proceeds as follows each period t:
Propagate: draw proposed particles by simulating the transition equation from the filtered particles at t-1.
Weight: assign importance weights proportional to the
observation density p(y_t | x_t^{(i)}).
Normalise: rescale weights to sum to one.
Log-likelihood contribution: \log \bar{w}_t where
\bar{w}_t is the average unnormalised weight.
Resample: systematic resampling when the effective
sample size drops below n_particles / 2.
A list with:
loglikScalar log-likelihood estimate.
filtered_statesMatrix (T x n_s) of weighted particle means.
essVector (length T) of effective sample sizes.
n_particlesNumber of particles used.
particle_filter_loglik, bayes_particle
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.