The blockpfGaussianOpt
function provides a simple example for
RcppSMC. It is based on a block sampling particle filter for a linear
Gaussian model. This is intended only to illustrate the potential of block
sampling; one would not ordinarily use a particle filter for a model in
which analytic solutions are available. The 'optimal' block sampler in the
sense of Doucet, Briers and Senecal (2006) can be implemented in this case.
The simGaussian
function simulates data from the associated linear
Gaussian state space model.
blockpfGaussianOpt(data, particles=1000, lag=5, plot=FALSE)
simGaussian(len)
The blockpfGaussianOpt
function returns a matrix containing the final
sample paths and a vector containing their weights. The logarithm of the
estimated ratio of normalising constants between the final and initial
distributions is also returned.
The simGaussian
function returns a list containing the state and data
sequences.
A vector variable containing the sequence of observations.
An integer specifying the number of particles.
An integer specifying the length of block to use.
A boolean variable describing whether plot should illustrate the estimated path along with the uncertainty.
The length of the data sequence to simulate.
Adam M. Johansen and Dirk Eddelbuettel
The blockpfGaussianOpt
function provides a simple example for
RcppSMC. It is based on a simple linear Gaussian state space model in
which the state evolution and observation equations are:
x(n) = x(n-1) + e(n) and
y(n) = x(n) + f(n)
where e(n) and f(n) are mutually-independent standard normal random
variables. The 'optimal' block-sampling proposal described by Doucet
et al (2006) is employed.
The simGaussian
function simulates from the same model returning both
the state and observation vectors.
A. Doucet, M. Briers, and S. Senecal. Efficient Block Sampling Strategies for sequential Monte Carlo methods. Journal of Computational and Graphical Statistics, 15(3):693-711, 2006.
sim <- simGaussian(len=250)
res <- blockpfGaussianOpt(sim$data,lag=5,plot=TRUE)
Run the code above in your browser using DataLab