Learn R Programming

pmhtutorial (version 1.5)

example2_lgss: Parameter estimation in a linear Gaussian state space model

Description

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.

Usage

example2_lgss(noBurnInIterations = 1000, noIterations = 5000,
  noParticles = 100, initialPhi = 0.5)

Arguments

noBurnInIterations

The number of burn-in iterations in the PMH algorithm. This parameter must be smaller than noIterations.

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.

noParticles

The number of particles to use when estimating the likelihood.

initialPhi

The initial guess of the parameter phi.

Value

Returns the estimate of the posterior mean.

Details

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.

References

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.

Examples

Run this code
# NOT RUN {
    example2_lgss(noBurnInIterations=200, noIterations=1000)
# }

Run the code above in your browser using DataLab