The pomp Package - uni-bayreuth.deftp.uni-bayreuth.de/math/statlib/R/CRAN/doc/packages/pomp.pdfThe...

24
The pomp Package July 24, 2007 Type Package Title Partially-observed Markov processes Version 0.17-3 Date 2007-07-23 Author Aaron A. King, Ed Ionides, Carles Breto Maintainer Aaron A. King <[email protected]> Description Inference methods for partially-observed Markov processes Depends R(>= 2.3.1), stats, methods, graphics License GPL version 2 or later LazyLoad true R topics documented: B-splines .......................................... 2 dmeasure-pomp ....................................... 3 dprocess-pomp ....................................... 4 mif-class ........................................... 5 mif-methods ......................................... 6 mif .............................................. 8 ou2 ............................................. 10 particles-mif ......................................... 11 pfilter ............................................ 12 pomp-class ......................................... 13 pomp-package ........................................ 15 pomp ............................................ 16 rmeasure-pomp ....................................... 18 rprocess-pomp ........................................ 19 simulate-mif ......................................... 20 simulate-pomp ....................................... 21 Index 23 1

Transcript of The pomp Package - uni-bayreuth.deftp.uni-bayreuth.de/math/statlib/R/CRAN/doc/packages/pomp.pdfThe...

Page 1: The pomp Package - uni-bayreuth.deftp.uni-bayreuth.de/math/statlib/R/CRAN/doc/packages/pomp.pdfThe pomp Package July 24, 2007 Type Package Title Partially-observed Markov processes

The pomp PackageJuly 24, 2007

Type Package

Title Partially-observed Markov processes

Version 0.17-3

Date 2007-07-23

Author Aaron A. King, Ed Ionides, Carles Breto

Maintainer Aaron A. King <[email protected]>

Description Inference methods for partially-observed Markov processes

Depends R(>= 2.3.1), stats, methods, graphics

License GPL version 2 or later

LazyLoad true

R topics documented:B-splines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2dmeasure-pomp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3dprocess-pomp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4mif-class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5mif-methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6mif . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8ou2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10particles-mif . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11pfilter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12pomp-class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13pomp-package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15pomp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16rmeasure-pomp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18rprocess-pomp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19simulate-mif . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20simulate-pomp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

Index 23

1

Page 2: The pomp Package - uni-bayreuth.deftp.uni-bayreuth.de/math/statlib/R/CRAN/doc/packages/pomp.pdfThe pomp Package July 24, 2007 Type Package Title Partially-observed Markov processes

2 B-splines

B-splines B-spline bases

Description

These functions generate B-spline basis functions as lookup tables. bspline.basis gives a setof basis functions. periodic.bspline.basis gives a basis of periodic spline functions.

Usage

bspline.basis(x, degree = 3, knots)periodic.bspline.basis(x, nbasis, degree = 3, period = 1)

Arguments

x Vector at which the spline functions are to be evaluated.

degree Degree of requested B-splines.

knots Vector of positions of the knots.

nbasis The number of basis functions to return.

period The period of the requested periodic B-splines.

Details

For periodic.bspline.basis, x must be positive and not greater than period.

Valuebspline.basis

Returns a matrix with length(x) rows and nbasis=length(knots)-degree-1 columns. Each column contains the values one of the nbasisspline functions.

periodic.bspline.basisReturns a matrix with length(x) rows and nbasis columns.

Author(s)

Aaron A. King (kingaa at umich dot edu)

Examples

x <- seq(-0.2,1.2,by=0.01)y <- bspline.basis(x,degree=7,seq(0,1,length=14))matplot(x,y)

x <- seq(0,1,by=0.01)y <- periodic.bspline.basis(x,nbasis=5)matplot(x,y)

Page 3: The pomp Package - uni-bayreuth.deftp.uni-bayreuth.de/math/statlib/R/CRAN/doc/packages/pomp.pdfThe pomp Package July 24, 2007 Type Package Title Partially-observed Markov processes

dmeasure-pomp 3

dmeasure-pomp Evaluate the probability density of observations given underlyingstates in a partially-observed Markov process

Description

The method dmeaure evaluates the probability density of a set of measurements given the state ofthe system.

Usage

dmeasure(object, y, x, times, params, log = FALSE, ...)## S4 method for signature 'pomp':dmeasure(object, y, x, times, params, log = FALSE, ...)

Arguments

object an object of class pomp.y a rank-2 array containing observations. The dimensions of y are nobs x ntimes,

where nobs is the number of observables and ntimes is the length of times.x a rank-3 array containing the states of the unobserved process. The dimensions

of x are nvars x nsims x ntimes, where nvars is the number of state vari-ables, nsims is the number of replicates, and ntimes is the length of times.Note that if nsims != nrow(y) or ntimes != length(times), anerror is generated.

times a numeric vector containing the times at which the observations were made.params a rank-2 array of parameters with columns corresponding to the columns of x.

Note that the x and params must agree in the number of their columns.log if TRUE, probabilities p are given as log(p).... at present, these are ignored.

Value

Returns a matrix of dimensions nsims x ntimes. If d is the returned matrix, d[j,k] is thelikelihood of the observation y[,k] at time times[k] given the state x[,j,k].

