Learn R Programming

pomp (version 1.10)

Iterated filtering 2: IF2: Maximum likelihood by iterated, perturbed Bayes maps

Description

An improved iterated filtering algorithm for estimating the parameters of a partially-observed Markov process. Running mif2 causes the algorithm to perform a specified number of particle-filter iterations. At each iteration, the particle filter is performed on a perturbed version of the model, in which the parameters to be estimated are subjected to random perturbations at each observation. This extra variability effectively smooths the likelihood surface and combats particle depletion by introducing diversity into particle population. As the iterations progress, the magnitude of the perturbations is diminished according to a user-specified cooling schedule. The algorithm is presented and justified in Ionides et al. (2015).

Usage

"mif2"(object, Nmif = 1, start, Np, rw.sd, transform = FALSE, cooling.type = c("hyperbolic", "geometric"), cooling.fraction.50, tol = 1e-17, max.fail = Inf, verbose = getOption("verbose"), ...) "mif2"(object, Nmif = 1, Np, tol, ...) "mif2"(object, Nmif, start, Np, rw.sd, transform, cooling.type, cooling.fraction.50, tol, ...) "continue"(object, Nmif = 1, ...) "conv.rec"(object, pars, transform = FALSE, ...) "conv.rec"(object, ...) rw.sd(...)

Arguments

object
An object of class pomp.
Nmif
The number of filtering iterations to perform.
start
named numerical vector; the starting guess of the parameters. By default,
start=coef(object).
Np
the number of particles to use in filtering. 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 timestep, one may specify Np either as a vector of positive integers (of length length(time(object))) or as a function taking a positive integer argument. In the latter case, Np(n) must be a single positive integer, representing the number of particles to be used at the n-th timestep: Np(1) is the number of particles to use going from timezero(object) to time(object)[1], Np(2), from time(object)[1] to time(object)[2], and so on. Note that this behavior differs from that of mif!
rw.sd
specification of the magnitude of the random-walk perturbations that will be applied to some or all model parameters. Parameters that are to be estimated should have positive perturbations specified here. The specification is given using the rw.sd function, which creates a list of unevaluated expressions. The latter are evaluated in a context where the model time variable is defined (as time). The expression ivp(s) can be used in this context as shorthand for
ifelse(time==time[1],s,0).
Likewise, ivp(s,lag) is equivalent to
ifelse(time==time[lag],s,0).
See below for some examples. The perturbations that are applied are normally distributed with the specified s.d. If transform = TRUE, then they are applied on the estimation scale.
transform
logical; if TRUE, optimization is performed on the estimation scale, as defined by the user-supplied parameter transformations (see pomp). This can be used, for example, to enforce positivity or interval constraints on model parameters. See the tutorials on the package website for examples.
cooling.type, cooling.fraction.50
specifications for the cooling schedule, i.e., the manner in which the intensity of the parameter perturbations is reduced with successive filtering iterations. cooling.type specifies the nature of the cooling schedule. See below (under “Specifying the perturbations”) for more detail.
tol, max.fail
passed to the particle filter. See the descriptions under pfilter.
verbose
logical; if TRUE, print progress reports.
...
additional arguments that override the defaults.
pars
names of parameters.

Value

Upon successful completion, mif2 returns an object of class mif2d.pomp. This class inherits from the pfilterd.pomp and pomp classes.

Specifying the perturbations: the <code>rw.sd</code> function

This function simply returns a list containing its arguments as unevaluated expressions. These are then evaluated in a context containing the model time variable. This allows for easy specification of the structure of the perturbations that are to be applied. For example,
    rw.sd(a=0.05,
          b=ifelse(0.2,time==time[1],0),
          c=ivp(0.2),
          d=ifelse(time==time[13],0.2,0),
          e=ivp(0.2,lag=13),
          f=ifelse(time<23,0.02,0))< pre="">
  results in perturbations of parameter a with s.d. 0.05 at every time step, while parameters b and c both get perturbations of s.d. 0.2 only before the first observation.
  Parameters d and e, by contrast, get perturbations of s.d. 0.2 only before the thirteenth observation.
  Finally, parameter f gets a random perturbation of size 0.02 before every observation falling before $t=23$. On the $m$-th IF2 iteration, prior to time-point $n$, the $d$-th parameter is given a random increment normally distributed with mean $0$ and standard deviation $c[m,n] sigma[d,n]$, where $c$ is the cooling schedule and $sigma$ is specified using rw.sd, as described above.
  Let $N$ be the length of the time series and $alpha=$cooling.fraction.50.
  Then, when cooling.type="geometric", we have
  $$c_{m,n}=\alpha^{\frac{n-1+(m-1)N}{50N}}.$$
  When cooling.type="hyperbolic", we have
  $$c_{m,n}=\frac{s+1}{s+n+(m-1)N},$$
  where $s$ satisfies
  $$\frac{s+1}{s+50N}=\alpha.$$
  Thus, in either case, the perturbations at the end of 50 IF2 iterations are a fraction $alpha$ smaller than they are at first.

Re-running <code>mif2</code> Iterations

To re-run a sequence of mif2 iterations, one can use the mif2 method on a mif2d.pomp object. By default, the same parameters used for the original mif2 run are re-used (except for tol, max.fail, and verbose, the defaults of which are shown above). If one does specify additional arguments, these will override the defaults.

Continuing <code>mif2</code> Iterations

One can resume a series of mif2 iterations from where one left off using the continue method. A call to mif2 to perform Nmif=m iterations followed by a call to continue to perform Nmif=n iterations will produce precisely the same effect as a single call to mif2 to perform Nmif=m+n iterations. By default, all the algorithmic parameters are the same as used in the original call to mif2. Additional arguments will override these defaults.

Methods

Methods that can be used to manipulate, display, or extract information from a mif2d.pomp object:

References

E. L. Ionides, D. Nguyen, Y. Atchad\'e, S. Stoev, and A. A. King. Inference for dynamic and latent variable models via iterated, perturbed Bayes maps. Proc. Natl. Acad. Sci. U.S.A., 112:719--724, 2015.

See Also

pomp, pfilter, mif, and the IF2 tutorial on the package website.

Examples

Run this code
## Not run: 
# pompExample(ou2)
# 
# guess1 <- guess2 <- coef(ou2)
# guess1[c('x1.0','x2.0','alpha.2','alpha.3')] <- 0.5*guess1[c('x1.0','x2.0','alpha.2','alpha.3')]
# guess2[c('x1.0','x2.0','alpha.2','alpha.3')] <- 1.5*guess1[c('x1.0','x2.0','alpha.2','alpha.3')]
# 
# m1 <- mif2(ou2,Nmif=100,start=guess1,Np=1000,
#            cooling.type="hyperbolic",cooling.fraction.50=0.05,
#            rw.sd=rw.sd(x1.0=ivp(0.5),x2.0=ivp(0.5),
#              alpha.2=0.1,alpha.3=0.1))
# 
# m2 <- mif2(ou2,Nmif=100,start=guess2,Np=1000,
#            cooling.type="hyperbolic",cooling.fraction.50=0.05,
#            rw.sd=rw.sd(x1.0=ivp(0.5),x2.0=ivp(0.5),
#              alpha.2=0.1,alpha.3=0.1))
# 
# plot(c(m1,m2))
# 
# rbind(mle1=c(coef(m1),loglik=logLik(pfilter(m1,Np=1000))),
#       mle2=c(coef(m2),loglik=logLik(pfilter(m1,Np=1000))),
#       truth=c(coef(ou2),loglik=logLik(pfilter(m1,Np=1000))))
# ## End(Not run)

Run the code above in your browser using DataLab