particle_filter_loglik: Particle Filter Log-Likelihood for a DSGE Solution

View source: R/particle-filter.R

particle_filter_loglikR Documentation

Particle Filter Log-Likelihood for a DSGE Solution

Description

Convenience wrapper around particle_filter that accepts a dsge_solution object and observed data directly.

Usage

particle_filter_loglik(
  sol,
  y,
  n_particles = 1000L,
  meas_sd = 0.001,
  seed = NULL
)

Arguments

sol

A dsge_solution object from solve_dsge.

y

Matrix or data frame of observed data (T x n_obs).

n_particles

Integer. Number of particles. Default 1000.

meas_sd

Numeric. Measurement error standard deviation. Default 0.001.

seed

Optional integer random seed.

Value

Scalar log-likelihood estimate.

See Also

particle_filter, bayes_particle

Examples


m <- dsge_model(
  obs(y ~ z), state(z ~ rho * z), start = list(rho = 0.8)
)
set.seed(1)
z <- numeric(100); for (i in 2:100) z[i] <- 0.8 * z[i-1] + rnorm(1)
dat <- data.frame(y = z - mean(z))
sol <- solve_dsge(m, params = c(rho = 0.8), shock_sd = c(z = 0.2))
ll  <- particle_filter_loglik(sol, dat, n_particles = 500, seed = 1)



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