Author(s)

Aaron A. King (kingaa at umich dot edu)

References

See Also

pomp-class

Page 4: The pomp Package - uni-bayreuth.deftp.uni-bayreuth.de/math/statlib/R/CRAN/doc/packages/pomp.pdfThe pomp Package July 24, 2007 Type Package Title Partially-observed Markov processes

4 dprocess-pomp

dprocess-pomp Evaluate the probability density of state transitions in a Markov pro-cess

Description

The method dprocess evaluates the probability density of a set of consecutive state transitions.

Usage

dprocess(object, x, times, params, log = FALSE, ...)## S4 method for signature 'pomp':dprocess(object, x, times, params, log = FALSE, ...)

Arguments

object an object of class pomp.

x a rank-3 array containing the states of the unobserved process. The dimensionsof x are nvars x nsims x ntimes, where nvars is the number of state vari-ables, nsims is the number of replicates, and ntimes is the length of times.Note that if nsims != nrow(y) or ntimes-1 != length(times),an error is generated.

times a numeric vector containing the times corresponding to the given states.

params a rank-2 array of parameters with columns corresponding to the columns of x.Note that the x and params must agree in the number of their columns.

log if TRUE, probabilities p are given as log(p).

... at present, these are ignored.

Value

Returns a matrix of dimensions nsims x ntimes-1. If d is the returned matrix, d[j,k] is thelikelihood of the transition from state x[,j,k-1] at time times[k-1] to state x[,j,k] attime times[k].

Author(s)

Aaron A. King (kingaa at umich dot edu)

See Also

pomp-class

Page 5: The pomp Package - uni-bayreuth.deftp.uni-bayreuth.de/math/statlib/R/CRAN/doc/packages/pomp.pdfThe pomp Package July 24, 2007 Type Package Title Partially-observed Markov processes

mif-class 5

mif-class The "mif" class

Description

The MIF algorithm: maximum likelihood via iterated filtering. The mif class holds a fitted model.

Objects from the Class

Objects can be created by calls to the mif method on an pomp object. Such a call uses the MIFalgorithm to fit the model parameters.

Slots

A mif object is derived from a pomp object and therefore has all the slots of such an object. Seepomp-class for details. A full description of slots in a mif object follows.

ivps A character vector containing the names of variables appearing in coef which are to beestimated as initial-value parameters (IVPs).

pars A character vector containing the names of ordinary parameters appearing in coef which areto be estimated.

Nmif Number of MIF iterations that have been completed.

particles A function of prototype particles(Np,center,sd,...) that draws particlesfrom a distribution centered on center and with width proportional to sd.

alg.pars A named list of algorithm parameters. This consists of

Np the number of particles to use in filtering

var.factor the scaling coefficient relating the width of the initial particle distribution to rw.sd

ic.lag the timepoint for fixed-lag smoothing of initial-value parameters (IVPs)

cooling.factor normal-bracket41bracket-normalthe exponential cooling factor, a, where 0 < a <1

coef A named vector containing the parameter estimate.

random.walk.sd A named vector containing the random-walk variance to be used for ordinaryparameters. The width of the initial distribution of particles will be random.walk.sd*CC.

pred.mean Matrix of prediction means. See pfilter.

pred.var Matrix of prediction variances. See pfilter.

filter.mean Matrix of filtering means. See pfilter.

conv.rec The "convergence record": a matrix containing a record of the parameter values, loglikelihoods, and other pertinent information, with one row for each MIF iteration.

eff.sample.size A vector containing the effective number of particles at each time point. Seepfilter.

cond.loglik A vector containing the conditional log likelihoods at each time point. See pfilter.

Page 6: The pomp Package - uni-bayreuth.deftp.uni-bayreuth.de/math/statlib/R/CRAN/doc/packages/pomp.pdfThe pomp Package July 24, 2007 Type Package Title Partially-observed Markov processes

6 mif-methods

loglik A numeric value containing the value of the log likelihood, as evaluated for the random-parameter model.

data Inherited from the pomp class.

times Inherited from the pomp class.

t0 Inherited from the pomp class.

rprocess Inherited from the pomp class.

dprocess Inherited from the pomp class.

rmeasure Inherited from the pomp class.

dmeasure Inherited from the pomp class.

userdata Inherited from the pomp class.

Extends

Class pomp, directly. See pomp-class.

Methods

See mif, mif-methods, particles-mif, pfilter-mif.

Author(s)

Aaron A. King (kingaa at umich dot edu)

References

E. L. Ionides, C. Bretó, & A. A. King, Inference for nonlinear dynamical systems, Proc. Natl. Acad.Sci. U.S.A., 103:18438–18443, 2006.

See Also

mif, mif-methods, pomp, pomp-class

mif-methods Methods of the "mif" class

Description

Methods of the "mif" class.

Page 7: The pomp Package - uni-bayreuth.deftp.uni-bayreuth.de/math/statlib/R/CRAN/doc/packages/pomp.pdfThe pomp Package July 24, 2007 Type Package Title Partially-observed Markov processes

mif-methods 7

Usage

