From ced75614f8aa51a843793e1f404e654654f68999 Mon Sep 17 00:00:00 2001 From: "Aaron A. King" Date: Fri, 24 May 2024 16:56:15 -0400 Subject: [PATCH] change userdata interface --- DESCRIPTION | 4 +- R/abc.R | 3 +- R/blowflies.R | 18 +++++---- R/bsmc2.R | 9 +---- R/kalman.R | 3 +- R/mif2.R | 3 +- R/pfilter.R | 11 +----- R/pmcmc.R | 2 +- R/pomp.R | 77 ++++++++++++++++++++++-------------- R/probe.R | 10 +---- R/simulate.R | 12 +++--- R/spect.R | 1 + R/trajectory.R | 7 +--- R/userdata.R | 6 +-- inst/NEWS | 8 ++++ inst/NEWS.Rd | 7 ++++ man/abc.Rd | 7 +--- man/bsmc2.Rd | 7 +--- man/kalman.Rd | 7 +--- man/mif2.Rd | 7 +--- man/nlf.Rd | 7 +--- man/pfilter.Rd | 7 +--- man/pmcmc.Rd | 7 +--- man/pomp.Rd | 37 ++++++++--------- man/probe.Rd | 11 ++---- man/probe_match.Rd | 7 +--- man/simulate.Rd | 16 +++----- man/spect.Rd | 7 +--- man/spect_match.Rd | 7 +--- man/trajectory.Rd | 9 +---- man/userdata.Rd | 6 +-- man/wpfilter.Rd | 7 +--- tests/R_v_C.Rout | 8 ++-- tests/blowflies.R | 9 +---- tests/blowflies.Rout.save | 9 +---- tests/gillespie.R | 2 +- tests/gillespie.Rout.save | 3 +- tests/kalman.R | 2 +- tests/kalman.Rout.save | 73 ++++++++++++++++++++++++++-------- tests/kalman2.R | 2 +- tests/kalman2.Rout.save | 3 +- tests/mif2.Rout.save | 5 ++- tests/pomp.R | 3 ++ tests/pomp.Rout.save | 8 +++- tests/pomp_methods.R | 2 +- tests/pomp_methods.Rout.save | 3 +- tests/spy.Rout | 70 +++++++++++++++++--------------- tests/userdata.R | 15 ++++--- tests/userdata.Rout.save | 18 ++++----- 49 files changed, 277 insertions(+), 295 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 85e4601f0..1277d56cc 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: pomp Type: Package Title: Statistical Inference for Partially Observed Markov Processes -Version: 5.8.3.0 -Date: 2024-05-22 +Version: 5.8.4.0 +Date: 2024-05-24 Authors@R: c(person(given=c("Aaron","A."),family="King",role=c("aut","cre"),email="kingaa@umich.edu",comment=c(ORCID="0000-0001-6159-3207")), person(given=c("Edward","L."),family="Ionides",role="aut",comment=c(ORCID="0000-0002-4190-0174")) , person(given="Carles",family="Bretó",role="aut",comment=c(ORCID="0000-0003-4695-4902")), diff --git a/R/abc.R b/R/abc.R index e2e0a2f55..2b37c6d09 100644 --- a/R/abc.R +++ b/R/abc.R @@ -14,10 +14,9 @@ ##' @family MCMC methods ##' @family Bayesian methods ##' @concept approximate Bayesian computation -##' -##' @inheritParams pomp ##' @inheritParams probe ##' @inheritParams pmcmc +##' @inheritParams pomp ##' @param Nabc the number of ABC iterations to perform. ##' @param scale named numeric vector of scales. ##' @param epsilon ABC tolerance. diff --git a/R/blowflies.R b/R/blowflies.R index e98787087..a8ced1bd4 100644 --- a/R/blowflies.R +++ b/R/blowflies.R @@ -117,9 +117,11 @@ blowflies1 <- function ( ), paramnames=c("P","N0","delta","sigma.P","sigma.d","sigma.y"), statenames=c("N1","R","S","e","eps"), - y.init=with( ## initial data - dat, - approx(x=day,y=y,xout=seq(from=0,to=14,by=1),rule=2)$y + userdata=list( + y.init=with( ## initial data + dat, + approx(x=day,y=y,xout=seq(from=0,to=14,by=1),rule=2)$y + ) ), ## y.init=c(948, 948, 942, 930, 911, 885, 858, 833.7, 801, 748.3, 676, 589.8, 504, 434.9, 397), rinit=function (params, t0, y.init, ...) { @@ -173,11 +175,13 @@ blowflies2 <- function ( partrans=parameter_trans( log=c("P","delta","N0","sigma.P","sigma.d","sigma.y") ), - y.init=with( ## initial data - dat, - approx(x=day,y=y,xout=seq(from=0,to=14,by=2),rule=2)$y + userdata=list( + y.init=with( ## initial data + dat, + approx(x=day,y=y,xout=seq(from=0,to=14,by=2),rule=2)$y + ) + ## y.init=c(948, 942, 911, 858, 801, 676, 504, 397), ), - ## y.init=c(948, 942, 911, 858, 801, 676, 504, 397), paramnames=c("P","N0","delta","sigma.P","sigma.d","sigma.y"), statenames=c("N1","R","S","e","eps"), rinit=function (params, t0, y.init, ...) { diff --git a/R/bsmc2.R b/R/bsmc2.R index cf4372bad..f5b4e30cc 100644 --- a/R/bsmc2.R +++ b/R/bsmc2.R @@ -18,18 +18,14 @@ ##' @family full-information methods ##' @family particle filter methods ##' @family estimation methods -##' ##' @importFrom mvtnorm rmvnorm ##' @importFrom stats median cov -##' -##' @inheritParams pomp ##' @inheritParams pfilter -##' +##' @inheritParams pomp ##' @param smooth Kernel density smoothing parameter. ##' The compensating shrinkage factor will be \code{sqrt(1-smooth^2)}. ##' Thus, \code{smooth=0} means that no noise will be added to parameters. ##' The general recommendation is that the value of \code{smooth} should be chosen close to 0 (e.g., \code{shrink} ~ 0.1). -##' ##' @return ##' An object of class \sQuote{bsmcd_pomp}. ##' The following methods are avaiable: @@ -37,11 +33,8 @@ ##' \item{\code{\link[=plot,bsmcd_pomp-method]{plot}}}{produces diagnostic plots} ##' \item{\code{\link{as.data.frame}}}{puts the prior and posterior samples into a data frame} ##' } -##' ##' @inheritSection pomp Note for Windows users -##' ##' @author Michael Lavine, Matthew Ferrari, Aaron A. King, Edward L. Ionides -##' ##' @references ##' ##' \Liu2001b diff --git a/R/kalman.R b/R/kalman.R index f91ead198..5cd4866b7 100644 --- a/R/kalman.R +++ b/R/kalman.R @@ -14,13 +14,12 @@ ##' @family particle filter methods ##' @family elementary algorithms ##' @inheritSection pomp Note for Windows users -##' +##' @inheritParams pfilter ##' @inheritParams pomp ##' @param Np integer; the number of particles to use, i.e., the size of the ensemble. ##' ##' @return ##' An object of class \sQuote{kalmand_pomp}. -##' ##' @references ##' ##' \Evensen1994 diff --git a/R/mif2.R b/R/mif2.R index b81c9bf6b..985cd8b56 100644 --- a/R/mif2.R +++ b/R/mif2.R @@ -6,7 +6,6 @@ ##' 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). -##' ##' @name mif2 ##' @rdname mif2 ##' @include pfilter.R workhorses.R pomp_class.R safecall.R continue.R @@ -17,8 +16,8 @@ ##' @family estimation methods ##' @family methods based on maximization ##' @importFrom utils head -##' @inheritParams pomp ##' @inheritParams pfilter +##' @inheritParams pomp ##' @param Nmif The number of filtering iterations to perform. ##' @param 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. diff --git a/R/pfilter.R b/R/pfilter.R index 94dddcc6b..4348aea97 100644 --- a/R/pfilter.R +++ b/R/pfilter.R @@ -22,27 +22,21 @@ ##' \code{Np(1)}, from \code{timezero(object)} to \code{time(object)[1]}, ##' and so on, ##' while when \code{T=length(time(object))}, \code{Np(T)} is the number of particles to sample at the end of the time-series. -##' ##' @param pred.mean logical; if \code{TRUE}, the prediction means are calculated for the state variables and parameters. -##' ##' @param pred.var logical; if \code{TRUE}, the prediction variances are calculated for the state variables and parameters. -##' ##' @param filter.mean logical; if \code{TRUE}, the filtering means are calculated for the state variables and parameters. -##' ##' @param filter.traj logical; if \code{TRUE}, a filtered trajectory is returned for the state variables and parameters. ##' See \code{\link{filter_traj}} for more information. -##' ##' @param save.states character; ##' If \code{save.states="unweighted"}, the state-vector for each unweighted particle at each time is saved. ##' If \code{save.states="weighted"}, the state-vector for each weighted particle at each time is saved, along with the corresponding weight. ##' If \code{save.states="no"}, information on the latent states is not saved. ##' \code{"FALSE"} is a synonym for \code{"no"} and \code{"TRUE"} is a synonym for \code{"unweighted"}. ##' To retrieve the saved states, applying \code{\link{saved_states}} to the result of the \code{pfilter} computation. -##' +##' @param ... additional arguments are passed to \code{\link{pomp}}. ##' @return ##' An object of class \sQuote{pfilterd_pomp}, which extends class \sQuote{pomp}. ##' Information can be extracted from this object using the methods documented below. -##' ##' @section Methods: ##' \describe{ ##' \item{\code{\link{logLik}}}{ the estimated log likelihood } @@ -59,15 +53,12 @@ ##' \item{\code{\link{as.data.frame}}}{coerce to a data frame} ##' \item{\code{\link{plot}}}{diagnostic plots} ##' } -##' ##' @references ##' ##' \Arulampalam2002 ##' ##' \Bhadra2016 -##' ##' @example examples/pfilter.R -##' NULL setClass( diff --git a/R/pmcmc.R b/R/pmcmc.R index b61572db9..01de3d18f 100644 --- a/R/pmcmc.R +++ b/R/pmcmc.R @@ -17,8 +17,8 @@ ##' @family Bayesian methods ##' ##' @importFrom stats runif -##' @inheritParams pomp ##' @inheritParams pfilter +##' @inheritParams pomp ##' @param Nmcmc The number of PMCMC iterations to perform. ##' @param proposal optional function that draws from the proposal ##' distribution. Currently, the proposal distribution must be symmetric for diff --git a/R/pomp.R b/R/pomp.R index 9e8b76c30..f79d2a616 100644 --- a/R/pomp.R +++ b/R/pomp.R @@ -5,18 +5,18 @@ ##' One implements the \acronym{POMP} model by specifying some or all of its \emph{basic components}. ##' These comprise: ##' \describe{ -##' \item{rinit,}{which samples from the distribution of the state process at the zero-time;} -##' \item{dinit,}{which evaluates the density of the state process at the zero-time;} -##' \item{rprocess,}{the simulator of the unobserved Markov state process;} -##' \item{dprocess,}{the evaluator of the probability density function for transitions of the unobserved Markov state process;} -##' \item{rmeasure,}{the simulator of the observed process, conditional on the unobserved state;} -##' \item{dmeasure,}{the evaluator of the measurement model probability density function;} -##' \item{emeasure,}{the expectation of the measurements, conditional on the latent state;} -##' \item{vmeasure,}{the covariance matrix of the measurements, conditional on the latent state;} -##' \item{rprior,}{which samples from a prior probability distribution on the parameters;} -##' \item{dprior,}{which evaluates the prior probability density function;} -##' \item{skeleton,}{which computes the deterministic skeleton of the unobserved state process;} -##' \item{partrans,}{which performs parameter transformations.} +##' \item{rinit}{which samples from the distribution of the state process at the zero-time;} +##' \item{dinit}{which evaluates the density of the state process at the zero-time;} +##' \item{rprocess}{the simulator of the unobserved Markov state process;} +##' \item{dprocess}{the evaluator of the probability density function for transitions of the unobserved Markov state process;} +##' \item{rmeasure}{the simulator of the observed process, conditional on the unobserved state;} +##' \item{dmeasure}{the evaluator of the measurement model probability density function;} +##' \item{emeasure}{the expectation of the measurements, conditional on the latent state;} +##' \item{vmeasure}{the covariance matrix of the measurements, conditional on the latent state;} +##' \item{rprior}{which samples from a prior probability distribution on the parameters;} +##' \item{dprior}{which evaluates the prior probability density function;} +##' \item{skeleton}{which computes the deterministic skeleton of the unobserved state process;} +##' \item{partrans}{which performs parameter transformations.} ##' } ##' The basic structure and its rationale are described in the \emph{Journal of Statistical Software} paper, an updated version of which is to be found on the \href{https://kingaa.github.io/pomp/}{package website}. ##' @@ -118,12 +118,11 @@ ##' @param accumvars optional character vector; ##' contains the names of accumulator variables. ##' See \link{accumvars} for a definition and discussion of accumulator variables. -##' @param ... additional arguments supply new or modify existing model characteristics or components. -##' See \code{\link{pomp}} for a full list of recognized arguments. -##' -##' When named arguments not recognized by \code{\link{pomp}} are provided, these are made available to all basic components via the so-called \dfn{userdata} facility. +##' @param userdata optional list; the elements of this list will be available to basic model components. ##' This allows the user to pass information to the basic components outside of the usual routes of covariates (\code{covar}) and model parameters (\code{params}). ##' See \link[=userdata]{userdata} for information on how to use this facility. +##' @param ... additional arguments will be added to the \code{userdata} list, with a warning. +##' In a future release, this warning will become an error. ##' @param verbose logical; if \code{TRUE}, diagnostic messages will be printed to the console. ##' @return ##' The \code{pomp} constructor function returns an object, call it \code{P}, of class \sQuote{pomp}. @@ -159,6 +158,7 @@ pomp <- function (data, times, t0, ..., covar, params, accumvars, obsnames, statenames, paramnames, covarnames, nstatevars, PACKAGE, globals, on_load, + userdata, cdir = getOption("pomp_cdir", NULL), cfile, shlib.args, compile = TRUE, verbose = getOption("verbose", FALSE)) { @@ -180,7 +180,7 @@ pomp <- function (data, times, t0, ..., missing(rprior) && missing(dprior) && missing(partrans) && missing(covar) && missing(params) && missing(accumvars) && missing(nstatevars) && - ...length() == 0 + missing(userdata) && ...length() == 0 ) return(as(data,"pomp")) @@ -197,7 +197,7 @@ pomp <- function (data, times, t0, ..., params=params,covar=covar,accumvars=accumvars, obsnames=obsnames,statenames=statenames,paramnames=paramnames, covarnames=covarnames,nstatevars=nstatevars,PACKAGE=PACKAGE, - globals=globals,on_load=on_load, + globals=globals,on_load=on_load,userdata=userdata, cdir=cdir,cfile=cfile,shlib.args=shlib.args, compile=compile,verbose=verbose ), @@ -284,11 +284,14 @@ setMethod( setMethod( "construct_pomp", signature=signature(data="array", times="numeric"), - definition = function (data, times, ..., + definition = function ( + data, times, + ..., userdata, rinit, dinit, rprocess, dprocess, rmeasure, dmeasure, emeasure, vmeasure, skeleton, rprior, dprior, - partrans, params, covar) { + partrans, params, covar + ) { if (missing(rinit)) rinit <- NULL if (missing(dinit)) dinit <- NULL @@ -318,6 +321,7 @@ setMethod( if (is.list(params)) params <- unlist(params) if (missing(covar)) covar <- covariate_table() + if (missing(userdata)) userdata <- list() pomp_internal( data=data, @@ -336,6 +340,7 @@ setMethod( partrans=partrans, params=params, covar=covar, + userdata=userdata, ... ) @@ -354,11 +359,14 @@ setMethod( setMethod( "construct_pomp", signature=signature(data="pomp", times="NULL"), - definition = function (data, times, t0, timename, ..., + definition = function ( + data, times, t0, timename, + ..., userdata, rinit, dinit, rprocess, dprocess, rmeasure, dmeasure, emeasure, vmeasure, skeleton, rprior, dprior, partrans, params, covar, - accumvars, nstatevars, cfile) { + accumvars, nstatevars, cfile + ) { times <- data@times if (missing(t0)) t0 <- data@t0 @@ -392,6 +400,8 @@ setMethod( if (missing(nstatevars)) nstatevars <- data@nstatevars else nstatevars <- max(nstatevars[1L],data@nstatevars,na.rm=TRUE) + if (missing(userdata)) userdata <- list() + if (missing(cfile)) cfile <- NULL if (!is.null(cfile)) { cfile <- as.character(cfile) @@ -421,6 +431,7 @@ setMethod( covar=covar, accumvars=accumvars, nstatevars=nstatevars, + userdata=userdata, params=params, .solibs=data@solibs, .userdata=data@userdata, @@ -431,15 +442,20 @@ setMethod( } ) -pomp_internal <- function (data, times, t0, timename, ..., +pomp_internal <- function ( + data, times, t0, timename, + ..., rinit, dinit, rprocess, dprocess, rmeasure, dmeasure, emeasure, vmeasure, skeleton, rprior, dprior, partrans, params, covar, accumvars, obsnames, statenames, paramnames, covarnames, nstatevars, PACKAGE, globals, on_load, cdir, cfile, shlib.args, - compile, .userdata, .solibs = list(), - verbose = getOption("verbose", FALSE)) { + compile, + userdata = list(), .userdata = list(), + .solibs = list(), + verbose = getOption("verbose", FALSE) +) { ## check times if (missing(times) || !is.numeric(times) || !all(is.finite(times)) || @@ -459,17 +475,20 @@ pomp_internal <- function (data, times, t0, timename, ..., else timename <- as.character(timename) - if (missing(.userdata)) .userdata <- list() added.userdata <- list(...) - if (length(added.userdata)>0) { - pMess_("The provided ", + if (length(added.userdata)>0L) { + pWarn_("The provided ", ngettext(length(added.userdata),"object","objects")," ", paste(sQuote(names(added.userdata)),collapse=","), ngettext(length(added.userdata)," is"," are"), - " available for use by POMP basic components." + " available for use by POMP basic components.\n", + "This option is deprecated: use ",sQuote("userdata"), + " to specify the list of such objects explicitly.\n", + "In a future release, this warning will become an error." ) .userdata[names(added.userdata)] <- added.userdata } + .userdata[names(userdata)] <- userdata if (!is(rprocess,"rprocPlugin")) { pStop_(sQuote("rprocess"), diff --git a/R/probe.R b/R/probe.R index 8146b6783..b69c67dd7 100644 --- a/R/probe.R +++ b/R/probe.R @@ -23,26 +23,20 @@ ##' @concept synthetic likelihood ##' @family elementary algorithms ##' @family summary statistic-based methods -##' ##' @inheritSection pomp Note for Windows users -##' ##' @include pomp_class.R pomp_fun.R pomp.R ##' @importFrom stats quantile -##' ##' @param probes a single probe or a list of one or more probes. ##' A probe is simply a scalar- or vector-valued function of one argument that can be applied to the data array of a \sQuote{pomp}. ##' A vector-valued probe must always return a vector of the same size. ##' A number of useful probes are provided with the package: ##' see \link[=basic_probes]{basic probes}. ##' @param nsim the number of model simulations to be computed. -##' @param seed optional integer; -##' if non-\code{NULL}, the random number generator will be initialized with this seed for simulations. -##' See \code{\link{simulate}}. +##' @inheritParams pfilter +##' @inheritParams simulate ##' @inheritParams pomp -##' ##' @return ##' \code{probe} returns an object of class \sQuote{probed_pomp}, which contains the data and the model, together with the results of the \code{probe} calculation. -##' ##' @section Methods: ##' The following methods are available. ##' \describe{ diff --git a/R/simulate.R b/R/simulate.R index 4537ede4e..2478f8517 100644 --- a/R/simulate.R +++ b/R/simulate.R @@ -17,14 +17,13 @@ ##' containing the parameters at which the simulations are to be performed. ##' @param nsim The number of simulations to perform. ##' Note that the number of replicates will be \code{nsim} times \code{ncol(params)}. -##' @param seed optional; -##' if set, the pseudorandom number generator (RNG) will be initialized with \code{seed}. the random seed to use. +##' @param seed optional integer; +##' if set, the pseudorandom number generator (RNG) will be initialized with \code{seed}. ##' The RNG will be restored to its original state afterward. ##' @param format the format in which to return the results. ##' -##' \code{format = "pomps"} causes the results to be returned as a single \dQuote{pomp} object, -##' identical to \code{object} except for the latent states and observations, -##' which have been replaced by the simulated values. +##' \code{format = "pomps"} causes the results to be returned as a single \dQuote{pomp} object, if \code{params} is a vector, or a list of \dQuote{pomp} objects, if \code{params} is a matrix with more than one column. +##' Each of these will be identical to \code{object} except in that the latent states and observations will have been replaced by their simulated values. ##' ##' \code{format = "arrays"} causes the results to be returned as a list of two arrays. ##' The \dQuote{states} element will contain the simulated state trajectories in a rank-3 array with dimensions @@ -40,6 +39,7 @@ ##' ##' @param include.data if \code{TRUE}, the original data and covariates (if any) are included (with \code{.id = "data"}). ##' This option is ignored unless \code{format = "data.frame"}. +##' @param ... additional arguments are passed to \code{\link{pomp}}. ##' ##' @return ##' A single \dQuote{pomp} object, @@ -191,7 +191,7 @@ simulate_internal <- function ( params <- as.matrix(params) storage.mode(params) <- "double" - if (ncol(params) == 1) coef(object) <- params[,1L] + if (ncol(params) == 1L) coef(object) <- params[,1L] pompLoad(object,verbose=verbose) on.exit(pompUnload(object,verbose=verbose)) diff --git a/R/spect.R b/R/spect.R index 1607f3d63..50a73a796 100644 --- a/R/spect.R +++ b/R/spect.R @@ -40,6 +40,7 @@ ##' detrending, and subtraction of constant, linear, and quadratic trends from ##' the data. Detrending is applied to each data series and to each model ##' simulation independently. +##' @inheritParams probe ##' @inheritParams pomp ##' ##' @return diff --git a/R/trajectory.R b/R/trajectory.R index bb963441b..3a90970c9 100644 --- a/R/trajectory.R +++ b/R/trajectory.R @@ -12,20 +12,17 @@ ##' @aliases trajectory,missing-method trajectory,ANY-method ##' @family elementary algorithms ##' @family deterministic methods -##' ##' @importFrom deSolve ode diagnostics ##' @importFrom stats setNames -##' ##' @inheritParams simulate ##' @inheritParams pomp -##' ##' @param object optional; ##' if present, it should be a data frame or a \sQuote{pomp} object. ##' @param ode_control optional list; ##' the elements of this list will be passed to \code{\link[deSolve]{ode}} if the skeleton is a vectorfield, and ignored if it is a map. ##' @param format the format in which to return the results. ##' -##' \code{format = "pomps"} causes the trajectories to be returned as a single \sQuote{pomp} object (if a single parameter vector have been furnished to \code{trajectory}) or as a \sQuote{pompList} object (if multiple parameters have been furnished). +##' \code{format = "pomps"} causes the trajectories to be returned as a single \sQuote{pomp} object (if a single parameter vector has been furnished to \code{trajectory}) or as a \sQuote{pompList} object (if a matrix of parameters have been furnished). ##' In each of these, the \code{states} slot will have been replaced by the computed trajectory. ##' Use \code{\link{states}} to view these. ##' @@ -41,10 +38,8 @@ ##' @return ##' The \code{format} option controls the nature of the return value of \code{trajectory}. ##' See above for details. -##' ##' @example examples/trajectory.R ##' @example examples/ricker-bifdiag.R -##' NULL setGeneric( diff --git a/R/userdata.R b/R/userdata.R index 21ee700e9..4a5f3dc3b 100644 --- a/R/userdata.R +++ b/R/userdata.R @@ -32,11 +32,9 @@ ##' We simply provide an additional argument to whichever \pkg{pomp} algorithm we are employing (e.g., \code{\link{simulate}}, \code{\link{pfilter}}, \code{\link{mif2}}, \code{\link{abc}}, etc.). ##' For example: ##' \preformatted{ -##' simulate(..., rmeasure = f, theta = 42, ...) +##' simulate(..., rmeasure = f, userdata = list(theta = 42), ...) ##' } ##' where the \code{\dots} represent the other \code{simulate} arguments we might want to supply. -##' When we do so, a message will be generated, informing us that \code{theta} is available for use by the \acronym{POMP} basic components. -##' This warning helps forestall accidental triggering of this facility due to typographical error. ##' ##' @section When the basic component is specified via a C snippet: ##' A C snippet implementation of the aforementioned measurement model is: @@ -54,7 +52,7 @@ ##' For example, it is wise to wrap floating point scalars and vectors with \code{as.double} and integers with \code{as.integer}. ##' In the present example, our call to simulate might look like ##' \preformatted{ -##' simulate(..., rmeasure = f, theta = as.double(42), ...) +##' simulate(..., rmeasure = f, userdata = list(theta = as.double(42)), ...) ##' } ##' ##' Since the two functions \code{get_userdata_double} and \code{get_userdata_int} return pointers, it is trivial to pass vectors of double-precision and integers. diff --git a/inst/NEWS b/inst/NEWS index 3f8ec609b..1c6b092ad 100644 --- a/inst/NEWS +++ b/inst/NEWS @@ -1,5 +1,13 @@ _N_e_w_s _f_o_r _p_a_c_k_a_g_e '_p_o_m_p' +_C_h_a_n_g_e_s _i_n '_p_o_m_p' _v_e_r_s_i_o_n _5._8._4: + + • To add additional elements for use by the basic model + components (i.e., “userdata”), the ‘userdata’ argument should + now be used. The old behavior will still work, but will + generate a warning. In a future release, this will become an + error. + _C_h_a_n_g_e_s _i_n '_p_o_m_p' _v_e_r_s_i_o_n _5._8._3: • Internally, ‘pomp’ codes no longer include ‘Rinternal.h’. diff --git a/inst/NEWS.Rd b/inst/NEWS.Rd index 979d31f0f..f74466e3c 100644 --- a/inst/NEWS.Rd +++ b/inst/NEWS.Rd @@ -1,5 +1,12 @@ \name{NEWS} \title{News for package `pomp'} +\section{Changes in \pkg{pomp} version 5.8.4}{ + \itemize{ + \item To add additional elements for use by the basic model components (i.e., \dQuote{userdata}), the \code{userdata} argument should now be used. + The old behavior will still work, but will generate a warning. + In a future release, this will become an error. + } +} \section{Changes in \pkg{pomp} version 5.8.3}{ \itemize{ \item Internally, \pkg{pomp} codes no longer include \file{Rinternal.h}. diff --git a/man/abc.Rd b/man/abc.Rd index d9f67b647..52a7aa451 100644 --- a/man/abc.Rd +++ b/man/abc.Rd @@ -95,12 +95,7 @@ For more information, see \link[=rmeasure_spec]{rmeasure specification}.} For more information, see \link[=prior_spec]{prior specification}. Setting \code{dprior=NULL} resets the prior distribution to its default, which is a flat improper prior.} -\item{...}{additional arguments supply new or modify existing model characteristics or components. -See \code{\link{pomp}} for a full list of recognized arguments. - -When named arguments not recognized by \code{\link{pomp}} are provided, these are made available to all basic components via the so-called \dfn{userdata} facility. -This allows the user to pass information to the basic components outside of the usual routes of covariates (\code{covar}) and model parameters (\code{params}). -See \link[=userdata]{userdata} for information on how to use this facility.} +\item{...}{additional arguments are passed to \code{\link{pomp}}.} \item{verbose}{logical; if \code{TRUE}, diagnostic messages will be printed to the console.} } diff --git a/man/bsmc2.Rd b/man/bsmc2.Rd index bb92d3082..4d636f8aa 100644 --- a/man/bsmc2.Rd +++ b/man/bsmc2.Rd @@ -73,12 +73,7 @@ One should supply the \code{partrans} argument via a call to \code{\link{paramet For more information, see \link[=parameter_trans]{parameter_trans}. Setting \code{partrans=NULL} removes the parameter transformations, i.e., sets them to the identity transformation.} -\item{...}{additional arguments supply new or modify existing model characteristics or components. -See \code{\link{pomp}} for a full list of recognized arguments. - -When named arguments not recognized by \code{\link{pomp}} are provided, these are made available to all basic components via the so-called \dfn{userdata} facility. -This allows the user to pass information to the basic components outside of the usual routes of covariates (\code{covar}) and model parameters (\code{params}). -See \link[=userdata]{userdata} for information on how to use this facility.} +\item{...}{additional arguments are passed to \code{\link{pomp}}.} \item{verbose}{logical; if \code{TRUE}, diagnostic messages will be printed to the console.} } diff --git a/man/kalman.Rd b/man/kalman.Rd index f8978f1e0..01c258d45 100644 --- a/man/kalman.Rd +++ b/man/kalman.Rd @@ -75,12 +75,7 @@ This can be specified as a C snippet, an \R function, or the name of a pre-compi Setting \code{vmeasure=NULL} removes the vmeasure component. For more information, see \link[=vmeasure_spec]{vmeasure specification}.} -\item{...}{additional arguments supply new or modify existing model characteristics or components. -See \code{\link{pomp}} for a full list of recognized arguments. - -When named arguments not recognized by \code{\link{pomp}} are provided, these are made available to all basic components via the so-called \dfn{userdata} facility. -This allows the user to pass information to the basic components outside of the usual routes of covariates (\code{covar}) and model parameters (\code{params}). -See \link[=userdata]{userdata} for information on how to use this facility.} +\item{...}{additional arguments are passed to \code{\link{pomp}}.} \item{verbose}{logical; if \code{TRUE}, diagnostic messages will be printed to the console.} } diff --git a/man/mif2.Rd b/man/mif2.Rd index 9ee91405a..eed79b098 100644 --- a/man/mif2.Rd +++ b/man/mif2.Rd @@ -106,12 +106,7 @@ One should supply the \code{partrans} argument via a call to \code{\link{paramet For more information, see \link[=parameter_trans]{parameter_trans}. Setting \code{partrans=NULL} removes the parameter transformations, i.e., sets them to the identity transformation.} -\item{...}{additional arguments supply new or modify existing model characteristics or components. -See \code{\link{pomp}} for a full list of recognized arguments. - -When named arguments not recognized by \code{\link{pomp}} are provided, these are made available to all basic components via the so-called \dfn{userdata} facility. -This allows the user to pass information to the basic components outside of the usual routes of covariates (\code{covar}) and model parameters (\code{params}). -See \link[=userdata]{userdata} for information on how to use this facility.} +\item{...}{additional arguments are passed to \code{\link{pomp}}.} \item{verbose}{logical; if \code{TRUE}, diagnostic messages will be printed to the console.} } diff --git a/man/nlf.Rd b/man/nlf.Rd index d5fdfd5af..16afba6ab 100644 --- a/man/nlf.Rd +++ b/man/nlf.Rd @@ -127,12 +127,7 @@ For more information, see \link[=rprocess_spec]{rprocess specification for the d Setting \code{rmeasure=NULL} removes the measurement model simulator. For more information, see \link[=rmeasure_spec]{rmeasure specification}.} -\item{...}{additional arguments supply new or modify existing model characteristics or components. -See \code{\link{pomp}} for a full list of recognized arguments. - -When named arguments not recognized by \code{\link{pomp}} are provided, these are made available to all basic components via the so-called \dfn{userdata} facility. -This allows the user to pass information to the basic components outside of the usual routes of covariates (\code{covar}) and model parameters (\code{params}). -See \link[=userdata]{userdata} for information on how to use this facility.} +\item{...}{additional arguments are passed to \code{\link{pomp}}.} \item{verbose}{logical; if \code{TRUE}, diagnostic messages will be printed to the console.} } diff --git a/man/pfilter.Rd b/man/pfilter.Rd index 736ae067e..896cafd5c 100644 --- a/man/pfilter.Rd +++ b/man/pfilter.Rd @@ -89,12 +89,7 @@ If \code{save.states="no"}, information on the latent states is not saved. \code{"FALSE"} is a synonym for \code{"no"} and \code{"TRUE"} is a synonym for \code{"unweighted"}. To retrieve the saved states, applying \code{\link{saved_states}} to the result of the \code{pfilter} computation.} -\item{...}{additional arguments supply new or modify existing model characteristics or components. -See \code{\link{pomp}} for a full list of recognized arguments. - -When named arguments not recognized by \code{\link{pomp}} are provided, these are made available to all basic components via the so-called \dfn{userdata} facility. -This allows the user to pass information to the basic components outside of the usual routes of covariates (\code{covar}) and model parameters (\code{params}). -See \link[=userdata]{userdata} for information on how to use this facility.} +\item{...}{additional arguments are passed to \code{\link{pomp}}.} \item{verbose}{logical; if \code{TRUE}, diagnostic messages will be printed to the console.} } diff --git a/man/pmcmc.Rd b/man/pmcmc.Rd index d07d0024f..378d41dcc 100644 --- a/man/pmcmc.Rd +++ b/man/pmcmc.Rd @@ -87,12 +87,7 @@ For more information, see \link[=dmeasure_spec]{dmeasure specification}.} For more information, see \link[=prior_spec]{prior specification}. Setting \code{dprior=NULL} resets the prior distribution to its default, which is a flat improper prior.} -\item{...}{additional arguments supply new or modify existing model characteristics or components. -See \code{\link{pomp}} for a full list of recognized arguments. - -When named arguments not recognized by \code{\link{pomp}} are provided, these are made available to all basic components via the so-called \dfn{userdata} facility. -This allows the user to pass information to the basic components outside of the usual routes of covariates (\code{covar}) and model parameters (\code{params}). -See \link[=userdata]{userdata} for information on how to use this facility.} +\item{...}{additional arguments are passed to \code{\link{pomp}}.} \item{verbose}{logical; if \code{TRUE}, diagnostic messages will be printed to the console.} } diff --git a/man/pomp.Rd b/man/pomp.Rd index 4ca4beb76..6e78bfe5c 100644 --- a/man/pomp.Rd +++ b/man/pomp.Rd @@ -33,6 +33,7 @@ pomp( PACKAGE, globals, on_load, + userdata, cdir = getOption("pomp_cdir", NULL), cfile, shlib.args, @@ -53,12 +54,8 @@ The time vector must be numeric and non-decreasing.} \item{t0}{The zero-time, i.e., the time of the initial state. This must be no later than the time of the first observation, i.e., \code{t0 <= times[1]}.} -\item{...}{additional arguments supply new or modify existing model characteristics or components. -See \code{\link{pomp}} for a full list of recognized arguments. - -When named arguments not recognized by \code{\link{pomp}} are provided, these are made available to all basic components via the so-called \dfn{userdata} facility. -This allows the user to pass information to the basic components outside of the usual routes of covariates (\code{covar}) and model parameters (\code{params}). -See \link[=userdata]{userdata} for information on how to use this facility.} +\item{...}{additional arguments will be added to the \code{userdata} list, with a warning. +In a future release, this warning will become an error.} \item{rinit}{simulator of the initial-state distribution. This can be furnished either as a C snippet, an \R function, or the name of a pre-compiled native routine available in a dynamically loaded library. @@ -168,6 +165,10 @@ If no C snippets are used, \code{globals} has no effect.} arbitrary C code that will be executed when the C snippet file is loaded. If no C snippets are used, \code{on_load} has no effect.} +\item{userdata}{optional list; the elements of this list will be available to basic model components. +This allows the user to pass information to the basic components outside of the usual routes of covariates (\code{covar}) and model parameters (\code{params}). +See \link[=userdata]{userdata} for information on how to use this facility.} + \item{cdir}{optional character variable. \code{cdir} specifies the name of the directory within which C snippet code will be compiled. By default, this is in a temporary directory specific to the \R session. @@ -201,18 +202,18 @@ As such, it is central to all the package's functionality. One implements the \acronym{POMP} model by specifying some or all of its \emph{basic components}. These comprise: \describe{ -\item{rinit,}{which samples from the distribution of the state process at the zero-time;} -\item{dinit,}{which evaluates the density of the state process at the zero-time;} -\item{rprocess,}{the simulator of the unobserved Markov state process;} -\item{dprocess,}{the evaluator of the probability density function for transitions of the unobserved Markov state process;} -\item{rmeasure,}{the simulator of the observed process, conditional on the unobserved state;} -\item{dmeasure,}{the evaluator of the measurement model probability density function;} -\item{emeasure,}{the expectation of the measurements, conditional on the latent state;} -\item{vmeasure,}{the covariance matrix of the measurements, conditional on the latent state;} -\item{rprior,}{which samples from a prior probability distribution on the parameters;} -\item{dprior,}{which evaluates the prior probability density function;} -\item{skeleton,}{which computes the deterministic skeleton of the unobserved state process;} -\item{partrans,}{which performs parameter transformations.} +\item{rinit}{which samples from the distribution of the state process at the zero-time;} +\item{dinit}{which evaluates the density of the state process at the zero-time;} +\item{rprocess}{the simulator of the unobserved Markov state process;} +\item{dprocess}{the evaluator of the probability density function for transitions of the unobserved Markov state process;} +\item{rmeasure}{the simulator of the observed process, conditional on the unobserved state;} +\item{dmeasure}{the evaluator of the measurement model probability density function;} +\item{emeasure}{the expectation of the measurements, conditional on the latent state;} +\item{vmeasure}{the covariance matrix of the measurements, conditional on the latent state;} +\item{rprior}{which samples from a prior probability distribution on the parameters;} +\item{dprior}{which evaluates the prior probability density function;} +\item{skeleton}{which computes the deterministic skeleton of the unobserved state process;} +\item{partrans}{which performs parameter transformations.} } The basic structure and its rationale are described in the \emph{Journal of Statistical Software} paper, an updated version of which is to be found on the \href{https://kingaa.github.io/pomp/}{package website}. } diff --git a/man/probe.Rd b/man/probe.Rd index ba3ad60c0..018a40133 100644 --- a/man/probe.Rd +++ b/man/probe.Rd @@ -62,8 +62,8 @@ see \link[=basic_probes]{basic probes}.} \item{nsim}{the number of model simulations to be computed.} \item{seed}{optional integer; -if non-\code{NULL}, the random number generator will be initialized with this seed for simulations. -See \code{\link{simulate}}.} +if set, the pseudorandom number generator (RNG) will be initialized with \code{seed}. +The RNG will be restored to its original state afterward.} \item{params}{optional; named numeric vector of parameters. This will be coerced internally to storage mode \code{double}.} @@ -81,12 +81,7 @@ For more information, see \link[=rprocess_spec]{rprocess specification for the d Setting \code{rmeasure=NULL} removes the measurement model simulator. For more information, see \link[=rmeasure_spec]{rmeasure specification}.} -\item{...}{additional arguments supply new or modify existing model characteristics or components. -See \code{\link{pomp}} for a full list of recognized arguments. - -When named arguments not recognized by \code{\link{pomp}} are provided, these are made available to all basic components via the so-called \dfn{userdata} facility. -This allows the user to pass information to the basic components outside of the usual routes of covariates (\code{covar}) and model parameters (\code{params}). -See \link[=userdata]{userdata} for information on how to use this facility.} +\item{...}{additional arguments are passed to \code{\link{pomp}}.} \item{verbose}{logical; if \code{TRUE}, diagnostic messages will be printed to the console.} } diff --git a/man/probe_match.Rd b/man/probe_match.Rd index 104c4d71d..a650b41b2 100644 --- a/man/probe_match.Rd +++ b/man/probe_match.Rd @@ -108,12 +108,7 @@ One should supply the \code{partrans} argument via a call to \code{\link{paramet For more information, see \link[=parameter_trans]{parameter_trans}. Setting \code{partrans=NULL} removes the parameter transformations, i.e., sets them to the identity transformation.} -\item{...}{additional arguments supply new or modify existing model characteristics or components. -See \code{\link{pomp}} for a full list of recognized arguments. - -When named arguments not recognized by \code{\link{pomp}} are provided, these are made available to all basic components via the so-called \dfn{userdata} facility. -This allows the user to pass information to the basic components outside of the usual routes of covariates (\code{covar}) and model parameters (\code{params}). -See \link[=userdata]{userdata} for information on how to use this facility.} +\item{...}{additional arguments are passed to \code{\link{pomp}}.} \item{verbose}{logical; if \code{TRUE}, diagnostic messages will be printed to the console.} } diff --git a/man/simulate.Rd b/man/simulate.Rd index f2941687f..af42bea07 100644 --- a/man/simulate.Rd +++ b/man/simulate.Rd @@ -56,8 +56,8 @@ \item{nsim}{The number of simulations to perform. Note that the number of replicates will be \code{nsim} times \code{ncol(params)}.} -\item{seed}{optional; -if set, the pseudorandom number generator (RNG) will be initialized with \code{seed}. the random seed to use. +\item{seed}{optional integer; +if set, the pseudorandom number generator (RNG) will be initialized with \code{seed}. The RNG will be restored to its original state afterward.} \item{times}{the sequence of observation times. @@ -85,9 +85,8 @@ For more information, see \link[=rmeasure_spec]{rmeasure specification}.} \item{format}{the format in which to return the results. -\code{format = "pomps"} causes the results to be returned as a single \dQuote{pomp} object, -identical to \code{object} except for the latent states and observations, -which have been replaced by the simulated values. +\code{format = "pomps"} causes the results to be returned as a single \dQuote{pomp} object, if \code{params} is a vector, or a list of \dQuote{pomp} objects, if \code{params} is a matrix with more than one column. +Each of these will be identical to \code{object} except in that the latent states and observations will have been replaced by their simulated values. \code{format = "arrays"} causes the results to be returned as a list of two arrays. The \dQuote{states} element will contain the simulated state trajectories in a rank-3 array with dimensions @@ -104,12 +103,7 @@ An ordered factor variable, \sQuote{.id}, distinguishes one simulation from anot \item{include.data}{if \code{TRUE}, the original data and covariates (if any) are included (with \code{.id = "data"}). This option is ignored unless \code{format = "data.frame"}.} -\item{...}{additional arguments supply new or modify existing model characteristics or components. -See \code{\link{pomp}} for a full list of recognized arguments. - -When named arguments not recognized by \code{\link{pomp}} are provided, these are made available to all basic components via the so-called \dfn{userdata} facility. -This allows the user to pass information to the basic components outside of the usual routes of covariates (\code{covar}) and model parameters (\code{params}). -See \link[=userdata]{userdata} for information on how to use this facility.} +\item{...}{additional arguments are passed to \code{\link{pomp}}.} \item{verbose}{logical; if \code{TRUE}, diagnostic messages will be printed to the console.} diff --git a/man/spect.Rd b/man/spect.Rd index 8ca0a0c59..4f71e3ebe 100644 --- a/man/spect.Rd +++ b/man/spect.Rd @@ -99,12 +99,7 @@ For more information, see \link[=rprocess_spec]{rprocess specification for the d Setting \code{rmeasure=NULL} removes the measurement model simulator. For more information, see \link[=rmeasure_spec]{rmeasure specification}.} -\item{...}{additional arguments supply new or modify existing model characteristics or components. -See \code{\link{pomp}} for a full list of recognized arguments. - -When named arguments not recognized by \code{\link{pomp}} are provided, these are made available to all basic components via the so-called \dfn{userdata} facility. -This allows the user to pass information to the basic components outside of the usual routes of covariates (\code{covar}) and model parameters (\code{params}). -See \link[=userdata]{userdata} for information on how to use this facility.} +\item{...}{additional arguments are passed to \code{\link{pomp}}.} \item{verbose}{logical; if \code{TRUE}, diagnostic messages will be printed to the console.} } diff --git a/man/spect_match.Rd b/man/spect_match.Rd index 1e9b07b0f..a5be29ed6 100644 --- a/man/spect_match.Rd +++ b/man/spect_match.Rd @@ -136,12 +136,7 @@ One should supply the \code{partrans} argument via a call to \code{\link{paramet For more information, see \link[=parameter_trans]{parameter_trans}. Setting \code{partrans=NULL} removes the parameter transformations, i.e., sets them to the identity transformation.} -\item{...}{additional arguments supply new or modify existing model characteristics or components. -See \code{\link{pomp}} for a full list of recognized arguments. - -When named arguments not recognized by \code{\link{pomp}} are provided, these are made available to all basic components via the so-called \dfn{userdata} facility. -This allows the user to pass information to the basic components outside of the usual routes of covariates (\code{covar}) and model parameters (\code{params}). -See \link[=userdata]{userdata} for information on how to use this facility.} +\item{...}{additional arguments are passed to \code{\link{pomp}}.} \item{verbose}{logical; if \code{TRUE}, diagnostic messages will be printed to the console.} } diff --git a/man/trajectory.Rd b/man/trajectory.Rd index 2a017424e..378960b0f 100644 --- a/man/trajectory.Rd +++ b/man/trajectory.Rd @@ -69,19 +69,14 @@ This can be furnished either as a C snippet, an \R function, or the name of a pr Setting \code{rinit=NULL} sets the initial-state simulator to its default. For more information, see \link[=rinit_spec]{rinit specification}.} -\item{...}{additional arguments supply new or modify existing model characteristics or components. -See \code{\link{pomp}} for a full list of recognized arguments. - -When named arguments not recognized by \code{\link{pomp}} are provided, these are made available to all basic components via the so-called \dfn{userdata} facility. -This allows the user to pass information to the basic components outside of the usual routes of covariates (\code{covar}) and model parameters (\code{params}). -See \link[=userdata]{userdata} for information on how to use this facility.} +\item{...}{additional arguments are passed to \code{\link{pomp}}.} \item{ode_control}{optional list; the elements of this list will be passed to \code{\link[deSolve]{ode}} if the skeleton is a vectorfield, and ignored if it is a map.} \item{format}{the format in which to return the results. -\code{format = "pomps"} causes the trajectories to be returned as a single \sQuote{pomp} object (if a single parameter vector have been furnished to \code{trajectory}) or as a \sQuote{pompList} object (if multiple parameters have been furnished). +\code{format = "pomps"} causes the trajectories to be returned as a single \sQuote{pomp} object (if a single parameter vector has been furnished to \code{trajectory}) or as a \sQuote{pompList} object (if a matrix of parameters have been furnished). In each of these, the \code{states} slot will have been replaced by the computed trajectory. Use \code{\link{states}} to view these. diff --git a/man/userdata.Rd b/man/userdata.Rd index 58555fd74..7738eb521 100644 --- a/man/userdata.Rd +++ b/man/userdata.Rd @@ -38,11 +38,9 @@ So far, so good, but how do we get \code{theta} to this function? We simply provide an additional argument to whichever \pkg{pomp} algorithm we are employing (e.g., \code{\link{simulate}}, \code{\link{pfilter}}, \code{\link{mif2}}, \code{\link{abc}}, etc.). For example: \preformatted{ - simulate(..., rmeasure = f, theta = 42, ...) + simulate(..., rmeasure = f, userdata = list(theta = 42), ...) } where the \code{\dots} represent the other \code{simulate} arguments we might want to supply. -When we do so, a message will be generated, informing us that \code{theta} is available for use by the \acronym{POMP} basic components. -This warning helps forestall accidental triggering of this facility due to typographical error. } \section{When the basic component is specified via a C snippet}{ @@ -62,7 +60,7 @@ One must take care that one stores the user data with the appropriate storage ty For example, it is wise to wrap floating point scalars and vectors with \code{as.double} and integers with \code{as.integer}. In the present example, our call to simulate might look like \preformatted{ - simulate(..., rmeasure = f, theta = as.double(42), ...) + simulate(..., rmeasure = f, userdata = list(theta = as.double(42)), ...) } Since the two functions \code{get_userdata_double} and \code{get_userdata_int} return pointers, it is trivial to pass vectors of double-precision and integers. diff --git a/man/wpfilter.Rd b/man/wpfilter.Rd index 701cc2250..b5856dfc1 100644 --- a/man/wpfilter.Rd +++ b/man/wpfilter.Rd @@ -68,12 +68,7 @@ For more information, see \link[=dmeasure_spec]{dmeasure specification}.} \item{target}{numeric; target power.} -\item{...}{additional arguments supply new or modify existing model characteristics or components. -See \code{\link{pomp}} for a full list of recognized arguments. - -When named arguments not recognized by \code{\link{pomp}} are provided, these are made available to all basic components via the so-called \dfn{userdata} facility. -This allows the user to pass information to the basic components outside of the usual routes of covariates (\code{covar}) and model parameters (\code{params}). -See \link[=userdata]{userdata} for information on how to use this facility.} +\item{...}{additional arguments are passed to \code{\link{pomp}}.} \item{verbose}{logical; if \code{TRUE}, diagnostic messages will be printed to the console.} } diff --git a/tests/R_v_C.Rout b/tests/R_v_C.Rout index b7f3f7f60..016739f0a 100644 --- a/tests/R_v_C.Rout +++ b/tests/R_v_C.Rout @@ -109,16 +109,16 @@ Type 'q()' to quit R. > ## ----comparison---------------------------------------------------------- > system.time(simulate(gompertz,nsim=10000,format="arrays")) user system elapsed - 5.299 0.032 5.331 + 5.506 0.115 5.621 > system.time(simulate(Gompertz,nsim=10000,format="arrays")) user system elapsed - 0.141 0.017 0.159 + 0.167 0.004 0.171 > system.time(pfilter(gompertz,Np=1000)) user system elapsed - 0.541 0.000 0.540 + 0.583 0.000 0.582 > system.time(pfilter(Gompertz,Np=1000)) user system elapsed - 0.028 0.000 0.028 + 0.029 0.000 0.029 > > dev.off() null device diff --git a/tests/blowflies.R b/tests/blowflies.R index 25a1618d0..cf188bbdc 100644 --- a/tests/blowflies.R +++ b/tests/blowflies.R @@ -3,14 +3,7 @@ set.seed(599688L) library(pomp) -capture.output( - list(blowflies1(),blowflies2()) -> flies, - type="message" -) -> out -stopifnot( - sum(grepl("provided object",out))==2, - sum(grepl("y.init",out))==2 -) +list(blowflies1(),blowflies2()) -> flies plot(flies[[1]]) rinit(flies[[1]]) diff --git a/tests/blowflies.Rout.save b/tests/blowflies.Rout.save index 59a52598e..25b3e5a3c 100644 --- a/tests/blowflies.Rout.save +++ b/tests/blowflies.Rout.save @@ -22,14 +22,7 @@ Type 'q()' to quit R. > > library(pomp) > -> capture.output( -+ list(blowflies1(),blowflies2()) -> flies, -+ type="message" -+ ) -> out -> stopifnot( -+ sum(grepl("provided object",out))==2, -+ sum(grepl("y.init",out))==2 -+ ) +> list(blowflies1(),blowflies2()) -> flies > > plot(flies[[1]]) > rinit(flies[[1]]) diff --git a/tests/gillespie.R b/tests/gillespie.R index 1dc4f477d..83cb889e9 100644 --- a/tests/gillespie.R +++ b/tests/gillespie.R @@ -109,7 +109,7 @@ gsir |> v=Vmatrix, hmax=1/52/10 ), - nbasis=3L, + userdata=list(nbasis=3L), seed=806867104L, paramnames=c("gamma","mu","iota","beta1","beta2","beta3","pop","rho"), statenames=c("S","I","R","N","cases") diff --git a/tests/gillespie.Rout.save b/tests/gillespie.Rout.save index 27e9f2b42..8790140d9 100644 --- a/tests/gillespie.Rout.save +++ b/tests/gillespie.Rout.save @@ -128,12 +128,11 @@ Type 'q()' to quit R. + v=Vmatrix, + hmax=1/52/10 + ), -+ nbasis=3L, ++ userdata=list(nbasis=3L), + seed=806867104L, + paramnames=c("gamma","mu","iota","beta1","beta2","beta3","pop","rho"), + statenames=c("S","I","R","N","cases") + ) -> gsir1 -NOTE: The provided object 'nbasis' is available for use by POMP basic components. > > gsir1 |> + plot(main="Gillespie SIR, with zeroing") diff --git a/tests/kalman.R b/tests/kalman.R index f3df8b289..bc2440a2a 100644 --- a/tests/kalman.R +++ b/tests/kalman.R @@ -56,7 +56,7 @@ y |> as.data.frame() |> pfilter( times=t,t0=0, - A=A,C=C,R=R,sqrtQ=sqrtQ,sqrtR=sqrtR,X0=X0, + userdata=list(A=A,C=C,R=R,sqrtQ=sqrtQ,sqrtR=sqrtR,X0=X0), rprocess=discrete_time( step.fun=function(x1,x2,x3,x4,delta.t,...){ x <- c(x1,x2,x3,x4) diff --git a/tests/kalman.Rout.save b/tests/kalman.Rout.save index 0cac8e7d7..81d1ba4fb 100644 --- a/tests/kalman.Rout.save +++ b/tests/kalman.Rout.save @@ -75,7 +75,7 @@ Type 'q()' to quit R. + as.data.frame() |> + pfilter( + times=t,t0=0, -+ A=A,C=C,R=R,sqrtQ=sqrtQ,sqrtR=sqrtR,X0=X0, ++ userdata=list(A=A,C=C,R=R,sqrtQ=sqrtQ,sqrtR=sqrtR,X0=X0), + rprocess=discrete_time( + step.fun=function(x1,x2,x3,x4,delta.t,...){ + x <- c(x1,x2,x3,x4) @@ -107,7 +107,6 @@ Type 'q()' to quit R. + Np=1000, + filter.mean=TRUE + ) -> pf -NOTE: The provided objects 'A','C','R','sqrtQ','sqrtR','X0' are available for use by POMP basic components. > > freeze( + seed=1286628545, @@ -142,23 +141,41 @@ Error : in 'enkf': 'emeasure' is a needed basic component. > try(enkf(enkf,Np=100,vmeasure=NULL)) Error : in 'enkf': 'vmeasure' is a needed basic component. > try(enkf(enkf,C=matrix(1,2,4,dimnames=list(c("y2","y1"),NULL)),Np=100)) -NOTE: The provided object 'C' is available for use by POMP basic components. Error : in 'enkf': rownames of matrix returned by 'vmeasure' do not match those returned by 'emeasure'. +In addition: Warning message: +The provided object 'C' is available for use by POMP basic components. +This option is deprecated: use 'userdata' to specify the list of such objects explicitly. +In a future release, this warning will become an error. > try(enkf(enkf,C=matrix(1,3,4,dimnames=list(c("a","b","c"),NULL)),Np=100)) -NOTE: The provided object 'C' is available for use by POMP basic components. Error : in 'enkf': number of observables returned by 'emeasure' does not match data. +In addition: Warning message: +The provided object 'C' is available for use by POMP basic components. +This option is deprecated: use 'userdata' to specify the list of such objects explicitly. +In a future release, this warning will become an error. > try(enkf(enkf,R=matrix(1,1,1,dimnames=list(c("y1"),NULL)),Np=100)) -NOTE: The provided object 'R' is available for use by POMP basic components. Error : in 'enkf': rownames of matrix returned by 'vmeasure' do not match those returned by 'emeasure'. +In addition: Warning message: +The provided object 'R' is available for use by POMP basic components. +This option is deprecated: use 'userdata' to specify the list of such objects explicitly. +In a future release, this warning will become an error. > try(enkf(enkf,R=matrix(1,2,2,dimnames=list(c("y2","y1"),NULL)),Np=100)) -NOTE: The provided object 'R' is available for use by POMP basic components. Error : in 'enkf': rownames of matrix returned by 'vmeasure' do not match those returned by 'emeasure'. +In addition: Warning message: +The provided object 'R' is available for use by POMP basic components. +This option is deprecated: use 'userdata' to specify the list of such objects explicitly. +In a future release, this warning will become an error. > try(enkf(enkf,R=matrix(1,2,2,dimnames=list(c("a","b"),NULL)),Np=100)) -NOTE: The provided object 'R' is available for use by POMP basic components. Error : in 'enkf': rownames of matrix returned by 'vmeasure' do not match those returned by 'emeasure'. +In addition: Warning message: +The provided object 'R' is available for use by POMP basic components. +This option is deprecated: use 'userdata' to specify the list of such objects explicitly. +In a future release, this warning will become an error. > try(enkf(enkf,R=matrix(1,3,3,dimnames=list(c("a","b","c"),NULL)),Np=100)) -NOTE: The provided object 'R' is available for use by POMP basic components. Error : in 'enkf': rownames of matrix returned by 'vmeasure' do not match those returned by 'emeasure'. +In addition: Warning message: +The provided object 'R' is available for use by POMP basic components. +This option is deprecated: use 'userdata' to specify the list of such objects explicitly. +In a future release, this warning will become an error. > enkf(enkf) > enkf(enkf,Np=100) @@ -178,23 +195,41 @@ Error : in 'eakf': 'emeasure' is a needed basic component. > try(eakf(enkf,Np=100,vmeasure=NULL)) Error : in 'eakf': 'vmeasure' is a needed basic component. > try(eakf(enkf,C=matrix(1,2,4,dimnames=list(c("y2","y1"),NULL)),Np=100)) -NOTE: The provided object 'C' is available for use by POMP basic components. Error : in 'eakf': rownames of matrix returned by 'vmeasure' do not match those returned by 'emeasure'. +In addition: Warning message: +The provided object 'C' is available for use by POMP basic components. +This option is deprecated: use 'userdata' to specify the list of such objects explicitly. +In a future release, this warning will become an error. > try(eakf(enkf,C=matrix(1,3,4,dimnames=list(c("a","b","c"),NULL)),Np=100)) -NOTE: The provided object 'C' is available for use by POMP basic components. Error : in 'eakf': number of observables returned by 'emeasure' does not match data. +In addition: Warning message: +The provided object 'C' is available for use by POMP basic components. +This option is deprecated: use 'userdata' to specify the list of such objects explicitly. +In a future release, this warning will become an error. > try(eakf(enkf,R=matrix(1,1,1,dimnames=list(c("y1"),NULL)),Np=100)) -NOTE: The provided object 'R' is available for use by POMP basic components. Error : in 'eakf': rownames of matrix returned by 'vmeasure' do not match those returned by 'emeasure'. +In addition: Warning message: +The provided object 'R' is available for use by POMP basic components. +This option is deprecated: use 'userdata' to specify the list of such objects explicitly. +In a future release, this warning will become an error. > try(eakf(enkf,R=matrix(1,2,2,dimnames=list(c("y2","y1"),NULL)),Np=100)) -NOTE: The provided object 'R' is available for use by POMP basic components. Error : in 'eakf': rownames of matrix returned by 'vmeasure' do not match those returned by 'emeasure'. +In addition: Warning message: +The provided object 'R' is available for use by POMP basic components. +This option is deprecated: use 'userdata' to specify the list of such objects explicitly. +In a future release, this warning will become an error. > try(eakf(enkf,R=matrix(1,2,2,dimnames=list(c("a","b"),NULL)),Np=100)) -NOTE: The provided object 'R' is available for use by POMP basic components. Error : in 'eakf': rownames of matrix returned by 'vmeasure' do not match those returned by 'emeasure'. +In addition: Warning message: +The provided object 'R' is available for use by POMP basic components. +This option is deprecated: use 'userdata' to specify the list of such objects explicitly. +In a future release, this warning will become an error. > try(eakf(enkf,R=matrix(1,3,3,dimnames=list(c("a","b","c"),NULL)),Np=100)) -NOTE: The provided object 'R' is available for use by POMP basic components. Error : in 'eakf': rownames of matrix returned by 'vmeasure' do not match those returned by 'emeasure'. +In addition: Warning message: +The provided object 'R' is available for use by POMP basic components. +This option is deprecated: use 'userdata' to specify the list of such objects explicitly. +In a future release, this warning will become an error. > > invisible(enkf(pf,Np=1000,params=as.list(coef(pf)))) > invisible(eakf(pf,Np=1000,params=as.list(coef(pf)))) @@ -259,14 +294,20 @@ Error : in 'eakf': rownames of matrix returned by 'vmeasure' do not match those + rownames(R) <- rownames(C) + enkf(pf,Np=1000,R=R) + }) -NOTE: The provided object 'R' is available for use by POMP basic components. Error : in 'enkf': degenerate 'vmeasure': the leading minor of order 2 is not positive +In addition: Warning message: +The provided object 'R' is available for use by POMP basic components. +This option is deprecated: use 'userdata' to specify the list of such objects explicitly. +In a future release, this warning will become an error. > > try({ + eakf(pf,Np=1000,R=R) + }) -NOTE: The provided object 'R' is available for use by POMP basic components. Error : in 'eakf': degenerate 'vmeasure': Lapack routine dgesv: system is exactly singular: U[2,2] = 0 +In addition: Warning message: +The provided object 'R' is available for use by POMP basic components. +This option is deprecated: use 'userdata' to specify the list of such objects explicitly. +In a future release, this warning will become an error. > > try(enkf()) Error : in 'enkf': 'data' is a required argument. diff --git a/tests/kalman2.R b/tests/kalman2.R index 178b86d0c..339cb4990 100644 --- a/tests/kalman2.R +++ b/tests/kalman2.R @@ -50,7 +50,7 @@ dat |> ), vmeasure=function(R, ...) R, emeasure=function(x,...) c(Y=0.01*x), - R=matrix(0.01,1,1,dimnames=list("Y","Y")) + userdata=list(R=matrix(0.01,1,1,dimnames=list("Y","Y"))) ) -> kf kf |> plot() diff --git a/tests/kalman2.Rout.save b/tests/kalman2.Rout.save index dc2b5c5c3..f95b6f225 100644 --- a/tests/kalman2.Rout.save +++ b/tests/kalman2.Rout.save @@ -71,9 +71,8 @@ Error : in 'eakf': 'times' should either be a numeric vector of observation time + ), + vmeasure=function(R, ...) R, + emeasure=function(x,...) c(Y=0.01*x), -+ R=matrix(0.01,1,1,dimnames=list("Y","Y")) ++ userdata=list(R=matrix(0.01,1,1,dimnames=list("Y","Y"))) + ) -> kf -NOTE: The provided object 'R' is available for use by POMP basic components. > > kf |> plot() > diff --git a/tests/mif2.Rout.save b/tests/mif2.Rout.save index eb90ef618..504c76f30 100644 --- a/tests/mif2.Rout.save +++ b/tests/mif2.Rout.save @@ -183,7 +183,10 @@ loglik: NA + cooling.type="hyper",cooling.fraction.50=0.1, + drpocess="oops", + dmeasure=function(log,...)0) -> mf3 -NOTE: The provided object 'drpocess' is available for use by POMP basic components. +Warning message: +The provided object 'drpocess' is available for use by POMP basic components. +This option is deprecated: use 'userdata' to specify the list of such objects explicitly. +In a future release, this warning will become an error. > try(mif2(po,Nmif=2,Np=50,rw.sd=rw_sd(sigma=0.01),cooling.fraction.50=0.1,dmeasure=NULL)) Error : in 'mif2': 'rprocess', 'dmeasure' are needed basic components. > try(mif2(po,Nmif=2,Np=50,rw.sd=rw_sd(sigma=0.01),cooling.fraction.50=0.1,rprocess=NULL)) diff --git a/tests/pomp.R b/tests/pomp.R index a737d0961..adf2d722e 100644 --- a/tests/pomp.R +++ b/tests/pomp.R @@ -27,6 +27,9 @@ try(data.frame(a=1:10,b=1:10) |> pomp(times="a",t0=NA)) stopifnot(data.frame(a=1:10,b=1:10) |> pomp(covar=covariate_table(c=0:10,d=0:10,times="c"), covarnames="d",times="a",t0=0,bob=3) |> class() == "pomp") +stopifnot(data.frame(a=1:10,b=1:10) |> + pomp(covar=covariate_table(c=0:10,d=0:10,times="c"), + covarnames="d",times="a",t0=0,userdata=list(bob=3)) |> class() == "pomp") try(data.frame(a=1:10,b=1:10) |> pomp(covar=covariate_table(c=1:10,d=1:10,d=1:10,times="c"), times="a",t0=0)) diff --git a/tests/pomp.Rout.save b/tests/pomp.Rout.save index 12958d950..8d1f94c9e 100644 --- a/tests/pomp.Rout.save +++ b/tests/pomp.Rout.save @@ -66,7 +66,13 @@ Error : 't0' must be a single number not greater than 'times[1]'. > stopifnot(data.frame(a=1:10,b=1:10) |> + pomp(covar=covariate_table(c=0:10,d=0:10,times="c"), + covarnames="d",times="a",t0=0,bob=3) |> class() == "pomp") -NOTE: The provided object 'bob' is available for use by POMP basic components. +Warning message: +The provided object 'bob' is available for use by POMP basic components. +This option is deprecated: use 'userdata' to specify the list of such objects explicitly. +In a future release, this warning will become an error. +> stopifnot(data.frame(a=1:10,b=1:10) |> ++ pomp(covar=covariate_table(c=0:10,d=0:10,times="c"), ++ covarnames="d",times="a",t0=0,userdata=list(bob=3)) |> class() == "pomp") > try(data.frame(a=1:10,b=1:10) |> + pomp(covar=covariate_table(c=1:10,d=1:10,d=1:10,times="c"), + times="a",t0=0)) diff --git a/tests/pomp_methods.R b/tests/pomp_methods.R index 7b7497801..c6843aa8c 100644 --- a/tests/pomp_methods.R +++ b/tests/pomp_methods.R @@ -106,7 +106,7 @@ coef(po) po |> window(start=5,end=20) |> pomp(covar=covariate_table(times=0:20,q=0:20), - larry=3L) -> po1 + userdata=list(larry=3L)) -> po1 as(po1,"data.frame") |> head() dim(as.data.frame(c(a=po1,b=po1))) diff --git a/tests/pomp_methods.Rout.save b/tests/pomp_methods.Rout.save index c801f97e5..cd8222b71 100644 --- a/tests/pomp_methods.Rout.save +++ b/tests/pomp_methods.Rout.save @@ -268,8 +268,7 @@ numeric(0) > po |> + window(start=5,end=20) |> + pomp(covar=covariate_table(times=0:20,q=0:20), -+ larry=3L) -> po1 -NOTE: The provided object 'larry' is available for use by POMP basic components. ++ userdata=list(larry=3L)) -> po1 > as(po1,"data.frame") |> head() time Y q 1 5 0.7408867 5 diff --git a/tests/spy.Rout b/tests/spy.Rout index 330cb77b5..063638bb0 100644 --- a/tests/spy.Rout +++ b/tests/spy.Rout @@ -25,9 +25,11 @@ Type 'q()' to quit R. > > pomp(po,partrans=NULL,bob=3, + covar=covariate_table(a=0:20,b=0:20,times="a")) -> po1 -NOTE: The provided object 'bob' is available for use by POMP basic components. -Warning message: -in 'pomp': the supplied covariate times do not embrace the data times: covariates may be extrapolated. +Warning messages: +1: The provided object 'bob' is available for use by POMP basic components. +This option is deprecated: use 'userdata' to specify the list of such objects explicitly. +In a future release, this warning will become an error. +2: in 'pomp': the supplied covariate times do not embrace the data times: covariates may be extrapolated. > spy(po1) ================== pomp object 'po1': @@ -164,8 +166,8 @@ params /* pomp C snippet file: nancy */ -/* Time: 2024-04-30 08:11:15.392 -0400 */ -/* Salt: 9DAA8D5E59418992A0EAF24D */ +/* Time: 2024-05-24 16:07:40.839 -0400 */ +/* Salt: 0126BA7A968070B09ADA7541 */ #include #include @@ -288,8 +290,8 @@ pomp object 'sir': /* pomp C snippet file: sir_source */ -/* Time: 2024-04-30 08:11:15.534 -0400 */ -/* Salt: 1914EAA2FC08263B6B35F012 */ +/* Time: 2024-05-24 16:07:40.957 -0400 */ +/* Salt: AA6C60DA16990DC34AE2FBFE */ #include #include @@ -938,8 +940,8 @@ x1_0 x2_0 s1 s2 tau /* pomp C snippet file: rw2_source */ -/* Time: 2024-04-30 08:11:16.276 -0400 */ -/* Salt: A38A303EEFC617D84B031F01 */ +/* Time: 2024-05-24 16:07:41.744 -0400 */ +/* Salt: D2DA73368E7C6F3403335BF6 */ #include #include @@ -1205,8 +1207,8 @@ name birth susc.death infection inf.death recovery recov.death /* pomp C snippet file: sir2_source */ -/* Time: 2024-04-30 08:11:16.942 -0400 */ -/* Salt: A84F6E43E37D60B24FCF12A3 */ +/* Time: 2024-05-24 16:07:42.368 -0400 */ +/* Salt: 93BDD69202DE9561A7463207 */ #include #include @@ -1846,7 +1848,6 @@ Error : 'spy' is undefined for 'object' of class 'list'. + compile=FALSE + ) |> + spy() -NOTE: The provided object 'x0' is available for use by POMP basic components. ================== pomp object 'pomp(data = NULL, t0 = 0, times = 1:10, x0 = as.double(1), params = c(x_0 = 1, '' a = 22), rinit = Csnippet("x = *get_userdata_double(\"x0\");"), '' statenames = "x", compile = FALSE)': @@ -1855,7 +1856,7 @@ pomp object 'pomp(data = NULL, t0 = 0, times = 1:10, x0 = as.double(1), params = - covariates: - initial state simulator, rinit: native function - name: '__pomp_rinit' - - defined by a C snippet in library 'pomp_7593eefc78309496b4fd8edac45a6d5b' + - defined by a C snippet in library 'pomp_76f078570f92c6b269c1ac523812abd7' - initial state density, dinit: - process-model simulator, rprocess: - process model density, dprocess: @@ -1876,9 +1877,9 @@ x_0 a - C snippet file 1 : -/* pomp C snippet file: pomp_7593eefc78309496b4fd8edac45a6d5b */ -/* Time: 2024-04-30 08:11:17.693 -0400 */ -/* Salt: F4C2DD06FA27C30274EA1C20 */ +/* pomp C snippet file: pomp_76f078570f92c6b269c1ac523812abd7 */ +/* Time: 2024-05-24 16:07:43.110 -0400 */ +/* Salt: 1AB87353DE06A60B91580677 */ #include #include @@ -1904,15 +1905,19 @@ void __pomp_load_stack_incr (void) {++__pomp_load_stack;} void __pomp_load_stack_decr (int *val) {*val = --__pomp_load_stack;} -void R_init_pomp_7593eefc78309496b4fd8edac45a6d5b (DllInfo *info) { +void R_init_pomp_76f078570f92c6b269c1ac523812abd7 (DllInfo *info) { __pomp_get_userdata_double = (get_userdata_double_t *) R_GetCCallable("pomp","get_userdata_double"); - R_RegisterCCallable("pomp_7593eefc78309496b4fd8edac45a6d5b", "__pomp_load_stack_incr", (DL_FUNC) __pomp_load_stack_incr); - R_RegisterCCallable("pomp_7593eefc78309496b4fd8edac45a6d5b", "__pomp_load_stack_decr", (DL_FUNC) __pomp_load_stack_decr); - R_RegisterCCallable("pomp_7593eefc78309496b4fd8edac45a6d5b", "__pomp_rinit", (DL_FUNC) __pomp_rinit); + R_RegisterCCallable("pomp_76f078570f92c6b269c1ac523812abd7", "__pomp_load_stack_incr", (DL_FUNC) __pomp_load_stack_incr); + R_RegisterCCallable("pomp_76f078570f92c6b269c1ac523812abd7", "__pomp_load_stack_decr", (DL_FUNC) __pomp_load_stack_decr); + R_RegisterCCallable("pomp_76f078570f92c6b269c1ac523812abd7", "__pomp_rinit", (DL_FUNC) __pomp_rinit); } +Warning message: +The provided object 'x0' is available for use by POMP basic components. +This option is deprecated: use 'userdata' to specify the list of such objects explicitly. +In a future release, this warning will become an error. > > pomp( + data=NULL, @@ -1927,7 +1932,6 @@ void R_init_pomp_7593eefc78309496b4fd8edac45a6d5b (DllInfo *info) { + compile=FALSE + ) |> + spy() -NOTE: The provided object 'x0' is available for use by POMP basic components. ================== pomp object 'pomp(data = NULL, t0 = 0, times = 1:10, x0 = as.double(1), params = c(x_0 = 1, '' a = 22), globals = Csnippet("static double X0;"), rinit = Csnippet("x = X0;"), '' rprocess = euler(Csnippet("x += rgammawn(0.1,dt);"), delta.t = 0.1), '' on_load = Csnippet("X0 = *get_userdata_double(\"x0\");"), '' statenames = "x", compile = FALSE)': @@ -1936,13 +1940,13 @@ pomp object 'pomp(data = NULL, t0 = 0, times = 1:10, x0 = as.double(1), params = - covariates: - initial state simulator, rinit: native function - name: '__pomp_rinit' - - defined by a C snippet in library 'pomp_15209364fa46c0260cceddeb3a7b755f' + - defined by a C snippet in library 'pomp_472239922ec0d83afeb4fa1f3189779b' - initial state density, dinit: - process-model simulator, rprocess: Euler-method process-model simulator - timestep = 0.1 - step.fun: native function - name: '__pomp_stepfn' - - defined by a C snippet in library 'pomp_15209364fa46c0260cceddeb3a7b755f' + - defined by a C snippet in library 'pomp_472239922ec0d83afeb4fa1f3189779b' - process model density, dprocess: - measurement model simulator, rmeasure: - measurement model density, dmeasure: @@ -1961,9 +1965,9 @@ x_0 a - C snippet file 1 : -/* pomp C snippet file: pomp_15209364fa46c0260cceddeb3a7b755f */ -/* Time: 2024-04-30 08:11:17.757 -0400 */ -/* Salt: 5D262BD7C9FFE34612D44BBD */ +/* pomp C snippet file: pomp_472239922ec0d83afeb4fa1f3189779b */ +/* Time: 2024-05-24 16:07:43.173 -0400 */ +/* Salt: 294E37C4F406AB4253443A6B */ #include #include @@ -2001,14 +2005,18 @@ void __pomp_load_stack_incr (void) {++__pomp_load_stack;} void __pomp_load_stack_decr (int *val) {*val = --__pomp_load_stack;} -void R_init_pomp_15209364fa46c0260cceddeb3a7b755f (DllInfo *info) { +void R_init_pomp_472239922ec0d83afeb4fa1f3189779b (DllInfo *info) { __pomp_get_userdata_double = (get_userdata_double_t *) R_GetCCallable("pomp","get_userdata_double"); - R_RegisterCCallable("pomp_15209364fa46c0260cceddeb3a7b755f", "__pomp_load_stack_incr", (DL_FUNC) __pomp_load_stack_incr); - R_RegisterCCallable("pomp_15209364fa46c0260cceddeb3a7b755f", "__pomp_load_stack_decr", (DL_FUNC) __pomp_load_stack_decr); - R_RegisterCCallable("pomp_15209364fa46c0260cceddeb3a7b755f", "__pomp_rinit", (DL_FUNC) __pomp_rinit); - R_RegisterCCallable("pomp_15209364fa46c0260cceddeb3a7b755f", "__pomp_stepfn", (DL_FUNC) __pomp_stepfn); + R_RegisterCCallable("pomp_472239922ec0d83afeb4fa1f3189779b", "__pomp_load_stack_incr", (DL_FUNC) __pomp_load_stack_incr); + R_RegisterCCallable("pomp_472239922ec0d83afeb4fa1f3189779b", "__pomp_load_stack_decr", (DL_FUNC) __pomp_load_stack_decr); + R_RegisterCCallable("pomp_472239922ec0d83afeb4fa1f3189779b", "__pomp_rinit", (DL_FUNC) __pomp_rinit); + R_RegisterCCallable("pomp_472239922ec0d83afeb4fa1f3189779b", "__pomp_stepfn", (DL_FUNC) __pomp_stepfn); X0 = *get_userdata_double("x0"); } +Warning message: +The provided object 'x0' is available for use by POMP basic components. +This option is deprecated: use 'userdata' to specify the list of such objects explicitly. +In a future release, this warning will become an error. > diff --git a/tests/userdata.R b/tests/userdata.R index 1c542d410..c91689a27 100644 --- a/tests/userdata.R +++ b/tests/userdata.R @@ -3,10 +3,13 @@ set.seed(58668844L) library(pomp) -simulate(times=seq(1,100),t0=0, - nbasis=9L, - period=50.0, - msg="hello!", +simulate( + times=seq(1,100),t0=0, + userdata=list( + nbasis=9L, + period=50.0, + msg="hello!" + ), params=setNames(runif(n=9,min=-5,max=5),sprintf("beta%d",1:9)), rprocess=euler( Csnippet(r"{ @@ -51,8 +54,8 @@ try(po |> try(po |> simulate(rprocess=onestep( Csnippet(r"{int nbasis = *(get_userdata_int("bob"));}")), - bob=3)) + userdata=list(bob=3))) stopifnot(po |> simulate(rprocess=onestep( Csnippet(r"{int nbasis = *(get_userdata_int("bob"));}")), - bob=3L) |> class() == "pomp") + userdata=list(bob=3L)) |> class() == "pomp") diff --git a/tests/userdata.Rout.save b/tests/userdata.Rout.save index 146346df2..5d2fe7883 100644 --- a/tests/userdata.Rout.save +++ b/tests/userdata.Rout.save @@ -22,10 +22,13 @@ Type 'q()' to quit R. > > library(pomp) > -> simulate(times=seq(1,100),t0=0, -+ nbasis=9L, -+ period=50.0, -+ msg="hello!", +> simulate( ++ times=seq(1,100),t0=0, ++ userdata=list( ++ nbasis=9L, ++ period=50.0, ++ msg="hello!" ++ ), + params=setNames(runif(n=9,min=-5,max=5),sprintf("beta%d",1:9)), + rprocess=euler( + Csnippet(r"{ @@ -48,7 +51,6 @@ Type 'q()' to quit R. + rinit=Csnippet("x = 0;"), + statenames="x",obsnames="y",paramnames=c("beta1","beta2","beta3") + ) -> po -NOTE: The provided objects 'nbasis','period','msg' are available for use by POMP basic components. hello! > > try(po |> @@ -77,12 +79,10 @@ Error : in 'simulate': no user-data element 'bob' is found. > try(po |> + simulate(rprocess=onestep( + Csnippet(r"{int nbasis = *(get_userdata_int("bob"));}")), -+ bob=3)) -NOTE: The provided object 'bob' is available for use by POMP basic components. ++ userdata=list(bob=3))) Error : in 'simulate': user-data element 'bob' is not an integer. > stopifnot(po |> + simulate(rprocess=onestep( + Csnippet(r"{int nbasis = *(get_userdata_int("bob"));}")), -+ bob=3L) |> class() == "pomp") -NOTE: The provided object 'bob' is available for use by POMP basic components. ++ userdata=list(bob=3L)) |> class() == "pomp") >