particleMetropolisHastings: Particle Metropolis-Hastings algorithm for a linear Gaussian...

Description Usage Arguments Value Note Author(s) References Examples

View source: R/parameterEstimation.R

Description

Estimates the parameter posterior for phi a linear Gaussian state space model of the form x_{t} = φ x_{t-1} + σ_v v_t and y_t = x_t + σ_e e_t , where v_t and e_t denote independent standard Gaussian random variables, i.e.N(0,1).

Usage

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

Arguments

y

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

initialPhi

The mean of the log-volatility process μ.

sigmav

The standard deviation of the state process σ_v.

sigmae

The standard deviation of the observation process σ_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 φ.

Value

The trace of the Markov chain exploring the marginal posterior for φ.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
  # 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")

pmhtutorial documentation built on May 2, 2019, 3:25 a.m.