## S4 method for signature 'mif':coef(object, pars, ...)## S4 method for signature 'mif':logLik(object, ...)conv.rec(object, ...)## S4 method for signature 'mif':conv.rec(object, pars, ...)pred.mean(object, ...)## S4 method for signature 'mif':pred.mean(object, pars, ...)pred.var(object, ...)## S4 method for signature 'mif':pred.var(object, pars, ...)filter.mean(object, ...)## S4 method for signature 'mif':filter.mean(object, pars, ...)

Arguments

object The "mif" object.pars Names of parameters.... Further arguments (either ignored or passed to underlying functions).

Methods

coef Returns the value of the coef slot. These represent the best-fit parameters, generated by MIF.coef<- Assigns values to coefficients. coef(object,pars=NULL,...) <- value has

the effect of replacing the coefficients with the specified names with the given values. Bydefault, if value has a names attribute, these names are used, otherwise the names attributeof coef(object) is used.

conv.rec conv.rec(object, pars = NULL) returns the columns of the convergence-record matrix cor-responding to the names in pars. By default, all rows are returned.

logLik Returns the value in the loglik slot.mif Re-runs the MIF iterations. See the documentation under Re-running MIF Iterations below.plot Plots a series of diagnostic plots.pred.mean pred.mean(object, pars = NULL) returns the rows of the prediction-mean matrix cor-

responding to the names in pars. By default, all rows are returned.pred.var pred.mean(object, pars = NULL) returns the rows of the prediction-variance matrix cor-

responding to the names in pars. By default, all rows are returned.filter.mean filter.mean(object, pars = NULL) returns the rows of the filtering-mean matrix corre-

sponding to the names in pars. By default, all rows are returned.predvarplot predvarplot(object, pars = NULL, mean = FALSE, ...) produces

a plot of the scaled prediction variances for each parameter. This can be used to diagnose agood value of the mif parameters CC and T0. If used in this way, one should run mif withNmif=1 first. Additional arguments in ... will be passed to the actual plotting function.

Page 8: The pomp Package - uni-bayreuth.deftp.uni-bayreuth.de/math/statlib/R/CRAN/doc/packages/pomp.pdfThe pomp Package July 24, 2007 Type Package Title Partially-observed Markov processes

8 mif

pred.var pred.var(object, pars = NULL) returns the rows of the prediction-variance matrix corre-sponding to the names in pars. By default, all rows are returned.

print Prints a summary of the "mif" object.

show Displays the "mif" object.

pfilter See pfilter-mif.

simulate See simulate-mif.

Author(s)

Aaron A. King (kingaa at umich dot edu)

References

E. L. Ionides, C. Bretó, & A. A. King, Inference for nonlinear dynamical systems, Proc. Natl. Acad.Sci. U.S.A., 103:18438–18443, 2006.

See Also

mif, pomp, pomp-class, pfilter

mif The MIF algorithm

Description

The MIF algorithm for estimating the parameters of a partially-observed Markov process.

Running the MIF algorithm

The call sequence for mif is

mif(object, Nmif, start, pars, ivps = character(0), particles, rw.sd,alg.pars, weighted = TRUE, tol = 1e-17, warn = TRUE, max.fail = 0)

Description of arguments:

object An object of class pomp.

Nmif The number of MIF iterations to perform.

start The initial guess of the parameters. This must be a named vector.

pars Character vector of names of ordinary parameters to be estimated.

ivps Character vector of names of initial-value parameters to be estimated.

particles Function of prototype particles(Np,center,sd,...) which sets up the initialparticle matrix by drawing a sample of size Np from the initial particle distribution centeredat center and of width sd.

rw.sd The intensity of the random walk.

alg.pars A named list of algorithm parameters. This consists of

Page 9: The pomp Package - uni-bayreuth.deftp.uni-bayreuth.de/math/statlib/R/CRAN/doc/packages/pomp.pdfThe pomp Package July 24, 2007 Type Package Title Partially-observed Markov processes

mif 9

Np the number of particles to use in filtering

var.factor the scaling coefficient relating the width of the initial particle distribution to rw.sd

ic.lag the timepoint for fixed-lag smoothing of initial-value parameters (IVPs)

cooling.factor normal-bracket46bracket-normalthe exponential cooling factor, a, where 0 < a <1

weighted Should a weighted average be used? If weighted=F, the MIF update is not used;rather, an unweighed average of the filtering means is used for the update.

tol Particles with log likelihood below tol are considered to be "lost". A filtering failure occurswhen, at some time point, all particles are lost.

warn Should a warning be generated when a filtering failure occurs?

max.fail Maximum number of filtering failures permitted. If the number of failures exceeds thisnumber, execution will terminate with an error.

Re-running MIF Iterations

To re-run a sequence of MIF iterations, one can use the mif method on a "mif" object. The callsequence is

mif(object, ...)

Any additional arguments that are valid for the mif method of an "pomp" object (see pomp-class) can be given (with the exception of the ‘particles’ function). Arguments not specified willtake the values they have in the slots of object.

Continuing MIF Iterations

One can continue a series of MIF iterations from where one left off. The call sequence is

continue(object, Nmif, ...)

