Probabilistic inference, Monte Carlo, and posterior computation · Probabilistic computation and inference foundations · INF016 · Algorithm
Particle Markov chain Monte Carlo (PMCMC)
Uses particle methods inside a correctly constructed MCMC transition to infer static parameters and latent trajectories in state-space models. Particle marginal MH and particle Gibbs are related members;
In CodeSplash
A CodeSplash method covers part of this entry; some options or variants aren't built yet.
- Particle filter (state-space model with PMMH) Verified in Python and R
Do it in CodeSplash Run it on your own data, in Python or R.
- Availability
- Partly runs in CodeSplash
- Code example
- Component demo, not a trained model
- Who ran it
- CodeSplash's run and the reference's record
- CodeSplash's run
- Verified in Python and R through ts.particle_filter. The reference's example ran in Python and R here, and they agree.
- The reference's record
- Python: Ran in the reference's review. The report doesn't record which version of the code ran. R: Reviewed but not run: R wasn't available to the reference's authors.
Purpose
Uses particle methods inside a correctly constructed MCMC transition to infer static parameters and latent trajectories in state-space models. Particle marginal MH and particle Gibbs are related members; this entry illustrates the former rather than counting each as a separate model.
Question / hypotheses
Can a random particle-filter likelihood estimate be used inside an MCMC acceptance ratio without changing the desired parameter posterior?
Architecture / computational structure
Propose new parameters, run a particle filter to produce a new likelihood estimate and associated state, then apply the extended-target MH decision. On rejection retain both the old parameters and old estimate. Particle Gibbs instead relies on conditional SMC and a retained trajectory; it is not the same acceptance formula.
Assumptions
Particle marginal MH requires a nonnegative unbiased estimate of the likelihood, a properly constructed extended-state chain, and valid proposal/support conditions. Unbiasedness of the log likelihood is not the requirement. The current likelihood estimate and its random state are retained after rejection.
Formula / computational definition
Parameters and notation
Theta contains static model parameters, u represents particle-filter randomness, and latent paths may be retained. Hyperparameters include particle count, parameter-proposal covariance, chain/warmup lengths, and filter settings. Noise in the likelihood estimator controls mixing and must be balanced against particle cost.
Fitting, fine-tuning, and adaptation
Tune parameter proposals and particle budgets during a pilot/warmup protocol, then use a valid sampling scheme. A changed observation model or dataset defines a new posterior. If the model contains neural transition weights, their dimension and expensive filter likelihood may make a full parameter chain impractical.
How to use and calibrate
Measure repeated likelihood estimates at representative parameters and inspect chain stickiness, effective samples per second, and multiple-chain diagnostics. Compare to exact Kalman likelihoods on a linear-Gaussian special case to validate the particle likelihood and MH construction.
Example application
Infer unknown process-noise or nonlinear dynamical parameters jointly with latent sensor states when likelihood evaluation requires integrating over an entire hidden trajectory.
Interpretation / pitfalls
Watch out
Recomputing the current likelihood independently on every comparison produces a different noisy-MH scheme that is generally not exact PMMH. A severely noisy estimator can make the chain sticky even though the invariant-target construction is correct. Finite particles do not imply finite-run convergence.
Python and R code examples
Scope: A particle marginal MH acceptance decision using supplied likelihood estimates and a symmetric proposal; no filter, latent-path update, or complete PMCMC chain.
Implementation route: Python/base R perform the scalar decision natively. R pomp implements pmcmc for specified state-space models. A Python implementation must couple a valid particle likelihood estimator to the extended-state transition; simply inserting arbitrary stochastic losses is not sufficient.
Dependencies and validation: Python — executed successfully on the supplied synthetic inputs; imports identify NumPy/SciPy dependencies. R — base R, reviewed but not executed because Rscript is unavailable. Random-number streams differ between languages; matching seed integers do not imply matching draws.
Python and R
The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.
Component demo, not a trained model — A particle marginal MH acceptance decision using supplied likelihood estimates and a symmetric proposal; no filter, latent-path update, or complete PMCMC chain.
import math
theta=.5; logZ=-10.; proposed=.7; proposed_logZ=-10.4
logratio=proposed_logZ-logZ-.5*proposed**2+.5*theta**2 # N(0,1) prior; symmetric proposal
accepted=math.log(.7)<min(0.,logratio)
if accepted: theta,logZ=proposed,proposed_logZ
assert not accepted and logZ==-10.
print('acceptance probability',math.exp(min(0.,logratio)),'retained state',theta,logZ)
Component demo, not a trained model — A particle marginal MH acceptance decision using supplied likelihood estimates and a symmetric proposal; no filter, latent-path update, or complete PMCMC chain.
theta <- .5; logZ <- -10; proposed <- .7; proposed.logZ <- -10.4
logratio <- proposed.logZ-logZ-.5*proposed^2+.5*theta^2
accepted <- log(.7)<min(0,logratio)
if(accepted) {theta <- proposed; logZ <- proposed.logZ}
stopifnot(!accepted,logZ==-10)
print(c(acceptance.prob=exp(min(0,logratio)),theta=theta,retained.logZ=logZ))
Sources
- Primary/official source 1stats.ox.ac.uk
- Primary/official source 2kingaa.github.io
From the CodeSplash reference, entry INF016.