nimble (version 0.7.0)

buildLiuWestFilter: Create a Liu and West particle filter algorithm.

Description

Create a Liu and West particle filter algorithm for a given NIMBLE state space model.

Usage

buildLiuWestFilter(model, nodes, params = NULL, control = list())

Arguments

model

A NIMBLE model object, typically representing a state space model or a hidden Markov model

nodes

A character vector specifying the latent model nodes over which the particle filter will stochastically integrate over to estimate the log-likelihood function. All provided nodes must be stochastic, and must come from the same variable in the model.

params

A character vector specifying the top-level parameters to estimate the posterior distribution of. If unspecified, parameter nodes are specified as all stochastic top level nodes which are not in the set of latent nodes specified in nodes.

control

A list specifying different control options for the particle filter. Options are described in the details section below.

Details

Each of the control() list options are described in detail below:

d

A discount factor for the Liu-West filter. Should be close to, but not above, 1.

saveAll

Indicates whether to save state samples for all time points (TRUE), or only for the most recent time point (FALSE)

timeIndex

An integer used to manually specify which dimension of the latent state variable indexes time. Only needs to be set if the number of time points is less than or equal to the size of the latent state at each time point.

initModel

A logical value indicating whether to initialize the model before running the filtering algorithm. Defaults to TRUE.

The Liu and West filter samples from the posterior distribution of both the latent states and top-level parameters for a state space model. Each particle in the Liu and West filter contains values not only for latent states, but also for top level parameters. Latent states are propogated via an auxiliary step, as in the auxiliary particle filter (buildAuxiliaryFilter). Top-level parameters are propagated from one time point to the next through a smoothed kernel density based on previous particle values.

The resulting specialized particle filter algorthm will accept a single integer argument (m, default 10,000), which specifies the number of random \'particles\' to use for sampling from the posterior distributions. The algorithm saves unequally weighted samples from the posterior distribution of the latent states and top-level parameters in mvWSamples, with corresponding logged weights in mvWSamples['wts',]. An equally weighted sample from the posterior can be found in mvEWSamples.

Note that if saveAll=TRUE, the top-level parameter samples given in the mvWSamples output will correspond to the weights from the final time point.

References

Liu, J., and M. West. (2001). Combined parameter and state estimation in simulation-based filtering. Sequential Monte Carlo methods in practice. Springer New York, pages 197-223.

See Also

Other particle filtering methods: buildAuxiliaryFilter, buildBootstrapFilter, buildEnsembleKF

Examples

Run this code
# NOT RUN {
model <- nimbleModel(code = ...)
my_LWF <- buildLiuWestFilter(model, 'x[1:100]', params = 'sigma_x')
Cmodel <- compileNimble(model)
Cmy_LWF <- compileNimble(my_LWF, project = model)
Cmy_LWF$run(100000)
lw_X <- as.matrix(Cmy_LWF$mvEWSamples, 'x')

#  samples from posterior of a top level parameter named sigma_x:
lw_sigma_x <- as.matrix(Cmy_LWF$mvEWSamples, 'sigma_x')
# }

Run the code above in your browser using DataCamp Workspace