This will perform Nmif additional MIF iterations on the "mif" object object. A call to mif toperform Nmif=m iterations followed by a call to continue to perform Nmif=n iterations willproduce precisely the same effect as a single call to mif to perform Nmif=m+n iterations.

All additional arguments are passed to mif. This feature can be used to change any of the parame-ters (except the particles function).

Details

It is the user’s responsibility to ensure that the particles function satisfies the followingconditions:particles has at least the following arguments: Np, center, sd, and .... Additional ar-guments may be specified. These will be filled with the elements of the userdata slot of theunderlying "pomp" object (see pomp-class).

particles returns a named list consisting of two matrices. The element states must containthe state-variable portion of the particles; params must contain the parameter portion. Each matrixmust have rownames and exactly Np columns. Each column represents a distinct particle. Therownames are used by the algorithms (see mif, pfilter).

The center of the particle distribution returned by particles should be center. The widthof the particle distribution should vary monotonically with sd. In particular, when sd=0, the

Page 10: The pomp Package - uni-bayreuth.deftp.uni-bayreuth.de/math/statlib/R/CRAN/doc/packages/pomp.pdfThe pomp Package July 24, 2007 Type Package Title Partially-observed Markov processes

10 ou2

particles should return matrices with Np identical columns, each corresponding to the param-eters specified in center.

Author(s)

Aaron A. King (kingaa at umich dot edu)

References

E. L. Ionides, C. Bretó, & A. A. King, Inference for nonlinear dynamical systems, Proc. Natl. Acad.Sci. U.S.A., 103:18438–18443, 2006.

See Also

mif-class, mif-methods, pomp, pomp-class, pfilter. See the "random_walk_example"vignette for an example.

ou2 Two-dimensional Ornstein-Uhlenbeck process

Description

ou2 is a pomp object encoding a 2-D Ornstein-Uhlenbeck process.

Usage

data(ou2)

Details

The OU process is fully but noisily observed. The functions rprocess, dprocess, rmeasure,and dmeasure are implemented using compiled C code for computational speed: see the sourcecode for details. The use of this object is demonstrated in the vignette.

See Also

pomp-class and the vignettes.

Examples

data(ou2)slotNames(ou2)x0 <- c(x1.0=50,x2.0=-50)p <- c(

alpha.1=0.9,alpha.2=0,alpha.3=0,alpha.4=0.99,sigma.1=1,sigma.2=0,sigma.3=2,tau=1)

ou2 <- simulate(ou2,nsim=10,seed=20348585,xstart=x0,params=p)[[1]]

Page 11: The pomp Package - uni-bayreuth.deftp.uni-bayreuth.de/math/statlib/R/CRAN/doc/packages/pomp.pdfThe pomp Package July 24, 2007 Type Package Title Partially-observed Markov processes

particles-mif 11

plot(ou2)X <- matrix(x0,2,1000)rownames(X) <- names(x0)pfilter(ou2,xstart=X,params=p)$loglik

particles-mif Generate particles from the user-specified distribution.

Description

Generate particles from the user-specified distribution.

Usage

particles(object, ...)## S4 method for signature 'mif':particles(object, Np = 1, center = coef(object), sd = 0, ...)

Arguments

object the "mif" object

Np the number of particles, i.e., number of draws.

center the central value of the distribution of particles

sd the width of the distribution

... additional arguments. At present, these are ignored.

Details

The particles method is used to set up the initial distribution of particles. It is an interface tothe user-specifed particles slot in the "mif" object.

Value

particles returns a list of two matrices. states contains the state-variable portion of theparticles; params contains the parameter portion. Each has Np columns.

Author(s)

Aaron A. King (kingaa at umich dot edu)

See Also

mif, mif-methods, pomp, pomp-class

Page 12: The pomp Package - uni-bayreuth.deftp.uni-bayreuth.de/math/statlib/R/CRAN/doc/packages/pomp.pdfThe pomp Package July 24, 2007 Type Package Title Partially-observed Markov processes

12 pfilter

pfilter Particle filter.

Description

Run a particle filter.

Usage

pfilter(object, ...)## S4 method for signature 'pomp':pfilter(object, xstart, params, tol = 1e-17,

warn = TRUE, max.fail = 0, pred.mean = FALSE, pred.var = FALSE,filter.mean = FALSE, .rw.sd, ...)

## S4 method for signature 'mif':pfilter(object, Np, coef, tol = 1e-17, warn = TRUE,

max.fail = 0, pred.mean = FALSE, pred.var = FALSE,filter.mean = FALSE, ...)

Arguments

object An object of class pomp or inheriting class pomp.

xstart A nvars x np matrix containing the initial state-values of the np particles.This must have a ‘rownames’ attribute.

params A npars x np matrix containing the parameters corresponding to the initialstate values in xstart. This must have a ‘rownames’ attribute. It is permissibleto supply params as a named numeric vector, i.e., without a dim attribute. Inthis case, all particles will inherit the same parameter values.

Np Number of particles to use. By default, this is the number of particles used inthe mif iterations.

coef Coefficients at which to estimate the log likelihood. By default, coef(object)is used.

tol Particles with log likelihood below tol are considered to be "lost". A filteringfailure occurs when, at some time point, all particles are lost. When all particlesare lost, the conditional log likelihood at that time point is set to be log(tol).

