pfilter2: Particle filter

Description Usage Arguments Value Author(s) References See Also

Description

Run a plain vanilla particle filter. Resampling is performed at each observation.

Usage

1
2
3
4
5
6
7
8
9
## S4 method for signature 'pomp'
pfilter2(object, params, Np, tol = 1e-17,
    max.fail = Inf, pred.mean = FALSE, pred.var = FALSE,
    filter.mean = FALSE, 
    save.states = FALSE,
    save.params = FALSE, lag=0, seed = NULL,
    verbose = getOption("verbose"), ...)
## S4 method for signature 'pfilterd2.pomp'
pfilter2(object, params, Np, tol, ...)

Arguments

object

An object of class pomp or inheriting class pomp.

params

A npars x Np numeric matrix containing the parameters corresponding to the initial state values in xstart. This must have a ‘rownames’ attribute. If it desired that all particles should share the same parameter values, one one may supply params as a named numeric vector.

Np

the number of particles to use. This may be specified as a single positive integer, in which case the same number of particles will be used at each timestep. Alternatively, if one wishes the number of particles to vary across timesteps, one may specify Np either as a vector of positive integers (length(time(object,t0=TRUE))) or as a function taking a positive integer argument. In the latter case, Np(k) must be a single positive integer, representing the number of particles to be used at the k-th timestep: Np(0) is the number of particles to use going from timezero(object) to time(object)[1], Np(1), from timezero(object) to time(object)[1], and so on, while when T=length(time(object,t0=TRUE)), Np(T) is the number of particles to sample at the end of the time-series. When object is of class is2, this is by default the same number of particles used in the is2 iterations.

tol

positive numeric scalar; particles with likelihood less than tol are considered to be “lost”. A filtering failure occurs when, at some time point, all particles are lost. When all particles are lost, the conditional likelihood at that time point is set to tol.

max.fail

integer; the maximum number of filtering failures allowed. If the number of filtering failures exceeds this number, execution will terminate with an error. By default, max.fail is set to infinity, so no error can be triggered.

pred.mean

logical; if TRUE, the prediction means are calculated for the state variables and parameters.

pred.var

logical; if TRUE, the prediction variances are calculated for the state variables and parameters.

filter.mean

logical; if TRUE, the filtering means are calculated for the state variables and parameters.

save.states, save.params

logical. If save.states=TRUE, the state-vector for each particle at each time is saved in the saved.states slot of the returned pfilterd2.pomp object. If save.params=TRUE, the parameter-vector for each particle at each time is saved in the saved.params slot of the returned pfilterd2.pomp object.

lag

positive numeric scalar; use for fixed lag smoothing.

seed

optional; an object specifying if and how the random number generator should be initialized (‘seeded’). If seed is an integer, it is passed to set.seed prior to any simulation and is returned as the “seed” element of the return list. By default, the state of the random number generator is not changed and the value of .Random.seed on the call is stored in the “seed” element of the return list.

verbose

logical; if TRUE, progress information is reported as pfilter2 works.

...

By default, when pfilter2 pfilter is run on a pfilterd2.pomp object, the settings in the original call are re-used. This default behavior can be overridden by changing the settings (see Examples below).

Value

An object of class pfilterd2.pomp. This class inherits from class pomp and contains the following additional slots:

pred.mean, pred.var, filter.mean

matrices of prediction means, variances, and filter means, respectively. In each of these, the rows correspond to states and parameters (if appropriate), in that order, the columns to successive observations in the time series contained in object.

eff.sample.size

numeric vector containing the effective number of particles at each time point.

cond.loglik

numeric vector containing the conditional log likelihoods at each time point.

saved.states

If pfilter2 was called with save.states=TRUE, this is the list of state-vectors at each time point, for each particle. It is a length-ntimes list of nvars-by-Np arrays. In particular, saved.states[[t]][,i] can be considered a sample from f[X_t|y_{1:t}].

saved.params

If pfilter2 was called with save.params=TRUE, this is the list of parameter-vectors at each time point, for each particle. It is a length-ntimes list of npars-by-Np arrays. In particular, saved.params[[t]][,i] is the parameter portion of the i-th particle at time t.

seed

the state of the random number generator at the time pfilter2 was called. If the argument seed was specified, this is a copy; if not, this is the internal state of the random number generator at the time of call.

Np, tol, nfail

the number of particles used, failure tolerance, and number of filtering failures, respectively.

loglik

the estimated log-likelihood.

These can be accessed using the $ operator as if the returned object were a list. In addition, logLik returns the log likelihood. Note that if the argument params is a named vector, then these parameters are included in the params slot of the returned pfilterd2.pomp object. That is coef(pfilter2(obj,params=theta))==theta if theta is a named vector of parameters.

Author(s)

Dao Nguyen nguyenxd at umich dot edu, Edward L. Ionides ionides at umich dot edu

References

M. S. Arulampalam, S. Maskell, N. Gordon, & T. Clapp. A Tutorial on Particle Filters for Online Nonlinear, Non-Gaussian Bayesian Tracking. IEEE Trans. Sig. Proc. 50:174–188, 2002.

See Also

is2


nxdao2000/pis2 documentation built on May 24, 2019, 11:51 a.m.