Description
Nested Particle Filter for Stochastic SEIR Epidemic Models.
Description
Implements the online Bayesian inference framework for joint state and parameter estimation in a stochastic Susceptible-Exposed-Infectious-Recovered (SEIR) epidemic model with a time-varying transmission rate. The log-transmission rate is modelled as a latent Ornstein-Uhlenbeck (OU) process with exact Gaussian discrete-time transitions. Inference is performed via the nested particle filter (NPF) of Crisan and Miguez (2018) <doi:10.3150/17-BEJ954>, which maintains an outer particle layer over the OU hyperparameters and, for each outer particle, an inner bootstrap filter over epidemic states. The Cori-style renewal-equation estimator follows Cori et al. (2013) <doi:10.1093/aje/kwt133>. The package also provides utilities for simulation, posterior summarisation, and forecasting.
README.md
npfseir
Nested Particle Filter for Stochastic SEIR Models with Latent OU Transmission
An R package implementing the online Bayesian epidemic inference framework of Feng and Wang (2025).
Installation
# From source (local):
# R CMD build npfseir
# R CMD INSTALL npfseir_0.2.1.tar.gz
Quick start
library(npfseir)
# Fixed model parameters
fixed <- list(eps=1/5, gamma=1/7, delta=1/(70*365), b=1/(70*365),
q=0.15, N=330e6, sigma_comp=5000)
# Simulate
set.seed(1)
x0 <- c(330e6 - 5000, 2000, 3000, 0, log(0.3))
traj <- seir_simulate(400, kappa=0.10, sigma_psi=0.30,
mu_psi=log(0.25), x0=x0, fixed=fixed)
# Fit
fit <- npf_seir(traj$obs[-1], fixed, K=100, M=200, seed=42)
# Summarise and plot
summary(fit, burn=30)
plot(fit, burn=30)
# Forecast 14 days ahead
fc <- predict(fit, horizon=14)
Key functions
| Function | Description |
|---|---|
npf_seir() | Run the nested particle filter |
seir_simulate() | Simulate a stochastic SEIR trajectory |
cori_rt() | Cori-style renewal R_t estimator (illustrative) |
ou_params() | Exact OU discrete-time transition parameters |
Citation
Feng, W. and Wang, W. (2025). Bayesian sequential inference for a stochastic SEIR model with latent transmission dynamics. Preprint.
Crisan, D. and Miguez, J. (2018). Nested particle filters for online parameter estimation in discrete-time state-space Markov models. Bernoulli, 24(4B):3039–3086.