warn Should filtering failures generate warnings?

max.fail The maximum number of filtering failures allowed. If the number of filteringfailures exceeds this number, execution will terminate with an error.

pred.mean If TRUE, the prediction means are calculated for the state variables and param-eters.

pred.var If TRUE, the prediction variances are calculated for the state variables and pa-rameters.

filter.mean If TRUE, the filtering means are calculated for the state variables and parameters.

Page 13: The pomp Package - uni-bayreuth.deftp.uni-bayreuth.de/math/statlib/R/CRAN/doc/packages/pomp.pdfThe pomp Package July 24, 2007 Type Package Title Partially-observed Markov processes

pomp-class 13

.rw.sd For internal use with the MIF algorithm. If TRUE, the specified random walkSD is used.

... Additional arguments unused at present.

Value

A list with the following elements:

pred.mean The nvars+npars x ntimes matrix of prediction means, where ntimesis the length of the time series contained in object. The rows correspond tostates and parameters, in that order.

pred.varianceThe matrix of prediction variances, in the same format as pred.mean.

filter.mean The matrix of filtering means, in the same format as pred.mean.eff.sample.size

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

cond.loglik A vector containing the conditional log likelihoods at each time point.

nfail The number of filtering failures encountered.

loglik The estimated log-likelihood.

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 OnlineNonlinear, Non-Gaussian Bayesian Tracking. IEEE Trans. Sig. Proc. 50:174–188, 2002.

See Also

pomp-class

Examples

## See the vignettes for examples.

pomp-class Partially-observed Markov process

Description

The class pomp encodes a partially-observed Markov process.

Page 14: The pomp Package - uni-bayreuth.deftp.uni-bayreuth.de/math/statlib/R/CRAN/doc/packages/pomp.pdfThe pomp Package July 24, 2007 Type Package Title Partially-observed Markov processes

14 pomp-class

Objects from the Class

Objects should be created by calls of the function pomp. See the documentation for pomp for usageinstructions and important warnings.

Slots

data An array holding the data. This array is of dimensions nobs x ntimes, where nobs is thenumber of observed variables and ntimes is the number of times at which observations weremade.

times The times corresponding to the observations. times must be a strictly increasing numericvector.

t0 The zero-time.

rprocess Function of prototype rprocess(xstart,times,params,...) which simulatesfrom the unobserved process.

dprocess Function of prototype dprocess(x,times,params,log=FALSE,...) whichevaluates the likelihood of a sequence of consecutive state transitions.

rmeasure Function of prototype rmeasure(x,times,params,...) which simulates fromthe observation process.

dmeasure Function of prototype dmeasure(y,x,params,log=FALSE,...) which givesthe likelihood of y given x.

userdata A list containing any objects the user desires. Using this mechanism, the user can storeadditional information necessary for the definition of the model.

Methods

plot Plots the data. Additional arguments are passed to the low-level plotting routine.

print Prints the pomp object in a nice way.

show Displays the pomp object.

data.array data.array(object) returns the array of observations. data.array(object,vars)gives just the observations of variables vars. vars may specify the variables by position orby name.

time Returns the vector of observation times.

coerce A pomp object can be coerced to a data-frame via as(object,"data.frame").

rprocess simulates the process model. See rprocess-pomp.

dprocess evaluates the process model density. See dprocess-pomp.

rmeasure simulates the measurement model. See rmeasure-pomp.

dmeasure evaluates the measurement-model density. See dmeasure-pomp.

simulate simulate can be used to simulate state and/or observation trajectories. See documen-tation under simulate-pomp.

Author(s)

Aaron A. King (kingaa at umich dot edu)

Page 15: The pomp Package - uni-bayreuth.deftp.uni-bayreuth.de/math/statlib/R/CRAN/doc/packages/pomp.pdfThe pomp Package July 24, 2007 Type Package Title Partially-observed Markov processes

pomp-package 15

See Also

pomp, simulate-pomp

pomp-package Partially-observed Markov processes

Description

The ‘pomp’ package provides facilities for inference using partially-observed Markov processes(AKA state-space models or nonlinear stochastic dynamical systems). The user provides functionsspecifying the model’s process and measurement components. The package’s algorithms are builton top of these functions. At the moment, algorithms are provided for particle filtering (AKAsequential Monte Carlo or sequential importance sampling) and the likelihood maximization by it-erated filtering (MIF) method of Ionides, Breto, and King (PNAS, 103:18438-18443, 2006). Futuresupport for a variety of other algorithms is envisioned. A working group of the National Centerfor Ecological Analysis and Synthesis (NCEAS), "Inference for Mechanistic Models", is currentlyimplementing additional methods for this package.

The package is provided under the GPL. Contributions are welcome, as are comments, suggestions,and bug reports.

Classes

The basic class, pomp, is provided to encode a partially-observed Markov process together with amultivariate data set.

The class mif derives from class pomp and encodes the results of fitting the model to the data bythe MIF algorithm.

Vignettes

The vignette ‘random_walk_example’ illustrates the facilities of the package using simple random-walk processes. Run vignette(’random_walk_example’) or look at the HTML docu-mentation to view the vignette.

