Particle filter
Description
A plain vanilla sequential Monte Carlo (particle filter) algorithm. Resampling is performed at each observation.
Usage
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20  ## S4 method for signature 'pomp'
pfilter(object, params, Np, tol = 1e17,
max.fail = Inf, pred.mean = FALSE, pred.var = FALSE,
filter.mean = FALSE, save.states = FALSE,
save.params = FALSE, seed = NULL,
verbose = getOption("verbose"), ...)
## S4 method for signature 'pfilterd.pomp'
pfilter(object, params, Np, tol, ...)
## S4 method for signature 'pfilterd.pomp'
logLik(object, ...)
## S4 method for signature 'pfilterd.pomp'
cond.logLik(object, ...)
## S4 method for signature 'pfilterd.pomp'
eff.sample.size(object, ...)
## S4 method for signature 'pfilterd.pomp'
pred.mean(object, pars, ...)
## S4 method for signature 'pfilterd.pomp'
pred.var(object, pars, ...)
## S4 method for signature 'pfilterd.pomp'
filter.mean(object, pars, ...)

Arguments
object 
An object of class 
params 
A 
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 length(time(object,t0=TRUE)) or as a function taking a positive integer argument.
In the latter case, 
tol 
positive numeric scalar; particles with likelihood less than 
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, 
pred.mean 
logical; if 
pred.var 
logical; if 
filter.mean 
logical; if 
save.states, save.params 
logical.
If 
seed 
optional; an object specifying if and how the random number generator should be initialized (‘seeded’).
If 
verbose 
logical; if 
pars 
Names of parameters. 
... 
additional arguments that override the defaults. 
Value
An object of class pfilterd.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
pfilter
was called withsave.states=TRUE
, this is the list of statevectors at each time point, for each particle. It is a lengthntimes
list ofnvars
byNp
arrays. In particular,saved.states[[t]][,i]
can be considered a sample from f[X_ty_{1:t}].  saved.params

If
pfilter
was called withsave.params=TRUE
, this is the list of parametervectors at each time point, for each particle. It is a lengthntimes
list ofnpars
byNp
arrays. In particular,saved.params[[t]][,i]
is the parameter portion of the ith particle at time t.  seed

the state of the random number generator at the time
pfilter
was called. If the argumentseed
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 loglikelihood.
These can be accessed using the $
operator as if the returned object were a list.
Note that if the argument params
is a named vector, then these parameters are included in the params
slot of the returned pfilterd.pomp
object.
Methods
 logLik

Extracts the estimated log likelihood.
 cond.logLik

Extracts the estimated conditional log likelihood
ell_t(theta)=Prob[y_t  y_1, …, y_(t1)],
where y_t are the data, at time t.
 eff.sample.size

Extracts the (timedependent) estimated effective sample size, computed as
1/(sum(w_it^2)),
where w_it is the normalized weight of particle i at time t.
 pred.mean, pred.var

Extract the mean and variance of the approximate prediction distribution. This prediction distribution is that of
X_t  y_1,…,y_(t1),
where X_t, y_t are the state vector and data, respectively, at time t.
 filter.mean

Extract the mean of the filtering distribution, which is that of
X_t  y_1,…,y_t,
where X_t, y_t are the state vector and data, respectively, at time t.
Author(s)
Aaron A. King kingaa at umich dot edu
References
M. S. Arulampalam, S. Maskell, N. Gordon, & T. Clapp. A Tutorial on Particle Filters for Online Nonlinear, NonGaussian Bayesian Tracking. IEEE Trans. Sig. Proc. 50:174–188, 2002.
See Also
pomp
, mif
, pmcmc
, bsmc2
,
and the tutorials on the package website.
Examples
1 2 3 4 5 6 7 8 9 10  pompExample(gompertz)
pf < pfilter(gompertz,Np=1000) ## use 1000 particles
plot(pf)
logLik(pf)
cond.logLik(pf) ## conditional loglikelihoods
eff.sample.size(pf) ## effective sample size
logLik(pfilter(pf)) ## run it again with 1000 particles
## run it again with 2000 particles
pf < pfilter(pf,Np=2000,filter.mean=TRUE)
fm < filter.mean(pf) ## extract the filtering means
