particleMetropolisHastings {pmhtutorial}R Documentation

Particle Metropolis-Hastings algorithm for a linear Gaussian state space model

Description

Estimates the parameter posterior for phiphi a linear Gaussian state space model of the form xt=ϕxt1+σvvt x_{t} = \phi x_{t-1} + \sigma_v v_t and yt=xt+σeet y_t = x_t + \sigma_e e_t , where vtv_t and ete_t denote independent standard Gaussian random variables, i.e.N(0,1)N(0,1).

Usage

particleMetropolisHastings(y, initialPhi, sigmav, sigmae, noParticles,
  initialState, noIterations, stepSize)

Arguments

y

Observations from the model for t=1,...,Tt=1,...,T.

initialPhi

The mean of the log-volatility process μ\mu.

sigmav

The standard deviation of the state process σv\sigma_v.

sigmae

The standard deviation of the observation process σe\sigma_e.

noParticles

The number of particles to use in the filter.

initialState

The inital state.

noIterations

The number of iterations in the PMH algorithm.

stepSize

The standard deviation of the Gaussian random walk proposal for ϕ\phi.

Value

The trace of the Markov chain exploring the marginal posterior for ϕ\phi.

Note

See Section 4 in the reference for more details.

Author(s)

Johan Dahlin uni@johandahlin.com

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



  # Generates 100 observations from a linear state space model with
  # (phi, sigma_e, sigma_v) = (0.5, 1.0, 0.1) and zero initial state.
  theta <- c(0.5, 1.0, 0.1)
  d <- generateData(theta, noObservations=100, initialState=0.0) 

  # Estimate the marginal posterior for phi
  pmhOutput <- particleMetropolisHastings(d$y,
    initialPhi=0.1, sigmav=1.0, sigmae=0.1, noParticles=50, 
    initialState=0.0, noIterations=1000, stepSize=0.10)

  # Plot the estimate
  nbins <- floor(sqrt(1000))
  par(mfrow=c(1, 1))
  hist(pmhOutput, breaks=nbins, main="", xlab=expression(phi), 
    ylab="marginal posterior", freq=FALSE, col="#7570B3")


[Package pmhtutorial version 1.5 Index]