Author(s)

Aaron A. King (kingaa at umich dot edu)

See Also

pomp-class, pomp, mif-class, mif

Page 16: The pomp Package - uni-bayreuth.deftp.uni-bayreuth.de/math/statlib/R/CRAN/doc/packages/pomp.pdfThe pomp Package July 24, 2007 Type Package Title Partially-observed Markov processes

16 pomp

pomp Partially-observed Markov process object.

Description

Create a new pomp object.

Usage

pomp(data, times, t0, rprocess, dprocess, rmeasure, dmeasure, ...)

Arguments

data An array holding the data. This array is of dimensions nobs x ntimes, wherenobs is the number of observed variables and ntimes is the number of timesat which observations were made.

times The times corresponding to the observations. times must be a strictly increas-ing numeric vector.

t0 The zero-time. This must be prior to the first observation.

rprocess Function of prototype rprocess(xstart,times,params,...) whichsimulates from the unobserved process.

dprocess Function of prototype dprocess(x,times,params,log=FALSE,...)which evaluates the likelihood of a sequence of consecutive state transitions.

rmeasure Function of prototype rmeasure(x,times,params,...) which simu-lates from the observation process.

dmeasure Function of prototype dmeasure(y,x,times,params,log=FALSE,...)which gives the likelihood of y given x.

... Any additional arguments are stored in a slot ‘userdata’ and are passed as ar-guments to each of the functions rprocess, dprocess, rmeasure, anddmeasure whenever they are evaluated. Using this mechanism, the user canstore additional information necessary for the definition of the model.

Details

It is the user’s responsibility to ensure that the rprocess, dprocess, rmeasure, anddmeasure elements satisfy the following conditions:rprocess must have at least the following arguments: xstart, times, params, and ....Additional arguments may be specified. It is guaranteed that these will be filled with the corre-sponding elements the user has included as additional arguments in the construction of the pompobject.

In calls to rprocess, xstart will be a rank-2 array (matrix) with rows corresponding to statevariables and columns corresponding to independent realizations of the process. params willsimilarly be a rank-2 array with rows corresponding to parameters and columns corresponding toindependent realizations. The columns of params are to be matched up with those of xstart; in

Page 17: The pomp Package - uni-bayreuth.deftp.uni-bayreuth.de/math/statlib/R/CRAN/doc/packages/pomp.pdfThe pomp Package July 24, 2007 Type Package Title Partially-observed Markov processes

pomp 17

particular, they will agree in number. Both xstart and params must have rownames, which areavailable for use by the user.

rprocess must return a rank-3 array with rownames. Suppose x is the array returned. Thendim(x)=c(nvars,nreps,ntimes), where nvars is the number of state variables (=nrow(xstart)),nreps is the number of independent realizations simulated (=ncol(xstart)), and ntimes isthe length of the vector times. x[,j,k] is the value of the state process in the j-th realization attime times[k]. In particular, x[,,1] must be identical to xstart. The rownames of x mustcorrespond to those of xstart.

dprocess must have at least the following arguments: x, times, params, log, and ....Additional arguments may be passed. It is guaranteed that these will be filled with the correspondingelements the user has included as additional arguments in the construction of the pomp object.

In calls to dprocess, x will be an nvars x nreps x ntimes array, where these terms have thesame meanings as above. params will be a rank-2 array with rows corresponding to individualparameters and columns corresponding to independent realizations. The columns of params areto be matched up with those of x; in particular, they will agree in number. Both x and paramsmust have rownames, available for use by the user.

dprocessmust return a rank-2 array (matrix). Suppose d is the array returned. Then dim(d)=c(nreps,ntimes-1). d[j,k] is the probability density of the transition from state x[,j,k-1] at time times[k-1] to state x[,j,k] at time times[k]. If log=TRUE, then the log of the p.d.f. is returned. Itcan be assumed that the transitions are consecutive.

rmeasure must have at least the arguments x, times, params, and .... Additional argumentsmay be passed and will be filled with user-specified data as above. x must be a rank-3 array di-mension c(nvars,nreps,ntimes), where these variables have the same meanings as above.times is the corresponding set of times. rmeasuremust return a rank-3 array. If y is the returnedarray, then dim(y)=c(nobs,nreps,ntimes), where nobs is the number of observable vari-ables and nreps, ntimes agree with the corresponding dimensions of x. y[,j,k] must be thevector of observables in the j-th realization at time times[k].

dmeasure must have at least the arguments y, x, times, params, log, and .... y is a rank-2 array of observations (nobs x ntimes); x, a rank-3 array of states; params a rank-2 arraycontaining parameters, and times the corresponding observation times. Additional argumentsmay be passed and will be filled with user-specified data as above. dmeasure must return a rank-2 array of dimension nreps x ntimes. If d is the returned array, then d[j,k] is the p.d.f. ofy[,k] given x[,j,k] at time times[k]. If log=TRUE, then the log of the p.d.f. is returned.

Value

An object of class pomp.

Warning

Some error checking is done, but complete error checking is impossible. If the user-specified func-tions do not conform to the above specifications (see Details), then the results may be invalid.

