nonLinPMMH: Particle marginal Metropolis-Hastings for a non-linear state...

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/nonLinPMMH.R

Description

The nonLinPMMH function implements particle marginal Metropolis Hastings for the non-linear state space model described in Section 3.1 of Andrieu et al. (2010).

Usage

1
2
nonLinPMMH(data, particles = 5000, iterations = 10000, burnin = 0,
  verbose = FALSE, msg_freq = 100, plot = FALSE)

Arguments

data

A vector of the observed data.

particles

An integer specifying the number of particles in the particle filtering estimates of the likelihood.

iterations

An integer specifying the number of MCMC iterations.

burnin

The number of iterations to remove from the beginning of the MCMC chain (for plotting purposes only).

verbose

Logical; if TRUE convergence diagnostics are printed to the console (each msg_freq iterations) displaying the running means of parameters, the log-prior, the log-likelihood and the MH acceptance rates up to the current iteration; defaults to FALSE in which case only percentage completion of the procedure is printed.

msg_freq

Specifies the printing frequency of percentage completion or, if verbose = TRUE, percentage completion as well as convergence diagnostics.

plot

A boolean variable to determine whether to plot the posterior estimates and MCMC chain.

Details

This example uses particle marginal Metropolis Hastings to estimate the standard deviation of the evolution and observation noise in the following non-linear state space model:

x(n) = 0.5 x(n-1) + 25 x(n-1) / (1+x(n-1)^2) + 8 cos(1.2n)+ e(n) and

y(n) = x(n)^2 / 20 + f(n)

where e(n) and f(n) are mutually-independent normal random variables of variances var_evol and var_obs, respectively, and x(0) ~ N(0,5).

Following Andrieu, Doucet and Holenstein (2010), the priors are var_evol ~ IG(0.01,0.01) and var_obs ~ IG(0.01,0.01) where IG is the inverse gamma distribution.

Data can be simulated from the model using simNonlin.

Value

A data.frame containing the chain of simulated σ_v and σ_w values, as well as the corresponding log likelihood estimates and log prior values.

Author(s)

Adam M. Johansen, Dirk Eddelbuettel and Leah F. South

References

C. Andrieu, A. Doucet, and R. Holenstein. Particle Markov chain Monte Carlo methods. Journal of the Royal Statistical Society: Series B (Statistical Methodology), 72(3):269-342, 2010.

See Also

simNonlin for a function to simulate from the model and pfNonlinBS for a simple bootrap particle filter applied to a similar non-linear state space model.

Examples

1
2
3
4
5
## Not run: 
sim <- simNonlin(len=500,var_init=5,var_evol=10,var_obs=1,cosSeqOffset=0)
res <- nonLinPMMH(sim$data,particles=5000,iterations=50000,burnin=10000,plot=TRUE)

## End(Not run)

RcppSMC documentation built on Dec. 18, 2021, 5:07 p.m.