[Pomp-commits] r1194 - in pkg/pomp: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Jun 8 01:51:08 CEST 2015
Author: kingaa
Date: 2015-06-08 01:51:07 +0200 (Mon, 08 Jun 2015)
New Revision: 1194
Modified:
pkg/pomp/R/mif2.R
pkg/pomp/man/mif2.Rd
Log:
- change behavior when Np is not constant
Modified: pkg/pomp/R/mif2.R
===================================================================
--- pkg/pomp/R/mif2.R 2015-06-07 15:55:58 UTC (rev 1193)
+++ pkg/pomp/R/mif2.R 2015-06-07 23:51:07 UTC (rev 1194)
@@ -54,6 +54,7 @@
verbose <- as.logical(verbose)
filter.mean <- as.logical(filter.mean)
mifiter <- as.integer(mifiter)
+ Np <- c(Np,Np[1L])
Np <- as.integer(Np)
times <- time(object,t0=TRUE)
@@ -308,7 +309,6 @@
stop(sQuote("mif2")," error: ",sQuote("start")," must be a named vector",
call.=FALSE)
-
ntimes <- length(time(object))
if (missing(Np)) {
@@ -325,16 +325,14 @@
stop(sQuote("mif2")," error: ",sQuote("Np"),
" must be a number, a vector of numbers, or a function")
if (length(Np)==1) {
- Np <- rep(Np,times=ntimes+1)
- } else if (length(Np)==ntimes) {
- Np <- c(Np,Np[1L])
+ Np <- rep(Np,times=ntimes)
} else if (length(Np)>ntimes) {
- if (Np[1L] != Np[ntimes+1])
- stop(sQuote("mif2")," error: Np[ntimes+1] != Np[1]")
- if (length(Np)>ntimes+1)
+ if (Np[1L] != Np[ntimes+1] || length(Np) > ntimes+1) {
warning("in ",sQuote("mif2"),": Np[k] ignored for k > ntimes")
+ }
+ Np <- head(Np,ntimes)
}
- if (any(Np<=0))
+ if (any(Np <= 0))
stop("number of particles, ",sQuote("Np"),", must always be positive")
cooling.type <- match.arg(cooling.type)
Modified: pkg/pomp/man/mif2.Rd
===================================================================
--- pkg/pomp/man/mif2.Rd 2015-06-07 15:55:58 UTC (rev 1193)
+++ pkg/pomp/man/mif2.Rd 2015-06-07 23:51:07 UTC (rev 1194)
@@ -30,10 +30,9 @@
\alias{rw.sd}
\description{
An improved iterated filtering algorithm for estimating the parameters of a partially-observed Markov process.
- Running \code{mif2} causes the algorithm to run for a specified number of particle-filter iterations.
- At each iteration, the particle filter is performed on a perturbed version of the model.
- Specifically, parameters to be estimated are subjected to random perturbations at each observation.
- This extra variability effectively smooths the likelihood surface and introduces diversity into the particle population to combat depletion.
+ Running \code{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).
}
@@ -64,7 +63,7 @@
\item{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 \code{Np} either as a vector of positive integers (of length \code{length(time(object,t0=TRUE))}) or as a function taking a positive integer argument.
+ Alternatively, if one wishes the number of particles to vary across timestep, one may specify \code{Np} either as a vector of positive integers (of length \code{length(time(object))}) or as a function taking a positive integer argument.
In the latter case, \code{Np(k)} must be a single positive integer, representing the number of particles to be used at the \code{k}-th timestep:
\code{Np(1)} is the number of particles to use going from \code{timezero(object)} to \code{time(object)[1]},
\code{Np(2)}, from \code{time(object)[1]} to \code{time(object)[2]},
More information about the pomp-commits
mailing list