Description Usage Arguments Value Methods Author(s) References See Also Examples
A plain vanilla sequential Monte Carlo (particle filter) algorithm. Resampling is performed at each observation.
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 = 1e-17,
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, ...)
|
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. |
An object of class pfilterd.pomp
.
This class inherits from class pomp
and contains the following additional slots:
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
.
numeric vector containing the effective number of particles at each time point.
numeric vector containing the conditional log likelihoods at each time point.
If pfilter
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}].
If pfilter
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.
the state of the random number generator at the time pfilter
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.
the number of particles used, failure tolerance, and number of filtering failures, respectively.
the estimated log-likelihood.
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.
Extracts the estimated log likelihood.
Extracts the estimated conditional log likelihood
ell_t(theta)=Prob[y_t | y_1, …, y_(t-1)],
where y_t are the data, at time t.
Extracts the (time-dependent) estimated effective sample size, computed as
1/(sum(w_it^2)),
where w_it is the normalized weight of particle i at time t.
Extract the mean and variance of the approximate prediction distribution. This prediction distribution is that of
X_t | y_1,…,y_(t-1),
where X_t, y_t are the state vector and data, respectively, at time t.
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.
Aaron A. King kingaa at umich dot edu
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.
pomp
, mif
, pmcmc
, bsmc2
,
and the tutorials on the package website.
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 log-likelihoods
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
|
newly created object(s):
gompertz
[1] 31.14355
[1] 1.01432389 0.62714124 -0.04762387 -0.05533604 -0.12584676 0.99027370
[7] 0.43836601 0.74174084 0.54490495 0.67053672 0.76702632 0.57340890
[13] -0.00544425 0.59827281 0.75910575 0.25226162 0.44735238 0.70886445
[19] 0.76217368 0.08169767 0.63547411 -0.65540303 0.80758985 0.89058518
[25] -0.12079162 -1.35405210 -0.75541593 1.17466440 0.88439589 1.06754198
[31] 0.38372454 0.36192365 -0.98911381 -0.45677896 0.90485885 1.10830389
[37] -0.70433428 0.49569338 0.72509571 0.60788903 0.80037919 0.31676919
[43] 0.68299491 0.67189040 0.80087891 0.82465142 1.02287841 0.81122973
[49] 0.95100076 0.66113085 0.47688624 0.82654682 0.56426760 1.08978876
[55] 0.70355080 0.38796088 0.12312275 -2.00688249 -0.47324653 0.63028494
[61] -0.21591667 0.58082061 0.72439179 0.03780105 -0.71137726 -0.29807890
[67] -0.63839733 0.28277871 0.47525169 0.41268069 0.13905792 0.35444468
[73] 0.46281668 0.73462883 0.64323744 0.02669726 0.27375498 0.44347607
[79] 0.56685349 0.61495808 0.70612239 -0.90581219 0.44403829 -0.67962879
[85] 0.02793086 0.41737872 -2.04459335 -1.51678465 0.64579726 0.32726770
[91] -0.36404230 -0.01766679 0.94943571 -0.26681506 0.85924494 0.87253739
[97] 0.05424478 0.81744664 0.70628009 0.60380903 -0.02365951
[1] 1000.00000 709.80261 332.49338 435.48247 305.90997 761.26907
[7] 575.34183 732.15694 665.38576 739.93168 790.79367 719.09082
[13] 514.13971 692.82647 756.52490 586.95345 686.26653 782.82314
[19] 794.45211 533.63051 786.08215 234.78190 784.18118 792.33994
[25] 432.35562 136.63826 168.23697 801.48683 707.93150 757.03186
[31] 392.39557 366.64581 175.75467 206.76949 675.86768 740.98323
[37] 247.04892 617.76895 639.26320 660.42963 694.52771 555.20128
[43] 742.73891 651.06559 697.22086 665.15845 803.32288 624.28028
[49] 763.90914 542.28456 563.20240 640.06415 494.23735 730.09474
[55] 628.34893 541.98950 488.60406 109.90894 402.97581 807.47172
[61] 369.75659 727.91298 798.34401 532.62239 333.29822 478.89845
[67] 402.42100 749.92448 809.44387 765.18892 660.82988 660.90113
[73] 650.09115 797.99942 770.93955 529.40788 650.42045 731.74249
[79] 791.99651 753.30561 795.96514 276.28799 667.38370 344.70900
[85] 455.44044 674.94676 78.34662 166.28755 767.53118 633.71316
[91] 308.29662 344.99819 754.16802 369.90060 788.38195 782.54992
[97] 484.12709 772.93691 754.06468 607.77902 470.86363
[1] 31.2916
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.