View source: R/particle-filter.R
| bayes_particle | R Documentation |
Estimates DSGE model parameters via the Particle Marginal Metropolis-Hastings (PMMH) algorithm (Andrieu, Doucet & Holenstein, 2010). The particle filter replaces the Kalman filter, enabling fully nonlinear likelihood evaluation without any linearization.
bayes_particle(
model,
data,
priors,
chains = 1L,
iter = 2000L,
warmup = floor(iter/2),
thin = 1L,
n_particles = 500L,
meas_sd = 0.001,
proposal_scale = 0.1,
demean = TRUE,
seed = NULL
)
model |
A |
data |
A data frame or matrix of observed variables. |
priors |
Named list of |
chains |
Integer. Number of MCMC chains. Default 1. |
iter |
Integer. Total iterations per chain. Default 2000. |
warmup |
Integer. Warmup iterations. Default |
thin |
Integer. Thinning interval. Default 1. |
n_particles |
Integer. Particles per likelihood evaluation. Default 500. Higher values give more accurate but slower estimates. |
meas_sd |
Numeric. Measurement error SD. Default 0.001. |
proposal_scale |
Numeric. Initial RWMH proposal scale. Default 0.1. |
demean |
Logical. Demean observed data before estimation. Default TRUE. |
seed |
Integer. Random seed. |
The PMMH algorithm is an exact Bayesian method: the particle filter
provides an unbiased estimator of the likelihood, and the resulting
Markov chain targets the exact posterior distribution. A larger
n_particles gives a less noisy likelihood estimate and better
mixing, at the cost of more computation per iteration.
As a rough guide, n_particles = 500 is adequate for models with
up to 5-6 states; larger models may require 1000-2000.
An object of class c("dsge_particle", "dsge_bayes") with the
same structure as bayes_dsge plus:
n_particlesNumber of particles used.
meas_sdMeasurement error SD.
estimatorCharacter string "pmmh".
Andrieu, C., Doucet, A. & Holenstein, R. (2010). Particle Markov chain Monte Carlo methods. Journal of the Royal Statistical Society: Series B, 72(3), 269-342.
Fernandez-Villaverde, J. & Rubio-Ramirez, J. F. (2007). Estimating macroeconomic models: A likelihood approach. Review of Economic Studies, 74(4), 1059-1087.
particle_filter, particle_filter_loglik,
bayes_dsge
m <- dsge_model(
obs(y ~ z), state(z ~ rho * z), start = list(rho = 0.8)
)
set.seed(2)
z <- numeric(80); for (i in 2:80) z[i] <- 0.8 * z[i-1] + rnorm(1)
dat <- data.frame(y = z)
pr <- list(rho = prior("beta", shape1 = 2, shape2 = 2))
fit <- bayes_particle(m, dat, pr,
chains = 1L, iter = 300L, warmup = 150L,
n_particles = 200L, seed = 2L)
coef(fit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.