Description Usage Arguments Value Note Author(s) References Examples
View source: R/parameterEstimation.R
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).
1 2 | particleMetropolisHastings(y, initialPhi, sigmav, sigmae, noParticles,
initialState, noIterations, stepSize)
|
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 φ. |
The trace of the Markov chain exploring the marginal posterior for φ.
See Section 4 in the reference for more details.
Johan Dahlin uni@johandahlin.com
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.
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")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.