Minimal working example of parameter estimation in a linear Gaussian state space model using the particle Metropolis-Hastings algorithm with a fully-adapted particle filter providing an unbiased estimator of the likelihood. The code estimates the parameter posterior for one parameter using simulated data.
example2_lgss(noBurnInIterations = 1000, noIterations = 5000,
noParticles = 100, initialPhi = 0.5)
The number of burn-in iterations in the PMH algorithm.
This parameter must be smaller than noIterations
.
The number of iterations in the PMH algorithm. 100 iterations takes about ten seconds on a laptop to execute. 5000 iterations are used in the reference below.
The number of particles to use when estimating the likelihood.
The initial guess of the parameter phi.
Returns the estimate of the posterior mean.
The Particle Metropolis-Hastings (PMH) algorithm makes use of a Gaussian random walk as the proposal for the parameter. The PMH algorithm is run using different step lengths in the proposal. This is done to illustrate the difficulty when tuning the proposal and the impact of a too small/large step length.
Dahlin, J. & Schon, T. B. "Getting Started with Particle Metropolis-Hastings for Inference in Nonlinear Dynamical Models." Journal of Statistical Software, Code Snippets, 88(2): 1--41, 2019.
# NOT RUN {
example2_lgss(noBurnInIterations=200, noIterations=1000)
# }
Run the code above in your browser using DataLab