Author(s)

Aaron A. King (kingaa at umich dot edu)

Page 18: The pomp Package - uni-bayreuth.deftp.uni-bayreuth.de/math/statlib/R/CRAN/doc/packages/pomp.pdfThe pomp Package July 24, 2007 Type Package Title Partially-observed Markov processes

18 rmeasure-pomp

References

See Also

pomp-class

Examples

x <- pomp(data=rbind(y=rnorm(100)),times=1:100,t0=0)print(x)plot(x)time(x)## See the vignettes for more instructive examples.

rmeasure-pomp Simulate the measurement model of a partially-observed Markov pro-cess

Description

The method rmeaure draws from the distribution of measurements given the state of the system.

Usage

rmeasure(object, x, times, params, ...)## S4 method for signature 'pomp':rmeasure(object, x, times, params, ...)

Arguments

object an object of class pomp.

x a rank-3 array containing the states of the unobserved process. The dimensionsof x are nvars x nsims x ntimes, where nvars is the number of statevariables, nsims is the number of simulations, and ntimes is the number ofdistinct times. Note that if ntimes!=length(times), an error is generated.

times a numerical vector containing the times at which the measurements are to bemade.

params a rank-2 array of parameters with the parameters corresponding to the columnsof x.

... at present, these are ignored.

Value

Returns a rank-3 array of dimensions nobs x nsims x ntimes, where nobs is the number ofobserved variables.

Page 19: The pomp Package - uni-bayreuth.deftp.uni-bayreuth.de/math/statlib/R/CRAN/doc/packages/pomp.pdfThe pomp Package July 24, 2007 Type Package Title Partially-observed Markov processes

rprocess-pomp 19

Author(s)

Aaron A. King (kingaa at umich dot edu)

References

See Also

pomp-class

rprocess-pomp Simulate the process model of a partially-observed Markov process

Description

The method rprocess runs simulations of the the process-model portion of partially-observedMarkov process.

Usage

rprocess(object, xstart, times, params, ...)## S4 method for signature 'pomp':rprocess(object, xstart, times, params, ...)

Arguments

object an object of class pomp.

xstart a rank-2 array containing the starting state of the system. Columns of xstartcorrespond to states; rows to state variables. If there is more than one column ofxstart, multiple independent simulations will be performed, one correspond-ing to each column. Note that in this case, params must have the same numberof columns as xstart.

times a numerical vector containing times. The first entry of times is the initial time(corresponding to xstart). Subsequent times are the values of time for whichthe state of the simulated processes are required.

params a rank-2 array of parameters with the parameters corresponding to the columnsof xstart.

... at present, these are ignored.

Author(s)

Aaron A. King (kingaa at umich dot edu)

References

Page 20: The pomp Package - uni-bayreuth.deftp.uni-bayreuth.de/math/statlib/R/CRAN/doc/packages/pomp.pdfThe pomp Package July 24, 2007 Type Package Title Partially-observed Markov processes

20 simulate-mif

See Also

pomp-class

simulate-mif Simulating a fitted "mif" object

Description

simulate can be used to generate simulated data sets and/or to simulate the state process.

Usage

## S4 method for signature 'mif':simulate(object, nsim = 1, seed = NULL, ...)

Arguments

object An object of class pomp.

nsim The number of simulations to perform. Note that the number of replicates willbe nsim times ncol(xstart).

seed The random seed to use.

... further arguments are passed to the simulate method for the pomp object.See simulate-pomp.

Details

When applied to a mif object, the underlying pomp object is simulated using the estimated param-eters. See simulate-pomp for details.

Value

See simulate-pomp.

Author(s)

Aaron A. King (kingaa at umich dot edu)

References

See Also

simulate, simulate-pomp, mif-class

Page 21: The pomp Package - uni-bayreuth.deftp.uni-bayreuth.de/math/statlib/R/CRAN/doc/packages/pomp.pdfThe pomp Package July 24, 2007 Type Package Title Partially-observed Markov processes

simulate-pomp 21

simulate-pomp Running simulations of a partially-observed Markov process

Description

simulate can be used to generate simulated data sets and/or to simulate the state process.

Usage

## S4 method for signature 'pomp':simulate(object, nsim = 1, seed = NULL, xstart, params,

states = FALSE, obs = FALSE, times = c(object@t0,time(object)),...)

Arguments

object An object of class pomp.

nsim The number of simulations to perform. Note that the number of replicates willbe nsim times ncol(xstart).

seed The random seed to use.

xstart The initial conditions.

params The parameters to use in simulating the model.

states Do we want the state trajectories?

obs Do we want data-frames of the simulated observations?

times The times for which observations are required. Note that the first element intimes is the start time. No observation will be returned for this time.

... further arguments that are at present ignored.

Details

Simulation of the state process and of the measurement process are each accomplished by a singlecall to the user-supplied rprocess and rmeasure functions, respectively. This makes it possiblefor the user to write highly optimized code for these potentially expensive computations.

Value

If states=FALSE and obs=FALSE (the default), a list of nsim ‘pomp’ objects is returned. Eachhas a simulated data set.

