bayes_particle: Bayesian DSGE Estimation Using Particle Marginal...

View source: R/particle-filter.R

bayes_particleR Documentation

Bayesian DSGE Estimation Using Particle Marginal Metropolis-Hastings

Description

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.

Usage

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
)

Arguments

model

A dsge_model or dsgenl_model object.

data

A data frame or matrix of observed variables.

priors

Named list of dsge_prior objects.

chains

Integer. Number of MCMC chains. Default 1.

iter

Integer. Total iterations per chain. Default 2000.

warmup

Integer. Warmup iterations. Default floor(iter/2).

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.

Details

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.

Value

An object of class c("dsge_particle", "dsge_bayes") with the same structure as bayes_dsge plus:

n_particles

Number of particles used.

meas_sd

Measurement error SD.

estimator

Character string "pmmh".

References

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.

See Also

particle_filter, particle_filter_loglik, bayes_dsge

Examples


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)



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