If states=TRUE and obs=FALSE, simulated state trajectories are returned as a rank-4 arraywith dimensions nvar x ncol(xstart) x nsim x ntimes. Here, nvar is the number ofstate variables and ntimes the length of the argument times. The measurement process is notsimulated in this case.

If states=FALSE and obs=TRUE, simulated observations are returned as a rank-4 array withdimensions nobs x ncol(xstart) x nsim x (ntimes-1). Here, nobs is the number ofobservables.

Page 22: The pomp Package - uni-bayreuth.deftp.uni-bayreuth.de/math/statlib/R/CRAN/doc/packages/pomp.pdfThe pomp Package July 24, 2007 Type Package Title Partially-observed Markov processes

22 simulate-pomp

If both states=TRUE and obs=TRUE, then a named list is returned. It contains the state trajec-tories and simulated observations as above.

Author(s)

Aaron A. King (kingaa at umich dot edu)

References

See Also

pomp-class

Page 23: The pomp Package - uni-bayreuth.deftp.uni-bayreuth.de/math/statlib/R/CRAN/doc/packages/pomp.pdfThe pomp Package July 24, 2007 Type Package Title Partially-observed Markov processes

Index

∗Topic datasetsou2, 10

∗Topic modelsdmeasure-pomp, 2dprocess-pomp, 3mif, 8mif-class, 4mif-methods, 6particles-mif, 10pfilter, 11pomp, 16pomp-class, 13pomp-package, 15rmeasure-pomp, 18rprocess-pomp, 19simulate-mif, 20simulate-pomp, 21

∗Topic smoothB-splines, 1

∗Topic tsdmeasure-pomp, 2dprocess-pomp, 3mif, 8mif-class, 4mif-methods, 6particles-mif, 10pfilter, 11pomp, 16pomp-class, 13pomp-package, 15rmeasure-pomp, 18rprocess-pomp, 19simulate-mif, 20simulate-pomp, 21

B-splines, 1bspline.basis (B-splines), 1

coef,mif-method (mif-methods), 6coef-mif (mif-methods), 6

coef<- (mif-methods), 6coef<-,mif-method (mif-methods), 6coef<-mif (mif-methods), 6coerce,pomp,data.frame-method

(pomp-class), 13continue (mif), 8continue,mif-method (mif), 8continue-mif (mif), 8conv.rec (mif-methods), 6conv.rec,mif-method

(mif-methods), 6conv.rec-mif (mif-methods), 6

data.array (pomp-class), 13data.array,pomp-method

(pomp-class), 13data.array-pomp (pomp-class), 13dmeasure (dmeasure-pomp), 2dmeasure,pomp-method

(dmeasure-pomp), 2dmeasure-pomp, 2, 14dprocess (dprocess-pomp), 3dprocess,pomp-method

(dprocess-pomp), 3dprocess-pomp, 3, 14

filter.mean (mif-methods), 6filter.mean,mif-method

(mif-methods), 6filter.mean-mif (mif-methods), 6

logLik,mif-method (mif-methods), 6logLik-mif (mif-methods), 6

mif, 6, 7, 8, 11, 15mif,mif-method (mif), 8mif,pomp-method (mif), 8mif-class, 9, 15mif-methods, 9mif-class, 4, 20

23

Page 24: The pomp Package - uni-bayreuth.deftp.uni-bayreuth.de/math/statlib/R/CRAN/doc/packages/pomp.pdfThe pomp Package July 24, 2007 Type Package Title Partially-observed Markov processes

24 INDEX

mif-methods, 6, 6, 11mif-mif (mif), 8mif-pomp (mif), 8

ou2, 10

particles (particles-mif), 10particles,mif-method

(particles-mif), 10particles-mif, 6, 10periodic.bspline.basis

(B-splines), 1pfilter, 5, 7, 9, 11pfilter,mif-method (pfilter), 11pfilter,pomp-method (pfilter), 11pfilter-mif, 6, 7pfilter-mif (pfilter), 11pfilter-pomp (pfilter), 11plot,pomp-method (pomp-class), 13plot-pomp (pomp-class), 13pomp, 6, 7, 9, 11, 13–15, 16pomp-class, 3–5, 7, 9, 10, 15, 19, 20pomp-class, 6, 11, 13, 13, 18, 22pomp-package, 15pred.mean (mif-methods), 6pred.mean,mif-method

(mif-methods), 6pred.mean-mif (mif-methods), 6pred.var (mif-methods), 6pred.var,mif-method

(mif-methods), 6pred.var-mif (mif-methods), 6print,pomp-method (pomp-class), 13print-pomp (pomp-class), 13

rmeasure (rmeasure-pomp), 18rmeasure,pomp-method

(rmeasure-pomp), 18rmeasure-pomp, 14, 18rprocess (rprocess-pomp), 19rprocess,pomp-method

(rprocess-pomp), 19rprocess-pomp, 14, 19

show,pomp-method (pomp-class), 13show-pomp (pomp-class), 13simulate, 20simulate,mif-method

(simulate-mif), 20

simulate,pomp-method(simulate-pomp), 21

simulate-mif, 7, 20simulate-pomp, 14, 20, 21

time,pomp-method (pomp-class), 13time-pomp (pomp-class), 13