From noreply at r-forge.r-project.org Sun Feb 1 16:17:40 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 1 Feb 2015 16:17:40 +0100 (CET) Subject: [Pomp-commits] r1067 - in pkg/pomp: . R Message-ID: <20150201151740.C3ABE187971@r-forge.r-project.org> Author: kingaa Date: 2015-02-01 16:17:40 +0100 (Sun, 01 Feb 2015) New Revision: 1067 Modified: pkg/pomp/DESCRIPTION pkg/pomp/R/pfilter.R Log: - make sure that filter.mean, pred.mean, and pred.var have named dimnames (for optimum interaction with 'reshape2') Modified: pkg/pomp/DESCRIPTION =================================================================== --- pkg/pomp/DESCRIPTION 2015-01-31 15:59:49 UTC (rev 1066) +++ pkg/pomp/DESCRIPTION 2015-02-01 15:17:40 UTC (rev 1067) @@ -1,7 +1,7 @@ Package: pomp Type: Package Title: Statistical Inference for Partially Observed Markov Processes -Version: 0.58-8 +Version: 0.58-9 Date: 2015-01-31 Authors at R: c(person(given=c("Aaron","A."),family="King", role=c("aut","cre"),email="kingaa at umich.edu"), Modified: pkg/pomp/R/pfilter.R =================================================================== --- pkg/pomp/R/pfilter.R 2015-01-31 15:59:49 UTC (rev 1066) +++ pkg/pomp/R/pfilter.R 2015-02-01 15:17:40 UTC (rev 1067) @@ -118,14 +118,16 @@ ptsi.for <- FALSE ## set up storage for saving samples from filtering distributions - if (save.states) - xparticles <- vector(mode="list",length=ntimes) - else + if (save.states) { + xparticles <- setNames(vector(mode="list",length=ntimes),time(object)) + } else { xparticles <- list() - if (save.params) - pparticles <- vector(mode="list",length=ntimes) - else + } + if (save.params) { + pparticles <- setNames(vector(mode="list",length=ntimes),time(object)) + } else { pparticles <- list() + } random.walk <- !missing(.rw.sd) if (random.walk) { @@ -155,7 +157,9 @@ data=0, nrow=nvars+npars, ncol=ntimes, - dimnames=list(c(statenames,rw.names),NULL) + dimnames=list( + variable=c(statenames,rw.names), + time=time(object)) ) else pred.m <- array(data=numeric(0),dim=c(0,0)) @@ -165,7 +169,9 @@ data=0, nrow=nvars+npars, ncol=ntimes, - dimnames=list(c(statenames,rw.names),NULL) + dimnames=list( + variable=c(statenames,rw.names), + time=time(object)) ) else pred.v <- array(data=numeric(0),dim=c(0,0)) @@ -176,14 +182,18 @@ data=0, nrow=nvars+length(paramnames), ncol=ntimes, - dimnames=list(c(statenames,paramnames),NULL) + dimnames=list( + variable=c(statenames,paramnames), + time=time(object)) ) else filt.m <- matrix( data=0, nrow=nvars, ncol=ntimes, - dimnames=list(statenames,NULL) + dimnames=list( + variable=statenames, + time=time(object)) ) else filt.m <- array(data=numeric(0),dim=c(0,0)) From noreply at r-forge.r-project.org Mon Feb 9 20:31:17 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 9 Feb 2015 20:31:17 +0100 (CET) Subject: [Pomp-commits] r1068 - in pkg/pomp: . R Message-ID: <20150209193117.C3F06186B01@r-forge.r-project.org> Author: kingaa Date: 2015-02-09 20:31:17 +0100 (Mon, 09 Feb 2015) New Revision: 1068 Modified: pkg/pomp/DESCRIPTION pkg/pomp/R/pomp.R Log: - fix bug in which any error in compilation on call to 'pomp' is not caught properly Modified: pkg/pomp/DESCRIPTION =================================================================== --- pkg/pomp/DESCRIPTION 2015-02-01 15:17:40 UTC (rev 1067) +++ pkg/pomp/DESCRIPTION 2015-02-09 19:31:17 UTC (rev 1068) @@ -1,8 +1,8 @@ Package: pomp Type: Package Title: Statistical Inference for Partially Observed Markov Processes -Version: 0.58-9 -Date: 2015-01-31 +Version: 0.58-10 +Date: 2015-02-09 Authors at R: c(person(given=c("Aaron","A."),family="King", role=c("aut","cre"),email="kingaa at umich.edu"), person(given=c("Edward","L."),family="Ionides",role=c("aut")), Modified: pkg/pomp/R/pomp.R =================================================================== --- pkg/pomp/R/pomp.R 2015-02-01 15:17:40 UTC (rev 1067) +++ pkg/pomp/R/pomp.R 2015-02-09 19:31:17 UTC (rev 1068) @@ -153,7 +153,7 @@ ), silent=FALSE ) - if (inherits(PACKAGE,"try-error")) { + if (inherits(libname,"try-error")) { stop("error in building shared-object library from Csnippets") } else { .solibfile <- c(.solibfile,libname[2L]) From noreply at r-forge.r-project.org Mon Feb 9 23:48:00 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 9 Feb 2015 23:48:00 +0100 (CET) Subject: [Pomp-commits] r1069 - in pkg/pomp: . R Message-ID: <20150209224800.2E16D187859@r-forge.r-project.org> Author: kingaa Date: 2015-02-09 23:47:59 +0100 (Mon, 09 Feb 2015) New Revision: 1069 Modified: pkg/pomp/DESCRIPTION pkg/pomp/R/pomp.R Log: - better error reporting Modified: pkg/pomp/DESCRIPTION =================================================================== --- pkg/pomp/DESCRIPTION 2015-02-09 19:31:17 UTC (rev 1068) +++ pkg/pomp/DESCRIPTION 2015-02-09 22:47:59 UTC (rev 1069) @@ -1,7 +1,7 @@ Package: pomp Type: Package Title: Statistical Inference for Partially Observed Markov Processes -Version: 0.58-10 +Version: 0.58-11 Date: 2015-02-09 Authors at R: c(person(given=c("Aaron","A."),family="King", role=c("aut","cre"),email="kingaa at umich.edu"), Modified: pkg/pomp/R/pomp.R =================================================================== --- pkg/pomp/R/pomp.R 2015-02-09 19:31:17 UTC (rev 1068) +++ pkg/pomp/R/pomp.R 2015-02-09 22:47:59 UTC (rev 1069) @@ -154,7 +154,8 @@ silent=FALSE ) if (inherits(libname,"try-error")) { - stop("error in building shared-object library from Csnippets") + stop("in ",sQuote("pomp"),": error in building shared-object library from Csnippets:\n", + libname,call.=FALSE) } else { .solibfile <- c(.solibfile,libname[2L]) libname <- libname[1L] From noreply at r-forge.r-project.org Wed Feb 11 13:31:23 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 11 Feb 2015 13:31:23 +0100 (CET) Subject: [Pomp-commits] r1070 - pkg/pompExamples Message-ID: <20150211123124.0068A185593@r-forge.r-project.org> Author: kingaa Date: 2015-02-11 13:31:23 +0100 (Wed, 11 Feb 2015) New Revision: 1070 Modified: pkg/pompExamples/DESCRIPTION Log: - bump Modified: pkg/pompExamples/DESCRIPTION =================================================================== --- pkg/pompExamples/DESCRIPTION 2015-02-09 22:47:59 UTC (rev 1069) +++ pkg/pompExamples/DESCRIPTION 2015-02-11 12:31:23 UTC (rev 1070) @@ -1,8 +1,8 @@ Package: pompExamples Type: Package Title: Additional pomp examples -Version: 0.26-5 -Date: 2015-01-29 +Version: 0.26-6 +Date: 2015-02-11 Maintainer: Aaron A. King Authors at R: c(person(given=c("Aaron","A."),family="King",role=c("aut","cre"), email="kingaa at umich.edu"), From noreply at r-forge.r-project.org Fri Feb 13 20:34:41 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 13 Feb 2015 20:34:41 +0100 (CET) Subject: [Pomp-commits] r1071 - in pkg/pomp: . R inst tests Message-ID: <20150213193441.D9C8B18766B@r-forge.r-project.org> Author: kingaa Date: 2015-02-13 20:34:41 +0100 (Fri, 13 Feb 2015) New Revision: 1071 Added: pkg/pomp/tests/ou2-spect.R pkg/pomp/tests/ou2-spect.Rout.save Modified: pkg/pomp/DESCRIPTION pkg/pomp/R/spect-match.R pkg/pomp/inst/NEWS pkg/pomp/inst/NEWS.Rd Log: - bug fix in 'spect.match'. Thanks to Karsten Hempel for catching it and submitting a patch. Modified: pkg/pomp/DESCRIPTION =================================================================== --- pkg/pomp/DESCRIPTION 2015-02-11 12:31:23 UTC (rev 1070) +++ pkg/pomp/DESCRIPTION 2015-02-13 19:34:41 UTC (rev 1071) @@ -1,8 +1,8 @@ Package: pomp Type: Package Title: Statistical Inference for Partially Observed Markov Processes -Version: 0.58-11 -Date: 2015-02-09 +Version: 0.59-1 +Date: 2015-02-14 Authors at R: c(person(given=c("Aaron","A."),family="King", role=c("aut","cre"),email="kingaa at umich.edu"), person(given=c("Edward","L."),family="Ionides",role=c("aut")), Modified: pkg/pomp/R/spect-match.R =================================================================== --- pkg/pomp/R/spect-match.R 2015-02-11 12:31:23 UTC (rev 1070) +++ pkg/pomp/R/spect-match.R 2015-02-13 19:34:41 UTC (rev 1071) @@ -37,13 +37,14 @@ detrend=detrend, ker=ker ) + ## simvals is an nsim x nfreq x nobs array ## compute a measure of the discrepancies between simulations and data discrep <- array(dim=c(length(freq),length(vars))) sim.means <- colMeans(simvals) for (j in seq_along(freq)) { for (k in seq_along(vars)) { - discrep[j,k] <- ((datval[j,k]-sim.means[j,k])^2)/mean((simvals[j,,k]-sim.means[j,k])^2) + discrep[j,k] <- ((datval[j,k]-sim.means[j,k])^2)/mean((simvals[,j,k]-sim.means[j,k])^2) } discrep[j,] <- weights[j]*discrep[j,] } Modified: pkg/pomp/inst/NEWS =================================================================== --- pkg/pomp/inst/NEWS 2015-02-11 12:31:23 UTC (rev 1070) +++ pkg/pomp/inst/NEWS 2015-02-13 19:34:41 UTC (rev 1071) @@ -1,5 +1,10 @@ _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 _0._5_9-_1: + + ? A bug in ?spect.match? has been fixed. Thanks to Karsten + Hempel for finding it and contributing the fix. + _C_h_a_n_g_e_s _i_n '_p_o_m_p' _v_e_r_s_i_o_n _0._5_8-_1: ? Compiler messages are now suppressed by default when Modified: pkg/pomp/inst/NEWS.Rd =================================================================== --- pkg/pomp/inst/NEWS.Rd 2015-02-11 12:31:23 UTC (rev 1070) +++ pkg/pomp/inst/NEWS.Rd 2015-02-13 19:34:41 UTC (rev 1071) @@ -1,5 +1,11 @@ \name{NEWS} \title{News for package `pomp'} +\section{Changes in \pkg{pomp} version 0.59-1}{ + \itemize{ + \item A bug in \code{spect.match} has been fixed. + Thanks to Karsten Hempel for finding it and contributing the fix. + } +} \section{Changes in \pkg{pomp} version 0.58-1}{ \itemize{ \item Compiler messages are now suppressed by default when \code{Csnippet}s are used in construction of a \code{pomp} object. Added: pkg/pomp/tests/ou2-spect.R =================================================================== --- pkg/pomp/tests/ou2-spect.R (rev 0) +++ pkg/pomp/tests/ou2-spect.R 2015-02-13 19:34:41 UTC (rev 1071) @@ -0,0 +1,16 @@ +library(pomp) +pompExample(ou2) + +gm1 <- spect.match(ou2, + kernel.width=3, + detrend="mean", + nsim=50, + est=c("alpha.1","alpha.4"), + method="Nelder-Mead") + +gm2 <- spect.match(ou2, + kernel.width=3, + detrend="mean", + nsim=49, + est=c("alpha.1","alpha.4"), + method="Nelder-Mead") Added: pkg/pomp/tests/ou2-spect.Rout.save =================================================================== --- pkg/pomp/tests/ou2-spect.Rout.save (rev 0) +++ pkg/pomp/tests/ou2-spect.Rout.save 2015-02-13 19:34:41 UTC (rev 1071) @@ -0,0 +1,41 @@ + +R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" +Copyright (C) 2014 The R Foundation for Statistical Computing +Platform: x86_64-unknown-linux-gnu (64-bit) + +R is free software and comes with ABSOLUTELY NO WARRANTY. +You are welcome to redistribute it under certain conditions. +Type 'license()' or 'licence()' for distribution details. + +R is a collaborative project with many contributors. +Type 'contributors()' for more information and +'citation()' on how to cite R or R packages in publications. + +Type 'demo()' for some demos, 'help()' for on-line help, or +'help.start()' for an HTML browser interface to help. +Type 'q()' to quit R. + +> library(pomp) +Loading required package: subplex +Loading required package: nloptr +> pompExample(ou2) +newly created object(s): + ou2 +> +> gm1 <- spect.match(ou2, ++ kernel.width=3, ++ detrend="mean", ++ nsim=50, ++ est=c("alpha.1","alpha.4"), ++ method="Nelder-Mead") +> +> gm2 <- spect.match(ou2, ++ kernel.width=3, ++ detrend="mean", ++ nsim=49, ++ est=c("alpha.1","alpha.4"), ++ method="Nelder-Mead") +> +> proc.time() + user system elapsed + 21.537 0.040 21.670 From noreply at r-forge.r-project.org Tue Feb 17 12:49:31 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 17 Feb 2015 12:49:31 +0100 (CET) Subject: [Pomp-commits] r1072 - / Message-ID: <20150217114931.CE77C185979@r-forge.r-project.org> Author: mpacala Date: 2015-02-17 12:49:31 +0100 (Tue, 17 Feb 2015) New Revision: 1072 Added: trigger_build Log: Added: trigger_build =================================================================== From noreply at r-forge.r-project.org Tue Feb 17 13:09:09 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 17 Feb 2015 13:09:09 +0100 (CET) Subject: [Pomp-commits] r1073 - pkg/pompExamples Message-ID: <20150217120910.08D00185F4A@r-forge.r-project.org> Author: mpacala Date: 2015-02-17 13:09:09 +0100 (Tue, 17 Feb 2015) New Revision: 1073 Added: pkg/pompExamples/build Log: Added: pkg/pompExamples/build =================================================================== From noreply at r-forge.r-project.org Tue Feb 17 13:31:45 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 17 Feb 2015 13:31:45 +0100 (CET) Subject: [Pomp-commits] r1074 - pkg/pompExamples Message-ID: <20150217123145.DF64918707E@r-forge.r-project.org> Author: mpacala Date: 2015-02-17 13:31:45 +0100 (Tue, 17 Feb 2015) New Revision: 1074 Removed: pkg/pompExamples/build Log: Deleted: pkg/pompExamples/build =================================================================== From noreply at r-forge.r-project.org Tue Feb 17 14:29:33 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 17 Feb 2015 14:29:33 +0100 (CET) Subject: [Pomp-commits] r1075 - pkg/pompExamples Message-ID: <20150217132933.1B0F31876F0@r-forge.r-project.org> Author: mpacala Date: 2015-02-17 14:29:32 +0100 (Tue, 17 Feb 2015) New Revision: 1075 Added: pkg/pompExamples/build Log: Added: pkg/pompExamples/build =================================================================== From noreply at r-forge.r-project.org Tue Feb 17 14:43:04 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 17 Feb 2015 14:43:04 +0100 (CET) Subject: [Pomp-commits] r1076 - pkg/pompExamples Message-ID: <20150217134305.10A0218111F@r-forge.r-project.org> Author: mpacala Date: 2015-02-17 14:43:04 +0100 (Tue, 17 Feb 2015) New Revision: 1076 Removed: pkg/pompExamples/build Log: Deleted: pkg/pompExamples/build =================================================================== From noreply at r-forge.r-project.org Tue Feb 17 15:24:58 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 17 Feb 2015 15:24:58 +0100 (CET) Subject: [Pomp-commits] r1077 - pkg/pompExamples Message-ID: <20150217142458.2EC611876F0@r-forge.r-project.org> Author: mpacala Date: 2015-02-17 15:24:57 +0100 (Tue, 17 Feb 2015) New Revision: 1077 Added: pkg/pompExamples/build Log: Added: pkg/pompExamples/build =================================================================== From noreply at r-forge.r-project.org Tue Feb 17 15:45:10 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 17 Feb 2015 15:45:10 +0100 (CET) Subject: [Pomp-commits] r1078 - pkg/pompExamples Message-ID: <20150217144510.A55C71865EF@r-forge.r-project.org> Author: mpacala Date: 2015-02-17 15:45:10 +0100 (Tue, 17 Feb 2015) New Revision: 1078 Removed: pkg/pompExamples/build Log: Deleted: pkg/pompExamples/build =================================================================== From noreply at r-forge.r-project.org Tue Feb 17 16:16:10 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 17 Feb 2015 16:16:10 +0100 (CET) Subject: [Pomp-commits] r1079 - pkg/pompExamples Message-ID: <20150217151610.C49AC186D3B@r-forge.r-project.org> Author: mpacala Date: 2015-02-17 16:16:10 +0100 (Tue, 17 Feb 2015) New Revision: 1079 Added: pkg/pompExamples/build Log: Added: pkg/pompExamples/build =================================================================== From noreply at r-forge.r-project.org Tue Feb 17 19:09:39 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 17 Feb 2015 19:09:39 +0100 (CET) Subject: [Pomp-commits] r1080 - pkg/pompExamples Message-ID: <20150217180939.9ADC4184672@r-forge.r-project.org> Author: mpacala Date: 2015-02-17 19:09:39 +0100 (Tue, 17 Feb 2015) New Revision: 1080 Removed: pkg/pompExamples/build Log: Deleted: pkg/pompExamples/build =================================================================== From noreply at r-forge.r-project.org Tue Feb 17 19:42:36 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 17 Feb 2015 19:42:36 +0100 (CET) Subject: [Pomp-commits] r1081 - pkg/pompExamples Message-ID: <20150217184236.36A11186D3B@r-forge.r-project.org> Author: mpacala Date: 2015-02-17 19:42:35 +0100 (Tue, 17 Feb 2015) New Revision: 1081 Added: pkg/pompExamples/build Log: Added: pkg/pompExamples/build =================================================================== From noreply at r-forge.r-project.org Tue Feb 17 20:17:11 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 17 Feb 2015 20:17:11 +0100 (CET) Subject: [Pomp-commits] r1082 - pkg/pompExamples Message-ID: <20150217191711.E18A11876E2@r-forge.r-project.org> Author: mpacala Date: 2015-02-17 20:17:11 +0100 (Tue, 17 Feb 2015) New Revision: 1082 Removed: pkg/pompExamples/build Log: Deleted: pkg/pompExamples/build =================================================================== From noreply at r-forge.r-project.org Sun Feb 22 20:38:41 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 22 Feb 2015 20:38:41 +0100 (CET) Subject: [Pomp-commits] r1083 - in pkg/pomp: . R man Message-ID: <20150222193842.11AE5187A49@r-forge.r-project.org> Author: kingaa Date: 2015-02-22 20:38:41 +0100 (Sun, 22 Feb 2015) New Revision: 1083 Added: pkg/pomp/R/proposals.R pkg/pomp/man/proposals.Rd Modified: pkg/pomp/DESCRIPTION pkg/pomp/NAMESPACE Log: - new MCMC proposal-function construction functions Modified: pkg/pomp/DESCRIPTION =================================================================== --- pkg/pomp/DESCRIPTION 2015-02-17 19:17:11 UTC (rev 1082) +++ pkg/pomp/DESCRIPTION 2015-02-22 19:38:41 UTC (rev 1083) @@ -1,8 +1,8 @@ Package: pomp Type: Package Title: Statistical Inference for Partially Observed Markov Processes -Version: 0.59-1 -Date: 2015-02-14 +Version: 0.60-1 +Date: 2015-02-22 Authors at R: c(person(given=c("Aaron","A."),family="King", role=c("aut","cre"),email="kingaa at umich.edu"), person(given=c("Edward","L."),family="Ionides",role=c("aut")), @@ -35,7 +35,7 @@ pfilter.R pfilter-methods.R minim.R traj-match.R bsmc.R bsmc2.R mif.R mif-methods.R - pmcmc.R pmcmc-methods.R + proposals.R pmcmc.R pmcmc-methods.R nlf-funcs.R nlf-guts.R nlf-objfun.R nlf.R probe.R probe-match.R basic-probes.R spect.R spect-match.R abc.R abc-methods.R Modified: pkg/pomp/NAMESPACE =================================================================== --- pkg/pomp/NAMESPACE 2015-02-17 19:17:11 UTC (rev 1082) +++ pkg/pomp/NAMESPACE 2015-02-22 19:38:41 UTC (rev 1083) @@ -85,6 +85,7 @@ onestep.sim, onestep.dens, gillespie.sim, + mvn.diag.rw,mvn.rw, sobol, sobolDesign, sliceDesign, Added: pkg/pomp/R/proposals.R =================================================================== --- pkg/pomp/R/proposals.R (rev 0) +++ pkg/pomp/R/proposals.R 2015-02-22 19:38:41 UTC (rev 1083) @@ -0,0 +1,25 @@ +mvn.rw.proposal.fn <- function (rw.sd) { + parnm <- colnames(rw.sd) + n <- ncol(rw.sd) + if (is.null(parnm)) + stop(sQuote("rw.sd")," must have names") + if (is.matrix(rw.sd)) { + if (nrow(rw.sd)!=ncol(rw.sd)) + stop(sQuote("rw.sd")," must be a square matrix") + ch <- try (chol(rw.sd,pivot=TRUE)) + if (inherits(ch,"try-error")) + stop("error in Choleski factorization of ",sQuote("rw.sd")) + oo <- order(attr(ch,"pivot")) + Q <- ch[,oo] + fn <- function (theta) { + theta[parnm] <- theta[parnm]+Q.rnorm(n=n,mean=0,sd=1) + theta + } + } else { + fn <- function (theta) { + theta[parnm] <- rnorm(n=n,mean=theta[parnm],sd=rw.sd) + theta + } + } + fn +} Added: pkg/pomp/man/proposals.Rd =================================================================== --- pkg/pomp/man/proposals.Rd (rev 0) +++ pkg/pomp/man/proposals.Rd 2015-02-22 19:38:41 UTC (rev 1083) @@ -0,0 +1,27 @@ +\name{proposals} +\alias{MCMC proposal functions} +\alias{mvn.rw} +\alias{mvn.diag.rw} +\title{MCMC proposal functions} +\description{ + Construct proposal distributions for use with MCMC methods. +} +\usage{ + mvn.diag.rw(rw.sd) + mvn.rw(rw.var) +} +\arguments{ + \item{rw.sd}{ + named numeric vector; + random-walk SDs for a multivariate normal random-walk proposal with diagonal variance-covariance matrix. + } + \item{rw.var}{ + square numeric matrix with row- and column-names. + Specifies the variance-covariance matrix for a multivariate normal random-walk proposal distribution. + } +} +\value{ + Functions taking a single argument. + Given a parameter vector, each returns a single draw from the corresponding proposal distribution. +} +\author{Aaron A. King \email{kingaa at umich dot edu}} From noreply at r-forge.r-project.org Sun Feb 22 20:43:06 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 22 Feb 2015 20:43:06 +0100 (CET) Subject: [Pomp-commits] r1084 - pkg/pomp/R Message-ID: <20150222194306.B6E8D185570@r-forge.r-project.org> Author: kingaa Date: 2015-02-22 20:43:06 +0100 (Sun, 22 Feb 2015) New Revision: 1084 Modified: pkg/pomp/R/proposals.R Log: - update proposals Modified: pkg/pomp/R/proposals.R =================================================================== --- pkg/pomp/R/proposals.R 2015-02-22 19:38:41 UTC (rev 1083) +++ pkg/pomp/R/proposals.R 2015-02-22 19:43:06 UTC (rev 1084) @@ -1,25 +1,33 @@ -mvn.rw.proposal.fn <- function (rw.sd) { - parnm <- colnames(rw.sd) - n <- ncol(rw.sd) +mvn.diag.rw <- function (rw.sd) { + if (!is.numeric(rw.sd)) { + stop(sQuote("rw.sd")," must be a named numeric vector") + } + rw.sd <- rw.sd[rw.sd>0] + parnm <- names(rw.sd) + n <- length(rw.sd) if (is.null(parnm)) stop(sQuote("rw.sd")," must have names") - if (is.matrix(rw.sd)) { - if (nrow(rw.sd)!=ncol(rw.sd)) - stop(sQuote("rw.sd")," must be a square matrix") - ch <- try (chol(rw.sd,pivot=TRUE)) - if (inherits(ch,"try-error")) - stop("error in Choleski factorization of ",sQuote("rw.sd")) - oo <- order(attr(ch,"pivot")) - Q <- ch[,oo] - fn <- function (theta) { - theta[parnm] <- theta[parnm]+Q.rnorm(n=n,mean=0,sd=1) - theta - } - } else { - fn <- function (theta) { - theta[parnm] <- rnorm(n=n,mean=theta[parnm],sd=rw.sd) - theta - } + function (theta) { + theta[parnm] <- rnorm(n=n,mean=theta[parnm],sd=rw.sd) + theta } - fn } + +mvn.rw <- function (rw.var) { + rw.var <- as.matrix(rw.var) + parnm <- colnames(rw.var) + n <- ncol(rw.var) + if (is.null(parnm)) + stop(sQuote("rw.var")," must have row- and column-names") + if (nrow(rw.var)!=ncol(rw.var)) + stop(sQuote("rw.var")," must be a square matrix") + ch <- try (chol(rw.var,pivot=TRUE)) + if (inherits(ch,"try-error")) + stop("error in Choleski factorization of ",sQuote("rw.var")) + oo <- order(attr(ch,"pivot")) + Q <- ch[,oo] + function (theta) { + theta[parnm] <- theta[parnm]+Q%*%rnorm(n=n,mean=0,sd=1) + theta + } +} From noreply at r-forge.r-project.org Sun Feb 22 20:43:12 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 22 Feb 2015 20:43:12 +0100 (CET) Subject: [Pomp-commits] r1085 - in pkg/pomp: R man Message-ID: <20150222194312.66A5F185570@r-forge.r-project.org> Author: kingaa Date: 2015-02-22 20:43:12 +0100 (Sun, 22 Feb 2015) New Revision: 1085 Modified: pkg/pomp/R/nlf.R pkg/pomp/man/nlf.Rd Log: - the transform.params argument is now deprecated in favor of the transform argument Modified: pkg/pomp/R/nlf.R =================================================================== --- pkg/pomp/R/nlf.R 2015-02-22 19:43:06 UTC (rev 1084) +++ pkg/pomp/R/nlf.R 2015-02-22 19:43:12 UTC (rev 1085) @@ -414,16 +414,16 @@ verbose = getOption("verbose"), bootstrap = FALSE, bootsamp = NULL, lql.frac = 0.1, se.par.frac = 0.1, - eval.only = FALSE, transform.params = FALSE, - transform, ...) + eval.only = FALSE, transform.params, + transform = FALSE, ...) { - transform.params <- as.logical(transform.params) - if (!missing(transform)) { - warning("argument ",sQuote("transform"), - " is deprecated and will change meaning in a future release.\n", - "Use ",sQuote("transform.data")," instead.") - if (missing(transform.data)) transform.data <- transform + if (!missing(transform.params)) { + warning("argument ",sQuote("transform.params"), + " is deprecated and will be removed in a future release.\n", + "Use ",sQuote("transform")," instead.") + if (missing(transform)) transform <- transform.params } + transform <- as.logical(transform) if (missing(transform.data)) transform.data <- identity transform.data <- match.fun(transform.data) period <- as.numeric(period) @@ -469,7 +469,7 @@ lql.frac=lql.frac, se.par.frac=se.par.frac, eval.only=eval.only, - transform=transform.params, + transform=transform, transform.data=transform.data, ... ) @@ -482,7 +482,7 @@ definition=function (object, start, est, lags, period, tensor, nconverge, nasymp, seed, transform.data, nrbf, method, lql.frac, se.par.frac, - transform.params, ...) + transform, ...) { if (missing(start)) start <- coef(object) if (missing(est)) est <- object at est @@ -492,7 +492,7 @@ if (missing(nconverge)) nconverge <- object at nconverge if (missing(nasymp)) nasymp <- object at nasymp if (missing(seed)) seed <- object at seed - if (missing(transform.params)) transform.params <- object at transform + if (missing(transform)) transform <- object at transform if (missing(transform.data)) transform.data <- object at transform.data if (missing(nrbf)) nrbf <- object at nrbf if (missing(method)) method <- object at method @@ -509,7 +509,7 @@ tensor=tensor, nconverge=nconverge, seed=seed, - transform.params=transform.params, + transform=transform, transform.data=transform.data, nrbf=nrbf, method=method, Modified: pkg/pomp/man/nlf.Rd =================================================================== --- pkg/pomp/man/nlf.Rd 2015-02-22 19:43:06 UTC (rev 1084) +++ pkg/pomp/man/nlf.Rd 2015-02-22 19:43:12 UTC (rev 1085) @@ -22,10 +22,10 @@ skip.se = FALSE, verbose = getOption("verbose"), bootstrap=FALSE, bootsamp = NULL, lql.frac = 0.1, se.par.frac = 0.1, eval.only = FALSE, - transform.params = FALSE, transform, \dots) + transform.params, transform = FALSE, \dots) \S4method{nlf}{nlfd.pomp}(object, start, est, lags, period, tensor, nconverge, nasymp, seed, transform.data, nrbf, method, - lql.frac, se.par.frac, transform.params, \dots) + lql.frac, se.par.frac, transform, \dots) } \arguments{ \item{object}{ @@ -61,7 +61,16 @@ When fitting, it is usually best to always run the simulations with the same sequence of random numbers, which is accomplished by setting \code{seed} to an integer. If you want a truly random simulation, set \code{seed=NULL}. } - \item{transform.data, transform}{ + \item{transform.params}{ + deprecated. + Will be removed in a future version. + Use \code{transform} instead. + } + \item{transform}{ + logical; + if \code{TRUE}, parameters are optimized on the transformed scale. + } + \item{transform.data}{ optional function. If specified, forecasting is performed using data and model simulations transformed by this function. By default, \code{transform.data} is the identity function, i.e., no transformation is performed. @@ -97,10 +106,6 @@ \item{eval.only}{ logical; if \code{TRUE}, no optimization is attempted and the quasi-loglikelihood value is evaluated at the \code{start} parameters. } - \item{transform.params}{ - logical; - if \code{TRUE}, parameters are optimized on the transformed scale. - } \item{\dots}{ Arguments that will be passed to \code{optim} or \code{subplex} in the \code{control} list. } From noreply at r-forge.r-project.org Sun Feb 22 20:43:18 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 22 Feb 2015 20:43:18 +0100 (CET) Subject: [Pomp-commits] r1086 - in pkg/pomp: R man tests Message-ID: <20150222194318.98C43185570@r-forge.r-project.org> Author: kingaa Date: 2015-02-22 20:43:18 +0100 (Sun, 22 Feb 2015) New Revision: 1086 Modified: pkg/pomp/R/pmcmc-methods.R pkg/pomp/R/pmcmc.R pkg/pomp/man/pmcmc.Rd pkg/pomp/tests/ou2-pmcmc.R pkg/pomp/tests/ou2-pmcmc.Rout.save Log: - new 'proposal' argument to 'pmcmc' - 'rw.sd' argument is obviated and deprecated - 'pars' argument is deprecated and ignored Modified: pkg/pomp/R/pmcmc-methods.R =================================================================== --- pkg/pomp/R/pmcmc-methods.R 2015-02-22 19:43:12 UTC (rev 1085) +++ pkg/pomp/R/pmcmc-methods.R 2015-02-22 19:43:18 UTC (rev 1086) @@ -127,7 +127,8 @@ mar.multi <- c(0,5.1,0,2.1) oma.multi <- c(6,0,5,0) xx <- z[[1]] - estnames <- xx at pars + estnames <- apply(xx at conv.rec,2,function(x)diff(range(x))>0) + estnames <- names(estnames[estnames]) ## plot pmcmc convergence diagnostics other.diagnostics <- c("loglik", "log.prior","nfail") Modified: pkg/pomp/R/pmcmc.R =================================================================== --- pkg/pomp/R/pmcmc.R 2015-02-22 19:43:12 UTC (rev 1085) +++ pkg/pomp/R/pmcmc.R 2015-02-22 19:43:18 UTC (rev 1086) @@ -3,18 +3,22 @@ 'pmcmc', contains='pfilterd.pomp', slots=c( - pars = 'character', Nmcmc = 'integer', - random.walk.sd = 'numeric', - conv.rec = 'matrix', + proposal = 'function', + conv.rec = 'array', log.prior = 'numeric' + ), + prototype=prototype( + Nmcmc = 0L, + proposal = function (...) stop("proposal not specified"), + conv.rec=array(dim=c(0,0)), + log.prior=numeric(0) ) ) pmcmc.internal <- function (object, Nmcmc, - start, pars, - rw.sd, Np, - tol, max.fail, + start, proposal, + Np, tol, max.fail, verbose, .ndone = 0L, .prev.pfp = NULL, .prev.log.prior = NULL, @@ -29,57 +33,21 @@ if (length(start)==0) stop( sQuote("start")," must be specified if ", - sQuote("coef(object)")," is NULL", - call.=FALSE + sQuote("coef(object)")," is NULL" ) - start.names <- names(start) - if (is.null(start.names)) + if (is.null(names(start))) stop("pmcmc error: ",sQuote("start")," must be a named vector",call.=FALSE) - if (missing(rw.sd)) - stop("pmcmc error: ",sQuote("rw.sd")," must be specified",call.=FALSE) - rw.names <- names(rw.sd) - if (is.null(rw.names) || any(rw.sd<0)) - stop("pmcmc error: ",sQuote("rw.sd")," must be a named non-negative numerical vector",call.=FALSE) - if (!all(rw.names%in%start.names)) - stop("pmcmc error: all the names of ",sQuote("rw.sd")," must be names of ",sQuote("start"),call.=FALSE) - rw.names <- names(rw.sd[rw.sd>0]) - if (length(rw.names) == 0) - stop("pmcmc error: ",sQuote("rw.sd")," must have one positive entry for each parameter to be estimated",call.=FALSE) + if (!is.function(proposal)) + stop(sQuote("proposal")," must be a function") - if (missing(pars)) - stop("pmcmc error: ",sQuote("pars")," must be specified",call.=FALSE) - if (length(pars)==0) - stop("pmcmc error: at least one parameter must be estimated",call.=FALSE) - if ( - !is.character(pars) || - !all(pars%in%start.names) || - !all(pars%in%rw.names) - ) - stop( - "pmcmc error: ", - sQuote("pars"), - " must be a mutually disjoint subset of ", - sQuote("names(start)"), - " and must correspond to positive random-walk SDs specified in ", - sQuote("rw.sd"), - call.=FALSE - ) + ## test proposal distribution + theta <- try(proposal(start)) + if (inherits(theta,"try-error")) + stop("pmcmc error: error in proposal function") + if (is.null(names(theta)) || !is.numeric(theta)) + stop("pmcmc error: ",sQuote("proposal")," must return a named numeric vector") - if (!all(rw.names%in%pars)) { - extra.rws <- rw.names[!(rw.names%in%pars)] - warning( - "pmcmc warning: the variable(s) ", - paste(extra.rws,collapse=", "), - " have positive random-walk SDs specified, but are not included in ", - sQuote("pars"), - ". These random walk SDs are ignored.", - call.=FALSE - ) - } - rw.sd <- rw.sd[pars] - rw.names <- names(rw.sd) - ntimes <- length(time(object)) if (missing(Np)) stop("pmcmc error: ",sQuote("Np")," must be specified",call.=FALSE) @@ -108,11 +76,7 @@ stop("pmcmc error: ",sQuote("Nmcmc")," must be a positive integer",call.=FALSE) if (verbose) { - cat("performing",Nmcmc,"PMCMC iteration(s) to estimate parameter(s)", - paste(pars,collapse=", ")) - cat(" using random-walk with SD\n") - print(rw.sd) - cat("using",Np,"particles\n") + cat("performing",Nmcmc,"PMCMC iteration(s) using",Np,"particles\n") } theta <- start @@ -127,18 +91,6 @@ ) ) - if (!all(is.finite(theta[pars]))) { - stop( - sQuote("pmcmc"), - " error: cannot estimate non-finite parameters: ", - paste( - pars[!is.finite(theta[pars])], - collapse="," - ), - call.=FALSE - ) - } - if (.ndone==0L) { ## compute prior and likelihood on initial parameter vector pfp <- try( pfilter.internal( @@ -171,8 +123,7 @@ for (n in seq_len(Nmcmc)) { # main loop - theta.prop <- theta - theta.prop[pars] <- rnorm(n=length(pars),mean=theta[pars],sd=rw.sd) + theta.prop <- proposal(theta) ## run the particle filter on the proposed new parameter values pfp.prop <- try( @@ -218,8 +169,7 @@ pfp, params=theta, Nmcmc=Nmcmc, - pars=pars, - random.walk.sd=rw.sd, + proposal=proposal, Np=Np, tol=tol, conv.rec=conv.rec, @@ -231,24 +181,34 @@ "pmcmc", signature=signature(object="pomp"), function (object, Nmcmc = 1, - start, pars, rw.sd, Np, + start, proposal, pars, rw.sd, Np, tol = 1e-17, max.fail = 0, verbose = getOption("verbose"), ...) { if (missing(start)) start <- coef(object) - if (missing(rw.sd)) - stop("pmcmc error: ",sQuote("rw.sd")," must be specified",call.=FALSE) - if (missing(pars)) pars <- names(rw.sd)[rw.sd>0] if (missing(Np)) stop("pmcmc error: ",sQuote("Np")," must be specified",call.=FALSE) + if (!missing(rw.sd)) { + warning("pmcmc warning: ",sQuote("rw.sd")," is a deprecated argument.", + "Use ",sQuote("proposal")," instead.",call.=FALSE) + if (missing(proposal)) { + proposal <- mvn.diag.rw(rw.sd=rw.sd) + } else { + warning("pmcmc warning: since ",sQuote("proposal"), + " has been specified, ",sQuote("rw.sd")," is ignored.") + } + } + + if (!missing(pars)) + warning("pmcmc warning: ",sQuote("pars")," is a deprecated argument and will be ignored.",call.=FALSE) + pmcmc.internal( object=object, Nmcmc=Nmcmc, start=start, - pars=pars, - rw.sd=rw.sd, + proposal=proposal, Np=Np, tol=tol, max.fail=max.fail, @@ -280,15 +240,14 @@ "pmcmc", signature=signature(object="pmcmc"), function (object, Nmcmc, - start, pars, rw.sd, + start, proposal, Np, tol, max.fail = 0, verbose = getOption("verbose"), ...) { if (missing(Nmcmc)) Nmcmc <- object at Nmcmc if (missing(start)) start <- coef(object) - if (missing(pars)) pars <- object at pars - if (missing(rw.sd)) rw.sd <- object at random.walk.sd + if (missing(proposal)) proposal <- object at proposal if (missing(Np)) Np <- object at Np if (missing(tol)) tol <- object at tol @@ -296,8 +255,7 @@ object=as(object,"pomp"), Nmcmc=Nmcmc, start=start, - pars=pars, - rw.sd=rw.sd, + proposal=proposal, Np=Np, tol=tol, max.fail=max.fail, Modified: pkg/pomp/man/pmcmc.Rd =================================================================== --- pkg/pomp/man/pmcmc.Rd 2015-02-22 19:43:12 UTC (rev 1085) +++ pkg/pomp/man/pmcmc.Rd 2015-02-22 19:43:18 UTC (rev 1086) @@ -15,11 +15,11 @@ The Particle MCMC algorithm for estimating the parameters of a partially-observed Markov process. } \usage{ -\S4method{pmcmc}{pomp}(object, Nmcmc = 1, start, pars, rw.sd, Np, +\S4method{pmcmc}{pomp}(object, Nmcmc = 1, start, proposal, pars, rw.sd, Np, tol = 1e-17, max.fail = 0, verbose = getOption("verbose"), \dots) \S4method{pmcmc}{pfilterd.pomp}(object, Nmcmc = 1, Np, tol, \dots) -\S4method{pmcmc}{pmcmc}(object, Nmcmc, start, pars, rw.sd, Np, - tol, max.fail = 0, verbose = getOption("verbose"), \dots) +\S4method{pmcmc}{pmcmc}(object, Nmcmc, start, proposal, Np, tol, + max.fail = 0, verbose = getOption("verbose"), \dots) \S4method{continue}{pmcmc}(object, Nmcmc = 1, \dots) } \arguments{ @@ -33,18 +33,14 @@ named numeric vector; the starting guess of the parameters. } - \item{pars}{ - optional character vector naming the ordinary parameters to be estimated. - Every parameter named in \code{pars} must have a positive random-walk standard deviation specified in \code{rw.sd}. - Leaving \code{pars} unspecified is equivalent to setting it equal to the names of all parameters with a positive value of \code{rw.sd}. + \item{proposal}{ + optional function that draws from the proposal distribution. + Currently, the proposal distribution must be symmetric for proper inference: + it is the user's responsibility to ensure that it is. + Several functions that construct appropriate proposal function are provided: + see \link{MCMC proposal functions} for more information. } - \item{rw.sd}{ - numeric vector with names; used to parameterize a Gaussian random walk MCMC proposal. The random walk is only applied to parameters named in \code{pars}. The algorithm requires that the random walk be nontrivial, so each element in \code{rw.sd[pars]} must be positive. - The following must be satisfied: - \code{names(rw.sd)} must be a subset of \code{names(start)}, - \code{rw.sd} must be non-negative (zeros are simply ignored), - the name of every positive element of \code{rw.sd} must be in \code{pars}. - } + \item{pars, rw.sd}{Deprecated. Will be removed in a future release.} \item{Np}{ a positive integer; the number of particles to use in each filtering operation. Modified: pkg/pomp/tests/ou2-pmcmc.R =================================================================== --- pkg/pomp/tests/ou2-pmcmc.R 2015-02-22 19:43:12 UTC (rev 1085) +++ pkg/pomp/tests/ou2-pmcmc.R 2015-02-22 19:43:18 UTC (rev 1086) @@ -12,7 +12,7 @@ f1 <- pmcmc( pomp(ou2,dprior=dprior.ou2), Nmcmc=20, - rw.sd=c(alpha.2=0.001,alpha.3=0.001), + proposal=mvn.diag.rw(c(alpha.2=0.001,alpha.3=0.001)), Np=100, max.fail=100, verbose=FALSE @@ -55,7 +55,7 @@ } ), Nmcmc=20, - rw.sd=c(alpha.2=0.001,alpha.3=0.001), + proposal=mvn.diag.rw(c(alpha.2=0.001,alpha.3=0.001)), Np=100, max.fail=100, verbose=FALSE Modified: pkg/pomp/tests/ou2-pmcmc.Rout.save =================================================================== --- pkg/pomp/tests/ou2-pmcmc.Rout.save 2015-02-22 19:43:12 UTC (rev 1085) +++ pkg/pomp/tests/ou2-pmcmc.Rout.save 2015-02-22 19:43:18 UTC (rev 1086) @@ -33,7 +33,7 @@ > f1 <- pmcmc( + pomp(ou2,dprior=dprior.ou2), + Nmcmc=20, -+ rw.sd=c(alpha.2=0.001,alpha.3=0.001), ++ proposal=mvn.diag.rw(c(alpha.2=0.001,alpha.3=0.001)), + Np=100, + max.fail=100, + verbose=FALSE @@ -49,6 +49,8 @@ + max.fail=100, + verbose=FALSE + ) +Warning message: +pmcmc warning: 'rw.sd' is a deprecated argument.Use 'proposal' instead. > > f3 <- pmcmc(f2) > f4 <- continue(f3,Nmcmc=20) @@ -78,7 +80,7 @@ + } + ), + Nmcmc=20, -+ rw.sd=c(alpha.2=0.001,alpha.3=0.001), ++ proposal=mvn.diag.rw(c(alpha.2=0.001,alpha.3=0.001)), + Np=100, + max.fail=100, + verbose=FALSE @@ -114,4 +116,4 @@ > > proc.time() user system elapsed - 24.125 0.068 24.493 + 28.001 0.048 28.080 From noreply at r-forge.r-project.org Sun Feb 22 20:43:23 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 22 Feb 2015 20:43:23 +0100 (CET) Subject: [Pomp-commits] r1087 - pkg/pomp/R Message-ID: <20150222194324.06588185570@r-forge.r-project.org> Author: kingaa Date: 2015-02-22 20:43:23 +0100 (Sun, 22 Feb 2015) New Revision: 1087 Modified: pkg/pomp/R/pmcmc-methods.R pkg/pomp/R/pmcmc.R Log: - return 'pars' slot to pmcmc object Modified: pkg/pomp/R/pmcmc-methods.R =================================================================== --- pkg/pomp/R/pmcmc-methods.R 2015-02-22 19:43:18 UTC (rev 1086) +++ pkg/pomp/R/pmcmc-methods.R 2015-02-22 19:43:23 UTC (rev 1087) @@ -127,8 +127,7 @@ mar.multi <- c(0,5.1,0,2.1) oma.multi <- c(6,0,5,0) xx <- z[[1]] - estnames <- apply(xx at conv.rec,2,function(x)diff(range(x))>0) - estnames <- names(estnames[estnames]) + estnames <- xx at pars ## plot pmcmc convergence diagnostics other.diagnostics <- c("loglik", "log.prior","nfail") Modified: pkg/pomp/R/pmcmc.R =================================================================== --- pkg/pomp/R/pmcmc.R 2015-02-22 19:43:18 UTC (rev 1086) +++ pkg/pomp/R/pmcmc.R 2015-02-22 19:43:23 UTC (rev 1087) @@ -3,12 +3,14 @@ 'pmcmc', contains='pfilterd.pomp', slots=c( + pars = 'character', Nmcmc = 'integer', proposal = 'function', conv.rec = 'array', log.prior = 'numeric' ), prototype=prototype( + pars = character(0), Nmcmc = 0L, proposal = function (...) stop("proposal not specified"), conv.rec=array(dim=c(0,0)), @@ -44,9 +46,9 @@ ## test proposal distribution theta <- try(proposal(start)) if (inherits(theta,"try-error")) - stop("pmcmc error: error in proposal function") + stop("pmcmc error: error in proposal function",call.=FALSE) if (is.null(names(theta)) || !is.numeric(theta)) - stop("pmcmc error: ",sQuote("proposal")," must return a named numeric vector") + stop("pmcmc error: ",sQuote("proposal")," must return a named numeric vector",call.=FALSE) ntimes <- length(time(object)) if (missing(Np)) @@ -164,10 +166,14 @@ } + pars <- apply(conv.rec,2,function(x)diff(range(x))>0) + pars <- names(pars[pars]) + new( "pmcmc", pfp, params=theta, + pars=pars, Nmcmc=Nmcmc, proposal=proposal, Np=Np, @@ -190,10 +196,12 @@ if (missing(Np)) stop("pmcmc error: ",sQuote("Np")," must be specified",call.=FALSE) + if (missing(proposal)) proposal <- NULL + if (!missing(rw.sd)) { warning("pmcmc warning: ",sQuote("rw.sd")," is a deprecated argument.", "Use ",sQuote("proposal")," instead.",call.=FALSE) - if (missing(proposal)) { + if (is.null(proposal)) { proposal <- mvn.diag.rw(rw.sd=rw.sd) } else { warning("pmcmc warning: since ",sQuote("proposal"), @@ -201,6 +209,9 @@ } } + if (is.null(proposal)) + stop("pmcmc error: ",sQuote("proposal")," must be specified",call.=FALSE) + if (!missing(pars)) warning("pmcmc warning: ",sQuote("pars")," is a deprecated argument and will be ignored.",call.=FALSE) From noreply at r-forge.r-project.org Sun Feb 22 20:43:32 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 22 Feb 2015 20:43:32 +0100 (CET) Subject: [Pomp-commits] r1088 - in pkg/pomp: R inst man tests Message-ID: <20150222194332.B8776185570@r-forge.r-project.org> Author: kingaa Date: 2015-02-22 20:43:32 +0100 (Sun, 22 Feb 2015) New Revision: 1088 Modified: pkg/pomp/R/abc.R pkg/pomp/inst/NEWS pkg/pomp/inst/NEWS.Rd pkg/pomp/man/abc.Rd pkg/pomp/tests/ou2-abc.R pkg/pomp/tests/ou2-abc.Rout.save Log: - new 'proposal' argument to 'abc' - 'rw.sd' argument is obviated and deprecated - 'pars' argument is deprecated and ignored Modified: pkg/pomp/R/abc.R =================================================================== --- pkg/pomp/R/abc.R 2015-02-22 19:43:23 UTC (rev 1087) +++ pkg/pomp/R/abc.R 2015-02-22 19:43:32 UTC (rev 1088) @@ -8,14 +8,22 @@ probes='list', scale = 'numeric', epsilon = 'numeric', - random.walk.sd = 'numeric', + proposal = 'function', conv.rec = 'matrix' + ), + prototype=prototype( + pars = character(0), + Nabc = 0L, + probes = list(), + scale = numeric(0), + epsilon = 1.0, + proposal = function (...) stop("proposal not specified"), + conv.rec=array(dim=c(0,0)) ) ) abc.internal <- function (object, Nabc, - start, pars, - rw.sd, probes, + start, proposal, probes, epsilon, scale, verbose, .ndone = 0L, @@ -39,46 +47,16 @@ if (is.null(start.names)) stop("abc error: ",sQuote("start")," must be a named vector",call.=FALSE) - if (missing(rw.sd)) - stop("abc error: ",sQuote("rw.sd")," must be specified",call.=FALSE) - rw.names <- names(rw.sd) - if (is.null(rw.names) || any(rw.sd<0)) - stop("abc error: ",sQuote("rw.sd")," must be a named non-negative numerical vector",call.=FALSE) - if (!all(rw.names%in%start.names)) - stop("abc error: all the names of ",sQuote("rw.sd")," must be names of ",sQuote("start"),call.=FALSE) - rw.names <- names(rw.sd[rw.sd>0]) - if (length(rw.names) == 0) - stop("abc error: ",sQuote("rw.sd")," must have one positive entry for each parameter to be estimated",call.=FALSE) + if (!is.function(proposal)) + stop(sQuote("proposal")," must be a function") - if ( - !is.character(pars) || - !all(pars%in%start.names) || - !all(pars%in%rw.names) - ) - stop( - "abc error: ", - sQuote("pars"), - " must be a subset of ", - sQuote("names(start)"), - " and must correspond to positive random-walk SDs specified in ", - sQuote("rw.sd"), - call.=FALSE - ) + ## test proposal distribution + theta <- try(proposal(start)) + if (inherits(theta,"try-error")) + stop("abc error: error in proposal function",call.=FALSE) + if (is.null(names(theta)) || !is.numeric(theta)) + stop("abc error: ",sQuote("proposal")," must return a named numeric vector",call.=FALSE) - if (!all(rw.names%in%pars)) { - extra.rws <- rw.names[!(rw.names%in%pars)] - warning( - "abc warning: the variable(s) ", - paste(extra.rws,collapse=", "), - " have positive random-walk SDs specified, but are not included in ", - sQuote("pars"), - ". These random walk SDs are ignored.", - call.=FALSE - ) - } - rw.sd <- rw.sd[pars] - rw.names <- names(rw.sd) - if (!is.list(probes)) probes <- list(probes) if (!all(sapply(probes,is.function))) stop(sQuote("probes")," must be a function or a list of functions") @@ -88,10 +66,7 @@ ntimes <- length(time(object)) if (verbose) { - cat("performing",Nabc,"ABC iteration(s) to estimate parameter(s)", - paste(pars,collapse=", ")) - cat(" using random-walk with SD\n") - print(rw.sd) + cat("performing",Nabc,"ABC iteration(s)\n") } theta <- start @@ -113,18 +88,6 @@ ) ) - if (!all(is.finite(theta[pars]))) { - stop( - sQuote("abc"), - " error: cannot estimate non-finite parameters: ", - paste( - pars[!is.finite(theta[pars])], - collapse="," - ), - call.=FALSE - ) - } - ## apply probes to data datval <- try(.Call(apply_probe_data,object,probes),silent=FALSE) if (inherits(datval,'try-error')) @@ -134,8 +97,7 @@ for (n in seq_len(Nabc)) { # main loop - theta.prop <- theta - theta.prop[pars] <- rnorm(n=length(pars),mean=theta[pars],sd=rw.sd) + theta.prop <- proposal(theta) log.prior.prop <- dprior(object,params=theta.prop,log=TRUE) if (is.finite(log.prior.prop) && @@ -175,6 +137,9 @@ } + pars <- apply(conv.rec,2,function(x)diff(range(x))>0) + pars <- names(pars[pars]) + new( 'abc', object, @@ -184,7 +149,7 @@ probes=probes, scale=scale, epsilon=epsilon, - random.walk.sd=rw.sd, + proposal=proposal, conv.rec=conv.rec ) @@ -194,7 +159,7 @@ "abc", signature=signature(object="pomp"), function (object, Nabc = 1, - start, pars, rw.sd, + start, proposal, pars, rw.sd, probes, scale, epsilon, verbose = getOption("verbose"), ...) { @@ -202,13 +167,25 @@ if (missing(start)) start <- coef(object) - if (missing(rw.sd)) - stop("abc error: ",sQuote("rw.sd")," must be specified", - call.=FALSE) + if (missing(proposal)) proposal <- NULL - if (missing(pars)) - pars <- names(rw.sd)[rw.sd>0] + if (!missing(rw.sd)) { + warning("abc warning: ",sQuote("rw.sd")," is a deprecated argument: ", + "Use ",sQuote("proposal")," instead.",call.=FALSE) + if (is.null(proposal)) { + proposal <- mvn.diag.rw(rw.sd=rw.sd) + } else { + warning("abc warning: since ",sQuote("proposal"), + " has been specified, ",sQuote("rw.sd")," is ignored.") + } + } + if (is.null(proposal)) + stop("abc error: ",sQuote("proposal")," must be specified",call.=FALSE) + + if (!missing(pars)) + warning("abc warning: ",sQuote("pars")," is a deprecated argument and will be ignored.",call.=FALSE) + if (missing(probes)) stop("abc error: ",sQuote("probes")," must be specified", call.=FALSE) @@ -225,11 +202,10 @@ object=object, Nabc=Nabc, start=start, - pars=pars, + proposal=proposal, probes=probes, scale=scale, epsilon=epsilon, - rw.sd=rw.sd, verbose=verbose ) } @@ -256,15 +232,14 @@ "abc", signature=signature(object="abc"), function (object, Nabc, - start, pars, rw.sd, + start, proposal, probes, scale, epsilon, verbose = getOption("verbose"), ...) { if (missing(Nabc)) Nabc <- object at Nabc if (missing(start)) start <- coef(object) - if (missing(pars)) pars <- object at pars - if (missing(rw.sd)) rw.sd <- object at random.walk.sd + if (missing(proposal)) proposal <- object at proposal if (missing(probes)) probes <- object at probes if (missing(scale)) scale <- object at scale if (missing(epsilon)) epsilon <- object at epsilon @@ -275,8 +250,7 @@ object=object, Nabc=Nabc, start=start, - pars=pars, - rw.sd=rw.sd, + proposal=proposal, probes=probes, scale=scale, epsilon=epsilon, Modified: pkg/pomp/inst/NEWS =================================================================== --- pkg/pomp/inst/NEWS 2015-02-22 19:43:23 UTC (rev 1087) +++ pkg/pomp/inst/NEWS 2015-02-22 19:43:32 UTC (rev 1088) @@ -1,5 +1,28 @@ _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 _0._6_0-_1: + + ? ?pmcmc? and ?abc? can now use arbitrary symmetric proposal + distributions via the ?proposal? argument. For the moment, + these are constrained to be symmetric. Two new functions, + ?mvn.diag.rw? and ?mvn.rw? generate suitable proposal + functions. The first generates a multivariate normal + random-walk proposal with diagonal variance-covariance + matrix; this duplicates the old behavior of both ?abc? and + ?pmcmc?. The second, ?mvn.rw?, corresponds to a multivariate + normal random-walk proposal with arbitrary + variance-covariance matrix. + + ? In ?pmcmc? and ?abc?, the arguments ?pars? and ?rw.sd? are + now unneeded and have been deprecated. Use of ?rw.sd? will + generate a warning and result in behavior equivalent to + choosing ?proposal=mvn.diag.rw(rw.sd)?. Use of ?pars? will + be ignored, with a warning. + + ? In ?nlf?, the ?transform.params? argument is now deprecated; + use instead the ?transform? argument, as in the other + inference methods. + _C_h_a_n_g_e_s _i_n '_p_o_m_p' _v_e_r_s_i_o_n _0._5_9-_1: ? A bug in ?spect.match? has been fixed. Thanks to Karsten Modified: pkg/pomp/inst/NEWS.Rd =================================================================== --- pkg/pomp/inst/NEWS.Rd 2015-02-22 19:43:23 UTC (rev 1087) +++ pkg/pomp/inst/NEWS.Rd 2015-02-22 19:43:32 UTC (rev 1088) @@ -1,5 +1,19 @@ \name{NEWS} \title{News for package `pomp'} +\section{Changes in \pkg{pomp} version 0.60-1}{ + \itemize{ + \item \code{pmcmc} and \code{abc} can now use arbitrary symmetric proposal distributions via the \code{proposal} argument. + For the moment, these are constrained to be symmetric. + Two new functions, \code{mvn.diag.rw} and \code{mvn.rw} generate suitable proposal functions. + The first generates a multivariate normal random-walk proposal with diagonal variance-covariance matrix; this duplicates the old behavior of both \code{abc} and \code{pmcmc}. + The second, \code{mvn.rw}, corresponds to a multivariate normal random-walk proposal with arbitrary variance-covariance matrix. + \item In \code{pmcmc} and \code{abc}, the arguments \code{pars} and \code{rw.sd} are now unneeded and have been deprecated. + Use of \code{rw.sd} will generate a warning and result in behavior equivalent to choosing \code{proposal=mvn.diag.rw(rw.sd)}. + Use of \code{pars} will be ignored, with a warning. + \item In \code{nlf}, the \code{transform.params} argument is now deprecated; + use instead the \code{transform} argument, as in the other inference methods. + } +} \section{Changes in \pkg{pomp} version 0.59-1}{ \itemize{ \item A bug in \code{spect.match} has been fixed. Modified: pkg/pomp/man/abc.Rd =================================================================== --- pkg/pomp/man/abc.Rd 2015-02-22 19:43:23 UTC (rev 1087) +++ pkg/pomp/man/abc.Rd 2015-02-22 19:43:32 UTC (rev 1088) @@ -16,13 +16,13 @@ The approximate Bayesian computation (ABC) algorithm for estimating the parameters of a partially-observed Markov process. } \usage{ -\S4method{abc}{pomp}(object, Nabc = 1, start, pars, - rw.sd, probes, scale, epsilon, +\S4method{abc}{pomp}(object, Nabc = 1, start, proposal, + pars, rw.sd, probes, scale, epsilon, verbose = getOption("verbose"), \dots) \S4method{abc}{probed.pomp}(object, probes, verbose = getOption("verbose"), \dots) -\S4method{abc}{abc}(object, Nabc, start, pars, - rw.sd, probes, scale, epsilon, +\S4method{abc}{abc}(object, Nabc, start, proposal, + probes, scale, epsilon, verbose = getOption("verbose"), \dots) \S4method{continue}{abc}(object, Nabc = 1, \dots) } @@ -37,27 +37,27 @@ named numeric vector; the starting guess of the parameters. } - \item{pars}{ - optional character vector naming the ordinary parameters to be estimated. - Every parameter named in \code{pars} must have a positive random-walk standard deviation specified in \code{rw.sd}. - Leaving \code{pars} unspecified is equivalent to setting it equal to the names of all parameters with a positive value of \code{rw.sd}. + \item{proposal}{ + optional function that draws from the proposal distribution. + Currently, the proposal distribution must be symmetric for proper inference: + it is the user's responsibility to ensure that it is. + Several functions that construct appropriate proposal function are provided: + see \link{MCMC proposal functions} for more information. } + \item{pars}{Deprecated and ignored. Will be removed in a future release.} \item{rw.sd}{ - numeric vector with names; used to parameterize a Gaussian random walk MCMC proposal. - The random walk is only applied to parameters named in \code{pars}. - The algorithm requires that the random walk be nontrivial, so each element in \code{rw.sd[pars]} must be positive. - The following must be satisfied: - \code{names(rw.sd)} must be a subset of \code{names(start)}, - \code{rw.sd} must be non-negative (zeros are simply ignored), - the name of every positive element of \code{rw.sd} must be in \code{pars}. + Deprecated. Will be removed in a future release. + Specifying \code{rw.sd} is equivalent to setting \code{proposal=mvn.diag.rw(rw.sd)}. } \item{probes}{ + List of probes (AKA summary statistics). + See \code{\link{probe}} for details. } \item{scale}{ - + named numeric vector of scales. } \item{epsilon}{ - + ABC tolerance. } \item{verbose}{ logical; if TRUE, print progress reports. @@ -74,11 +74,6 @@ \item{pars, Nabc, dprior, hyperparams, scale, epsilon}{ These slots hold the values of the corresponding arguments of the call to \code{abc}. } - \item{random.walk.sd}{ - a named numeric vector containing the random-walk variances used to parameterize a Gaussian random walk MCMC proposal. - } - \item{probes, conv.rec}{ - } } } \section{Re-running ABC Iterations}{ Modified: pkg/pomp/tests/ou2-abc.R =================================================================== --- pkg/pomp/tests/ou2-abc.R 2015-02-22 19:43:23 UTC (rev 1087) +++ pkg/pomp/tests/ou2-abc.R 2015-02-22 19:43:32 UTC (rev 1088) @@ -25,11 +25,10 @@ abc1 <- abc(po, Nabc=10000, start=coef(ou2), - pars=c("alpha.1","alpha.2"), probes=probes.good, scale=scale.dat, epsilon=1.7, - rw.sd= c(alpha.1=0.01,alpha.2=0.01) + proposal=mvn.diag.rw(rw.sd=c(alpha.1=0.01,alpha.2=0.01)) ) plot(abc1,scatter=TRUE) @@ -42,11 +41,10 @@ abc2 <- abc(po, Nabc=2000, - pars=c("alpha.1","alpha.2"), probes=probes.good, scale=scale.dat, epsilon=1, - rw.sd= c(alpha.1=0.01,alpha.2=0.01) + proposal=mvn.diag.rw(c(alpha.1=0.01,alpha.2=0.01)) ) plot(abc2) @@ -55,16 +53,21 @@ probes=probes.good, scale=scale.dat, epsilon=2, - rw.sd= c(alpha.1=0.01,alpha.2=0.01) + rw.sd=c(alpha.1=0.01,alpha.2=0.01) ) abc3 <- continue(abc3,Nabc=3000) plot(abc3) +sig <- matrix(c(0.01,0.005,0.005,0.01), + 2,2, + dimnames=list(c("alpha.1","alpha.2"), + c("alpha.1","alpha.2"))) + abc4 <- abc(probe(po,probes=probes.good,nsim=200), Nabc=2000, scale=scale.dat, epsilon=2, - rw.sd= c(alpha.1=0.01,alpha.2=0.01) + proposal=mvn.rw(sig) ) plot(abc4) @@ -89,7 +92,7 @@ probes=probes.good, scale=scale.dat, epsilon=1, - rw.sd= c(alpha.1=0.01,alpha.2=0.01) + proposal=mvn.diag.rw(c(alpha.1=0.01,alpha.2=0.01)) ) plot(abc6) Modified: pkg/pomp/tests/ou2-abc.Rout.save =================================================================== --- pkg/pomp/tests/ou2-abc.Rout.save 2015-02-22 19:43:23 UTC (rev 1087) +++ pkg/pomp/tests/ou2-abc.Rout.save 2015-02-22 19:43:32 UTC (rev 1088) @@ -46,11 +46,10 @@ > abc1 <- abc(po, + Nabc=10000, + start=coef(ou2), -+ pars=c("alpha.1","alpha.2"), + probes=probes.good, + scale=scale.dat, + epsilon=1.7, -+ rw.sd= c(alpha.1=0.01,alpha.2=0.01) ++ proposal=mvn.diag.rw(rw.sd=c(alpha.1=0.01,alpha.2=0.01)) + ) > > plot(abc1,scatter=TRUE) @@ -60,15 +59,14 @@ > runs <- rle(as.vector(conv.rec(abc1)[, "alpha.1"])) > hist(runs$lengths) > mean(runs$length) -[1] 6.949965 +[1] 13.81354 > > abc2 <- abc(po, + Nabc=2000, -+ pars=c("alpha.1","alpha.2"), + probes=probes.good, + scale=scale.dat, + epsilon=1, -+ rw.sd= c(alpha.1=0.01,alpha.2=0.01) ++ proposal=mvn.diag.rw(c(alpha.1=0.01,alpha.2=0.01)) + ) > plot(abc2) > @@ -77,16 +75,23 @@ + probes=probes.good, + scale=scale.dat, + epsilon=2, -+ rw.sd= c(alpha.1=0.01,alpha.2=0.01) ++ rw.sd=c(alpha.1=0.01,alpha.2=0.01) + ) +Warning message: +abc warning: 'rw.sd' is a deprecated argument: Use 'proposal' instead. > abc3 <- continue(abc3,Nabc=3000) > plot(abc3) > +> sig <- matrix(c(0.01,0.005,0.005,0.01), ++ 2,2, ++ dimnames=list(c("alpha.1","alpha.2"), ++ c("alpha.1","alpha.2"))) +> > abc4 <- abc(probe(po,probes=probes.good,nsim=200), + Nabc=2000, + scale=scale.dat, + epsilon=2, -+ rw.sd= c(alpha.1=0.01,alpha.2=0.01) ++ proposal=mvn.rw(sig) + ) > plot(abc4) > @@ -111,8 +116,10 @@ + probes=probes.good, + scale=scale.dat, + epsilon=1, -+ rw.sd= c(alpha.1=0.01,alpha.2=0.01) ++ proposal=mvn.diag.rw(c(alpha.1=0.01,alpha.2=0.01)) + ) +Warning message: +abc warning: 'pars' is a deprecated argument and will be ignored. > plot(abc6) > > try(abc7 <- c(abc2,abc3)) @@ -131,4 +138,4 @@ > > proc.time() user system elapsed - 9.612 0.100 9.906 + 12.322 0.033 12.359 From noreply at r-forge.r-project.org Sun Feb 22 20:43:39 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 22 Feb 2015 20:43:39 +0100 (CET) Subject: [Pomp-commits] r1089 - pkg/pomp/tests Message-ID: <20150222194339.B8B25185570@r-forge.r-project.org> Author: kingaa Date: 2015-02-22 20:43:39 +0100 (Sun, 22 Feb 2015) New Revision: 1089 Modified: pkg/pomp/tests/ou2-abc.R pkg/pomp/tests/ou2-abc.Rout.save pkg/pomp/tests/ou2-pmcmc.R pkg/pomp/tests/ou2-pmcmc.Rout.save Log: - update tests Modified: pkg/pomp/tests/ou2-abc.R =================================================================== --- pkg/pomp/tests/ou2-abc.R 2015-02-22 19:43:32 UTC (rev 1088) +++ pkg/pomp/tests/ou2-abc.R 2015-02-22 19:43:39 UTC (rev 1089) @@ -58,10 +58,11 @@ abc3 <- continue(abc3,Nabc=3000) plot(abc3) -sig <- matrix(c(0.01,0.005,0.005,0.01), - 2,2, - dimnames=list(c("alpha.1","alpha.2"), - c("alpha.1","alpha.2"))) +sig <- array(data=c(0.1,0.02,0,0.1), + dim=c(2,2), + dimnames=list(c("alpha.1","alpha.2"), + c("alpha.1","alpha.2"))) +sig <- crossprod(sig) abc4 <- abc(probe(po,probes=probes.good,nsim=200), Nabc=2000, Modified: pkg/pomp/tests/ou2-abc.Rout.save =================================================================== --- pkg/pomp/tests/ou2-abc.Rout.save 2015-02-22 19:43:32 UTC (rev 1088) +++ pkg/pomp/tests/ou2-abc.Rout.save 2015-02-22 19:43:39 UTC (rev 1089) @@ -82,10 +82,11 @@ > abc3 <- continue(abc3,Nabc=3000) > plot(abc3) > -> sig <- matrix(c(0.01,0.005,0.005,0.01), -+ 2,2, -+ dimnames=list(c("alpha.1","alpha.2"), -+ c("alpha.1","alpha.2"))) +> sig <- array(data=c(0.1,0.02,0,0.1), ++ dim=c(2,2), ++ dimnames=list(c("alpha.1","alpha.2"), ++ c("alpha.1","alpha.2"))) +> sig <- crossprod(sig) > > abc4 <- abc(probe(po,probes=probes.good,nsim=200), + Nabc=2000, @@ -138,4 +139,4 @@ > > proc.time() user system elapsed - 12.322 0.033 12.359 + 11.422 0.073 11.497 Modified: pkg/pomp/tests/ou2-pmcmc.R =================================================================== --- pkg/pomp/tests/ou2-pmcmc.R 2015-02-22 19:43:32 UTC (rev 1088) +++ pkg/pomp/tests/ou2-pmcmc.R 2015-02-22 19:43:39 UTC (rev 1089) @@ -80,5 +80,27 @@ plot(window(conv.rec(ff[2:3],c("alpha.3")),thin=3,start=2)) plot(conv.rec(ff[[3]],c("alpha.3"))) +sig <- array(data=c(0.1,-0.1,0,0.01), + dim=c(2,2), + dimnames=list( + c("alpha.2","alpha.3"), + c("alpha.2","alpha.3"))) +sig <- crossprod(sig) + +f7 <- pmcmc( + pomp(ou2, + dprior=function (params, log, ...) { + f <- sum(dnorm(params,mean=coef(ou2),sd=1,log=TRUE)) + if (log) f else exp(f) + } + ), + Nmcmc=30, + proposal=mvn.rw(sig), + Np=100, + max.fail=100, + verbose=FALSE + ) +plot(f7) + dev.off() Modified: pkg/pomp/tests/ou2-pmcmc.Rout.save =================================================================== --- pkg/pomp/tests/ou2-pmcmc.Rout.save 2015-02-22 19:43:32 UTC (rev 1088) +++ pkg/pomp/tests/ou2-pmcmc.Rout.save 2015-02-22 19:43:39 UTC (rev 1089) @@ -109,6 +109,28 @@ > plot(window(conv.rec(ff[2:3],c("alpha.3")),thin=3,start=2)) > plot(conv.rec(ff[[3]],c("alpha.3"))) > +> sig <- array(data=c(0.1,-0.1,0,0.01), ++ dim=c(2,2), ++ dimnames=list( ++ c("alpha.2","alpha.3"), ++ c("alpha.2","alpha.3"))) +> sig <- crossprod(sig) +> +> f7 <- pmcmc( ++ pomp(ou2, ++ dprior=function (params, log, ...) { ++ f <- sum(dnorm(params,mean=coef(ou2),sd=1,log=TRUE)) ++ if (log) f else exp(f) ++ } ++ ), ++ Nmcmc=30, ++ proposal=mvn.rw(sig), ++ Np=100, ++ max.fail=100, ++ verbose=FALSE ++ ) +> plot(f7) +> > dev.off() null device 1 @@ -116,4 +138,4 @@ > > proc.time() user system elapsed - 28.001 0.048 28.080 + 28.662 0.057 28.743 From noreply at r-forge.r-project.org Sun Feb 22 23:49:30 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 22 Feb 2015 23:49:30 +0100 (CET) Subject: [Pomp-commits] r1090 - in pkg/pomp: . R Message-ID: <20150222224930.C1E27187549@r-forge.r-project.org> Author: kingaa Date: 2015-02-22 23:49:30 +0100 (Sun, 22 Feb 2015) New Revision: 1090 Modified: pkg/pomp/DESCRIPTION pkg/pomp/NAMESPACE pkg/pomp/R/mif-methods.R pkg/pomp/R/pmcmc-methods.R Log: - remove deprecated 'compare.mif' and 'compare.pmcmc' methods - make package Description conform to standard. - register S3 method 'as.data.frame' for 'pomp' and 'pfilterd.pomp' objects Modified: pkg/pomp/DESCRIPTION =================================================================== --- pkg/pomp/DESCRIPTION 2015-02-22 19:43:39 UTC (rev 1089) +++ pkg/pomp/DESCRIPTION 2015-02-22 22:49:30 UTC (rev 1090) @@ -17,7 +17,7 @@ person(given=c("Simon","N."),family="Wood",role=c("ctb")) ) URL: http://pomp.r-forge.r-project.org -Description: Inference methods for partially observed Markov processes (AKA stochastic dynamical systems, state-space models) +Description: Inference methods for partially observed Markov processes (AKA stochastic dynamical systems, state-space models). Depends: R(>= 3.0.0), methods, subplex, nloptr Imports: stats, graphics, mvtnorm, deSolve, coda License: GPL(>= 2) Modified: pkg/pomp/NAMESPACE =================================================================== --- pkg/pomp/NAMESPACE 2015-02-22 19:43:39 UTC (rev 1089) +++ pkg/pomp/NAMESPACE 2015-02-22 22:49:30 UTC (rev 1090) @@ -73,9 +73,10 @@ traj.match ) +S3method(as.data.frame,pomp) +S3method(as.data.frame,pfilterd.pomp) + export( - as.data.frame.pomp, - as.data.frame.pfilterd.pomp, Csnippet, reulermultinom, deulermultinom, @@ -92,7 +93,6 @@ profileDesign, bspline.basis, periodic.bspline.basis, - compare.mif, parmat, logmeanexp, probe.mean, Modified: pkg/pomp/R/mif-methods.R =================================================================== --- pkg/pomp/R/mif-methods.R 2015-02-22 19:43:39 UTC (rev 1089) +++ pkg/pomp/R/mif-methods.R 2015-02-22 22:49:30 UTC (rev 1090) @@ -208,11 +208,6 @@ } } -compare.mif <- function (z) { - stop(sQuote("compare.mif")," has been deprecated in favor of ", - sQuote("plot")) -} - mif.diagnostics <- function (z) { ## assumes that z is a list of mifs with identical structure mar.multi <- c(0,5.1,0,2.1) Modified: pkg/pomp/R/pmcmc-methods.R =================================================================== --- pkg/pomp/R/pmcmc-methods.R 2015-02-22 19:43:39 UTC (rev 1089) +++ pkg/pomp/R/pmcmc-methods.R 2015-02-22 22:49:30 UTC (rev 1090) @@ -167,13 +167,3 @@ } invisible(NULL) } - -compare.pmcmc <- function (z) { - if (!is.list(z)) z <- list(z) - if (!all(sapply(z,function(x)is(x,'pmcmc')))) - stop("compare.pmcmc error: ",sQuote("z"), - " must be a pmcmc object or a list of pmcmc objects",call.=FALSE) - warning(sQuote("compare.pmcmc")," is deprecated.\n", - "Use ",sQuote("diagnostics")," instead.",call.=FALSE) - pmcmc.diagnostics(z) -} From noreply at r-forge.r-project.org Sun Feb 22 23:49:40 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 22 Feb 2015 23:49:40 +0100 (CET) Subject: [Pomp-commits] r1091 - in pkg/pomp: . R Message-ID: <20150222224940.C3086187549@r-forge.r-project.org> Author: kingaa Date: 2015-02-22 23:49:40 +0100 (Sun, 22 Feb 2015) New Revision: 1091 Modified: pkg/pomp/NAMESPACE pkg/pomp/R/probe.R Log: - add new S3 method: 'as.data.frame' for 'probed.pomp' objects Modified: pkg/pomp/NAMESPACE =================================================================== --- pkg/pomp/NAMESPACE 2015-02-22 22:49:30 UTC (rev 1090) +++ pkg/pomp/NAMESPACE 2015-02-22 22:49:40 UTC (rev 1091) @@ -75,6 +75,7 @@ S3method(as.data.frame,pomp) S3method(as.data.frame,pfilterd.pomp) +S3method(as.data.frame,probed.pomp) export( Csnippet, Modified: pkg/pomp/R/probe.R =================================================================== --- pkg/pomp/R/probe.R 2015-02-22 22:49:30 UTC (rev 1090) +++ pkg/pomp/R/probe.R 2015-02-22 22:49:40 UTC (rev 1091) @@ -206,6 +206,8 @@ } ) +as.data.frame.probed.pomp <- function (x, row.names, optional, ...) as(x,"data.frame") + setMethod("logLik",signature(object="probed.pomp"),function(object,...)object at synth.loglik) setMethod("$",signature=signature(x="probed.pomp"),function(x, name)slot(x,name)) From noreply at r-forge.r-project.org Mon Feb 23 15:05:48 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 23 Feb 2015 15:05:48 +0100 (CET) Subject: [Pomp-commits] r1092 - in www: content vignettes Message-ID: <20150223140548.E23E11876D6@r-forge.r-project.org> Author: kingaa Date: 2015-02-23 15:05:48 +0100 (Mon, 23 Feb 2015) New Revision: 1092 Modified: www/content/NEWS.html www/vignettes/advanced_topics_in_pomp.R www/vignettes/advanced_topics_in_pomp.pdf www/vignettes/bsmc-ricker-flat-prior.rda www/vignettes/bsmc-ricker-normal-prior.rda www/vignettes/gompertz-multi-mif.rda www/vignettes/gompertz-performance.rda www/vignettes/gompertz-pfilter-guess.rda www/vignettes/gompertz-trajmatch.rda www/vignettes/intro_to_pomp.R www/vignettes/intro_to_pomp.Rnw www/vignettes/intro_to_pomp.pdf www/vignettes/nlf-block-boot.rda www/vignettes/nlf-boot.rda www/vignettes/nlf-fit-from-truth.rda www/vignettes/nlf-fits.rda www/vignettes/nlf-lag-tests.rda www/vignettes/nlf-multi-short.rda www/vignettes/plugin-C-code.rda www/vignettes/plugin-R-code.rda www/vignettes/pomp.pdf www/vignettes/ricker-comparison.rda www/vignettes/ricker-first-probe.rda www/vignettes/ricker-mif.rda www/vignettes/ricker-probe-match.rda www/vignettes/ricker-probe.rda www/vignettes/vectorized-C-code.rda www/vignettes/vectorized-R-code.rda Log: - bring vignettes up to date Modified: www/content/NEWS.html =================================================================== --- www/content/NEWS.html 2015-02-22 22:49:40 UTC (rev 1091) +++ www/content/NEWS.html 2015-02-23 14:05:48 UTC (rev 1092) @@ -8,6 +8,82 @@

News for package ‘pomp’

+

Changes in pomp version 0.60-1

+ + + + + + +

Changes in pomp version 0.59-1

+ + + + + + +

Changes in pomp version 0.58-1

+ + + + + + +

Changes in pomp version 0.58-1

+ + + + + + +

Changes in pomp version 0.57-1

+ + + + + + +

Changes in pomp version 0.56-1

+ + + + + +

Changes in pomp version 0.55-1

Modified: www/vignettes/advanced_topics_in_pomp.R =================================================================== --- www/vignettes/advanced_topics_in_pomp.R 2015-02-22 22:49:40 UTC (rev 1091) +++ www/vignettes/advanced_topics_in_pomp.R 2015-02-23 14:05:48 UTC (rev 1092) @@ -1,4 +1,3 @@ - ## ----include=FALSE------------------------------------------------------- opts_chunk$set( echo=TRUE,results='markup', @@ -18,12 +17,10 @@ ) - ## ----include=FALSE------------------------------------------------------- library(pomp) set.seed(5384959) - ## ----pomp-builder-measmod,eval=T----------------------------------------- ## negative binomial measurement model ## E[cases|incid] = rho*incid @@ -36,7 +33,6 @@ lik = dnbinom_mu(cases,theta,rho*incid,give_log); ' - ## ----pomp-builder-stepfn,eval=T------------------------------------------ ## SIR process model with extra-demographic stochasticity ## and seasonal transmission @@ -76,7 +72,6 @@ if (beta_sd > 0.0) W += (dW-dt)/beta_sd; // increment has mean = 0, variance = dt ' - ## ----pomp-builder-skel,eval=T-------------------------------------------- skel <- ' int nrate = 6; @@ -112,7 +107,6 @@ DW = 0; ' - ## ----pomp-builder-partrans,eval=T---------------------------------------- ## parameter transformations ## note we use barycentric coordinates for the initial conditions @@ -144,7 +138,6 @@ to_log_barycentric(&TS_0,&S_0,3); " - ## ----pomp-builder-covar,eval=T------------------------------------------- covartab <- data.frame( time=seq(from=-1/52,to=10+1/52,by=1/26) @@ -164,7 +157,6 @@ ) - ## ----pomp-builder,eval=F------------------------------------------------- ## pompBuilder( ## name="SIR", @@ -200,7 +192,6 @@ ## } ## ) -> sir - ## ----pomp-builder-eval,echo=F,eval=T,results='hide'---------------------- if (Sys.getenv("POMP_BUILD_VIGNETTES")=="yes") { require(pomp) @@ -239,7 +230,6 @@ ) -> sir } - ## ----sir-sim,eval=T------------------------------------------------------ coef(sir) <- c( gamma=26,mu=0.02,iota=0.01, @@ -253,11 +243,9 @@ sir <- simulate(sir,seed=3493885L) traj <- trajectory(sir,hmax=1/52) - ## ----sir-plot,fig=T,echo=F----------------------------------------------- plot(sir) - ## ------------------------------------------------------------------------ pompExample(ou2) true.p <- coef(ou2) @@ -267,20 +255,17 @@ new.p["x1.0",] <- 1:3 init.state(ou2,params=new.p) - ## ------------------------------------------------------------------------ x <- rprocess(ou2,xstart=x0,times=time(ou2,t0=T),params=true.p) dim(x) x[,,1:5] - ## ------------------------------------------------------------------------ x <- x[,,-1,drop=F] y <- rmeasure(ou2,x=x,times=time(ou2),params=true.p) dim(y) y[,,1:5] - ## ------------------------------------------------------------------------ fp <- dprocess(ou2,x=x,times=time(ou2),params=true.p) dim(fp) @@ -291,19 +276,15 @@ dim(fm) fm[,36:40] - ## ----all-examples,eval=F------------------------------------------------- ## pompExample() - ## ----example-sources,eval=F---------------------------------------------- ## list.files(system.file("examples",package="pomp")) - ## ----demos,eval=F-------------------------------------------------------- ## demo(package='pomp') - ## ----plugin-R-code,echo=T,eval=T----------------------------------------- pompExample(ou2) ou2.dat <- as.data.frame(ou2) @@ -343,7 +324,6 @@ save(etime.Rplug,n.Rplug,file=binary.file,compress='xz') } - ## ----vectorized-R-code,eval=F-------------------------------------------- ## ou2.Rvect.rprocess <- function (xstart, times, params, ...) { ## nrep <- ncol(xstart) # number of realizations @@ -378,11 +358,9 @@ ## x ## } - ## ----vectorized-R-pomp,eval=F-------------------------------------------- ## ou2.Rvect <- pomp(ou2.Rplug,rprocess=ou2.Rvect.rprocess) - ## ----theta,eval=F-------------------------------------------------------- ## theta <- c( ## x1.0=-3, x2.0=4, @@ -447,15 +425,12 @@ save(etime.Rvect,n.Rvect,file=binary.file,compress='xz') } - ## ----view-ou2-source,eval=F---------------------------------------------- ## file.show(file=system.file("examples/ou2.c",package="pomp")) - ## ----view-pomp.h,eval=F,results='hide'----------------------------------- ## file.show(file=system.file("include/pomp.h",package="pomp")) - ## ----plugin-C-code,eval=F------------------------------------------------ ## ou2.Cplug <- pomp( ## ou2.Rplug, @@ -498,11 +473,9 @@ save(n.Cplug,etime.Cplug,speedup,file=binary.file,compress='xz') } - ## ----eval=F,results='hide'----------------------------------------------- ## file.show(file=system.file("examples/ou2.c",package="pomp")) - ## ----vectorized-C-code--------------------------------------------------- ou2.Cvect.rprocess <- function (xstart, times, params, ...) { nvar <- nrow(xstart) @@ -522,7 +495,6 @@ ) } - ## ----vectorized-C-code-pomp---------------------------------------------- ou2.Cvect <- pomp( ou2.Rplug, @@ -555,4 +527,3 @@ save(n.Cvect,etime.Cvect,speedup,file=binary.file,compress='xz') } - Modified: www/vignettes/advanced_topics_in_pomp.pdf =================================================================== (Binary files differ) Modified: www/vignettes/bsmc-ricker-flat-prior.rda =================================================================== (Binary files differ) Modified: www/vignettes/bsmc-ricker-normal-prior.rda =================================================================== (Binary files differ) Modified: www/vignettes/gompertz-multi-mif.rda =================================================================== (Binary files differ) Modified: www/vignettes/gompertz-performance.rda =================================================================== (Binary files differ) Modified: www/vignettes/gompertz-pfilter-guess.rda =================================================================== (Binary files differ) Modified: www/vignettes/gompertz-trajmatch.rda =================================================================== (Binary files differ) Modified: www/vignettes/intro_to_pomp.R =================================================================== --- www/vignettes/intro_to_pomp.R 2015-02-22 22:49:40 UTC (rev 1091) +++ www/vignettes/intro_to_pomp.R 2015-02-23 14:05:48 UTC (rev 1092) @@ -1,4 +1,3 @@ - ## ----include=FALSE------------------------------------------------------- opts_chunk$set( echo=TRUE,results='markup', @@ -18,11 +17,9 @@ ) - ## ----set-opts,echo=F,results='hide'-------------------------------------- set.seed(5384959L) - ## ----gompertz-proc-sim-def----------------------------------------------- require(pomp) @@ -42,7 +39,6 @@ } - ## ----gompertz-meas-sim-def----------------------------------------------- gompertz.meas.sim <- function (x, t, params, ...) { ## unpack the parameters: @@ -55,7 +51,6 @@ } - ## ----first-pomp-construction,eval=F-------------------------------------- ## gompertz <- pomp( ## data=data.frame( @@ -72,11 +67,9 @@ ## ) ## - ## ----set-params---------------------------------------------------------- theta <- c(r=0.1,K=1,sigma=0.1,tau=0.1,X.0=1) - ## ----gompertz-first-simulation,eval=F------------------------------------ ## gompertz <- simulate(gompertz,params=theta) @@ -95,11 +88,9 @@ ) coef(gompertz) <- theta - ## ----gompertz-plot,echo=F------------------------------------------------ plot(gompertz,variables=c("Y")) - ## ----second-pomp-construction-------------------------------------------- gompertz.meas.dens <- function (y, x, t, params, log, ...) { ## unpack the parameters: @@ -118,7 +109,6 @@ dmeasure=gompertz.meas.dens ) - ## ----gompertz-pfilter-truth,eval=F--------------------------------------- ## pf <- pfilter(gompertz,params=theta,Np=1000) ## loglik.truth <- logLik(pf) @@ -130,15 +120,12 @@ loglik.truth <- logLik(pf) loglik.truth - ## ----gompertz-pfilter-truth-alt1,eval=F---------------------------------- ## pf <- pfilter(gompertz,params=coef(gompertz),Np=1000) - ## ----gompertz-pfilter-truth-alt2,eval=F---------------------------------- ## pf <- pfilter(gompertz,Np=1000) - ## ----gompertz-pfilter-guess,eval=F--------------------------------------- ## theta.true <- coef(gompertz) ## theta.guess <- theta.true @@ -160,7 +147,6 @@ save(theta.true,theta.guess,loglik.guess,file=binary.file,compress='xz') } - ## ----kalman-filter-def--------------------------------------------------- kalman.filter <- function (Y, X0, r, K, sigma, tau) { ntimes <- length(Y) @@ -192,7 +178,6 @@ ) } - ## ----kalman-filter-run--------------------------------------------------- y <- obs(gompertz) x0 <- init.state(gompertz) @@ -205,45 +190,36 @@ ## ----kalman-likelihood-correction,echo=F--------------------------------- loglik.kalman <- kf$loglik - ## ----eval=F-------------------------------------------------------------- ## as(gompertz,"data.frame") - ## ----eval=F-------------------------------------------------------------- ## obs(gompertz) ## obs(gompertz,"Y") ## time(gompertz) - ## ----eval=F-------------------------------------------------------------- ## time(gompertz) <- 1:10 - ## ----eval=F-------------------------------------------------------------- ## timezero(gompertz) ## timezero(gompertz) <- -10 - ## ----eval=F-------------------------------------------------------------- ## time(gompertz,t0=TRUE) ## time(gompertz,t0=T) <- seq(from=0,to=10,by=1) - ## ----eval=F-------------------------------------------------------------- ## window(gompertz,start=3,end=20) - ## ----eval=F-------------------------------------------------------------- ## coef(gompertz) ## coef(gompertz,c("sigma","tau")) <- c(1,0) - ## ----eval=F-------------------------------------------------------------- ## states(gompertz) ## states(gompertz,"X") - ## ----snippet-gomp-pomp,results='hide'------------------------------------ gomp2 <- pomp( data=subset(as(gompertz,"data.frame"),select=c(time,Y)), @@ -269,7 +245,6 @@ ) - ## ----gompertz-perform,eval=F,echo=T-------------------------------------- ## tic <- Sys.time() ## sim1 <- simulate(gompertz,nsim=1000,seed=5676868L,obs=TRUE) @@ -327,15 +302,12 @@ save(g1sim,g2sim,g1pf,g2pf,file=binary.file,compress='xz') } - ## ----eval=F-------------------------------------------------------------- ## demo(gompertz) - ## ----eval=F-------------------------------------------------------------- ## system.file("examples",package="pomp") - ## ----loggomp-pomp-construction,eval=T------------------------------------ gompertz <- pomp( gompertz, @@ -347,28 +319,22 @@ } ) - ## ----eval=T-------------------------------------------------------------- coef(gompertz) <- c(r=0.1,K=1,tau=0.1,sigma=0.1,X.0=1) - ## ----eval=T-------------------------------------------------------------- coef(gompertz) - ## ----eval=T-------------------------------------------------------------- coef(gompertz,transform=TRUE) <- c(r=log(0.1),K=0,tau=log(0.1), sigma=log(0.1),X.0=0) - ## ----eval=T-------------------------------------------------------------- coef(gompertz,transform=TRUE) - ## ----eval=T-------------------------------------------------------------- coef(gompertz) - ## ----par-trans-inverse-test,results='markup'----------------------------- # use parameter.inv.transform: theta <- coef(gompertz,transform=TRUE) @@ -380,7 +346,6 @@ all.equal(coef(gompertz),coef(g2)) - ## ----echo=F,results='hide'----------------------------------------------- pompExample(gompertz) theta <- coef(gompertz) @@ -418,7 +383,6 @@ ## list(mif=m1,ll=ll) ## } - ## ----gompertz-post-mif,eval=F,echo=F------------------------------------- ## theta.true <- coef(gompertz) ## loglik.true <- replicate(n=10,logLik(pfilter(gompertz,Np=10000))) @@ -429,7 +393,6 @@ ## theta.mif <- theta.mif[best,] ## loglik.mif <- loglik.mif[best,] - ## ----gompertz-multi-mif-eval,echo=F,results='hide'----------------------- binary.file <- "gompertz-multi-mif.rda" if (file.exists(binary.file)) { @@ -500,7 +463,6 @@ truth=c(signif(theta.true[estpars],3),loglik=round(loglik.true,2)) ) -> results.table - ## ----eval=F-------------------------------------------------------------- ## theta.true <- coef(gompertz) ## loglik.true <- replicate(n=10,logLik(pfilter(gompertz,Np=10000))) @@ -511,7 +473,6 @@ ## theta.mif <- theta.mif[best,] ## loglik.mif <- loglik.mif[best,] - ## ----multi-mif-plot,echo=F,eval=F---------------------------------------- ## op <- par(mfrow=c(4,1),mar=c(3,3,0,0),mgp=c(2,1,0),bty='l') ## loglik <- sapply(mf,function(x)conv.rec(x$mif,"loglik")) @@ -524,7 +485,6 @@ ## matplot(log.tau,type='l',lty=1,xlab="MIF iteration",ylab=expression(log~tau)) ## par(op) - ## ----mif-plot,echo=F----------------------------------------------------- op <- par(mfrow=c(4,1),mar=c(3,3,0,0),mgp=c(2,1,0),bty='l') loglik <- sapply(mf,function(x)conv.rec(x$mif,"loglik")) @@ -537,11 +497,9 @@ matplot(log.tau,type='l',lty=1,xlab="MIF iteration",ylab=expression(log~tau)) par(op) - ## ----first-mif-results-table,echo=F-------------------------------------- print(results.table) - ## ----gompertz-skeleton-def,echo=T---------------------------------------- gompertz.skel <- function (x, t, params, ...) { r <- params["r"] @@ -552,7 +510,6 @@ return(xnew) } - ## ----gomp3-pomp---------------------------------------------------------- gomp3 <- simulate( pomp( @@ -566,7 +523,6 @@ seed=88737400L ) - ## ----gompertz-trajmatch-calc,eval=F-------------------------------------- ## tm <- traj.match( ## gomp3, @@ -595,14 +551,12 @@ save(tm,file=binary.file,compress="xz") } - ## ----trajmatch-plot,echo=F,eval=T,fig.height=4,fig.width=6--------------- op <- par(mfrow=c(1,1),mar=c(3,3,0,0),mgp=c(2,1,0),bty='l') plot(time(tm),obs(tm,"Y"),xlab="time",ylab=expression(X,Y),type='o') lines(time(tm),states(tm,"X"),lwd=2) par(op) - ## ----ricker-map-defn----------------------------------------------------- ricker.sim <- function (x, t, params, delta.t, ...) { e <- rnorm(n=1,mean=0,sd=params["sigma"]) @@ -615,14 +569,12 @@ ) } - ## ----ricker-sim-C-def---------------------------------------------------- ricker.sim <- Csnippet(' e = rnorm(0,sigma); N = r*N*exp(-N+e); ') - ## ----ricker-pomp,results='hide'------------------------------------------ ricker <- pomp( data=data.frame(time=seq(0,50,by=1),y=NA), @@ -644,11 +596,9 @@ ) ricker <- simulate(ricker,seed=73691676L) - ## ----get-ricker,echo=T,eval=T,results='hide'----------------------------- pompExample(ricker) - ## ----probe-list---------------------------------------------------------- plist <- list( probe.marginal("y",ref=obs(ricker),transform=sqrt), @@ -657,7 +607,6 @@ transform=sqrt) ) - ## ----first-probe,eval=F,echo=T------------------------------------------- ## pb.truth <- probe(ricker,probes=plist,nsim=1000,seed=1066L) ## guess <- c(r=20,sigma=1,phi=20,N.0=7,e.0=0) @@ -674,14 +623,12 @@ save(pb.truth,pb.guess,guess,file=binary.file,compress='xz') } - ## ----first-probe-plot,eval=F--------------------------------------------- ## summary(pb.truth) ## summary(pb.guess) ## plot(pb.truth) ## plot(pb.guess) - ## ----ricker-probe-plot,echo=F,results='hide'----------------------------- binary.file <- "ricker-probe.rda" if (file.exists(binary.file)) { @@ -701,7 +648,6 @@ } plot(pb) - ## ----ricker-probe-match-calc,eval=F-------------------------------------- ## pm <- probe.match( ## pb.guess, @@ -715,7 +661,6 @@ ## ) ## summary(pm) - ## ----ricker-probe.match-eval,echo=F,eval=T,results='hide'---------------- binary.file <- "ricker-probe-match.rda" if (file.exists(binary.file)) { @@ -735,7 +680,6 @@ save(pm,file=binary.file,compress="xz") } - ## ----ricker-mif-calc,eval=F---------------------------------------------- ## mf <- mif( ## ricker, @@ -752,7 +696,6 @@ ## ) ## mf <- continue(mf,Nmif=500,max.fail=20) - ## ----ricker-mif-eval,echo=F,eval=T,results='hide'------------------------ binary.file <- "ricker-mif.rda" if (file.exists(binary.file)) { @@ -775,7 +718,6 @@ save(mf,file=binary.file,compress="xz") } - ## ----ricker-comparison,eval=F,echo=T------------------------------------- ## pf.truth <- pfilter(ricker,Np=1000,max.fail=50,seed=1066L) ## pf.guess <- pfilter(ricker,params=guess,Np=1000,max.fail=50,seed=1066L) @@ -817,18 +759,16 @@ ## ----ricker-comparison-show---------------------------------------------- print(res,digits=3) - ## ----first-nlf,eval=T,results='hide'------------------------------------- pompExample(gompertz) out <- nlf( gompertz, start=c(r=1,K=2,sigma=0.5,tau=0.5,X.0=1), - transform.params=TRUE, + transform=TRUE, est=c("K","r"), lags=c(1,2) ) - ## ----nlf-gompertz-starts,eval=F------------------------------------------ ## # pick 5 random starting parameter values ## starts <- replicate(n=5, @@ -841,7 +781,6 @@ ## simplify=FALSE ## ) - ## ----nlf-gompertz-fits,eval=F-------------------------------------------- ## out <- list() ## ## Do the fitting. @@ -851,7 +790,7 @@ ## gompertz, ## start=starts[[j]], ## transform.data=log, -## transform.params=TRUE, +## transform=TRUE, ## est=c("K","r"), ## lags=c(1,2), ## seed=7639873L, @@ -886,7 +825,7 @@ gompertz, start=starts[[j]], transform.data=log, - transform.params=TRUE, + transform=TRUE, est=c("K","r"), lags=c(1,2), seed=7639873L, @@ -900,16 +839,13 @@ save(starts,out,fits,file=binary.file,compress="xz") } - ## ----eval=T-------------------------------------------------------------- fits - ## ----nlf-my-pomp,eval=T-------------------------------------------------- long.gomp <- simulate(gompertz,times=1:1000) theta <- coef(long.gomp) - ## ----nlf-lag-test-log.r,eval=F------------------------------------------- ## lags <- list(1,2,c(1,2),c(2,3)) ## r.vals <- theta["r"]*exp(seq(-0.69,0.69,length=25)) @@ -990,7 +926,6 @@ save(theta,lags,r.vals,K.vals,fvals,fvals2,file=binary.file,compress="xz") } - ## ----nlf-gompertz-plot,fig.height=4,fig.width=6,echo=F------------------- fvals <- scale(fvals,center=apply(fvals,2,max),scale=FALSE) fvals2 <- scale(fvals2,center=apply(fvals2,2,max),scale=FALSE) @@ -1021,7 +956,6 @@ abline(v=theta["K"],col="blue") par(op) - ## ----nlf-multi-short,eval=F---------------------------------------------- ## nreps <- 100 ## ndata <- 60 @@ -1066,15 +1000,13 @@ save(lags,nreps,ndata,fvals,file=binary.file,compress="xz") } - ## ----eval=T-------------------------------------------------------------- apply(fvals,2,function(x)sd(x)/mean(x)) - ## ----nlf-fit-from-truth,eval=F------------------------------------------- ## true.fit <- nlf( ## gompertz, -## transform.params=TRUE, +## transform=TRUE, ## est=c("K","r"), ## lags=2, ## seed=7639873, @@ -1090,7 +1022,7 @@ } else { true.fit <- nlf( gompertz, - transform.params=TRUE, + transform=TRUE, est=c("K","r"), lags=2, seed=7639873, @@ -1101,7 +1033,6 @@ save(true.fit,file=binary.file,compress="xz") } - ## ----echo=F-------------------------------------------------------------- set.seed(32329L) @@ -1116,7 +1047,7 @@ ## fit <- nlf( ## gompertz, ## start=coef(gompertz), -## transform.params=TRUE, +## transform=TRUE, ## est=c("K","r"), ## lags=lags, ## seed=7639873, @@ -1146,7 +1077,7 @@ fit <- nlf( gompertz, start=coef(gompertz), - transform.params=TRUE, + transform=TRUE, est=c("K","r"), lags=lags, seed=7639873, @@ -1166,12 +1097,10 @@ ## ------------------------------------------------------------------------ apply(pars,2,sd) - ## ----block-bootsamp,eval=F----------------------------------------------- ## bootsamp <- replicate(n=nreps,sample(nboot,size=floor(nboot/3),replace=TRUE)) ## bootsamp <- rbind(bootsamp,bootsamp+1,bootsamp+2) - ## ----nlf-block-boot,eval=F,echo=F---------------------------------------- ## lags <- 2 ## ndata <- length(obs(gompertz)) @@ -1186,7 +1115,7 @@ ## for (j in seq_len(nreps)) { ## fit <- nlf( ## gompertz, -## transform.params=TRUE, +## transform=TRUE, ## est=c("K","r"), ## lags=lags, ## seed=7639873L, @@ -1201,7 +1130,6 @@ ## } ## colnames(pars) <- c("r","K") - ## ----nlf-block-boot-eval,eval=T,echo=F,results='hide'-------------------- binary.file <- "nlf-block-boot.rda" if (file.exists(binary.file)) { @@ -1220,7 +1148,7 @@ for (j in seq_len(nreps)) { fit <- nlf( gompertz, - transform.params=TRUE, + transform=TRUE, est=c("K","r"), lags=lags, seed=7639873L, @@ -1237,7 +1165,6 @@ save(pars,file=binary.file,compress="xz") } - ## ----bsmc-example-flat-prior-1,echo=T,eval=T,results='hide'-------------- pompExample(ricker) @@ -1250,7 +1177,6 @@ } ) - ## ----bsmc-example-flat-prior-3,eval=F------------------------------------ ## fit1 <- bsmc2(ricker,Np=10000,transform=TRUE, ## est=c("r","sigma"),smooth=0.2, @@ -1277,15 +1203,12 @@ save(fit1,file=binary.file,compress="xz") } - ## ----bsmc-example-flat-prior-coef---------------------------------------- signif(coef(fit1),digits=2) - ## ----bsmc-example-flat-prior-plot,fig.height=6,fig.width=6,echo=F-------- plot(fit1,pars=c("r","sigma"),thin=5000) - ## ----bsmc-example-normal-prior,eval=F,echo=T----------------------------- ## ricker <- pomp(ricker, ## rprior=function (params, ...) { @@ -1323,7 +1246,6 @@ ## ----bsmc-example-normal-prior-show,echo=T,eval=T------------------------ signif(coef(fit2),digits=2) - ## ----sir-step-R---------------------------------------------------------- require(pomp) @@ -1352,7 +1274,6 @@ x } - ## ----sir-step-C---------------------------------------------------------- sir.step <- ' double rate[6]; // transition rates @@ -1380,7 +1301,6 @@ ' - ## ----sir-pomp-def,eval=T,echo=T,results='hide'--------------------------- rmeas <- ' cases = rnbinom_mu(theta,rho*incid); @@ -1425,17 +1345,14 @@ simulate(sir,seed=1914679908L) -> sir - ## ----sir-plot,echo=F----------------------------------------------------- plot(sir,var=c("cases","incid","S","I")) - ## ----seas-basis---------------------------------------------------------- tbasis <- seq(-1,21,by=1/52) basis <- periodic.bspline.basis(tbasis,nbasis=3,degree=2,period=1, names="seas%d") - ## ----complex-sir-def,echo=T,eval=T,results='hide'------------------------ seas.sir.step <- ' double rate[6]; // transition rates @@ -1472,7 +1389,6 @@ incid += trans[3]; // incidence is cumulative recoveries ' - ## ----other-codes,results='hide'------------------------------------------ seas.sir.skel <- ' double rate[6]; // transition rates @@ -1572,7 +1488,6 @@ ) -> complex.sir - ## ----seas-basis-plot,echo=F,fig.height=4,fig.width=6--------------------- op <- par(mar=c(5,5,1,5)) matplot(tbasis,basis,xlim=c(0,2),type='l',lwd=2,bty='u', @@ -1594,8 +1509,6 @@ par(op) - ## ----complex-sir-plot,echo=F--------------------------------------------- plot(complex.sir) - Modified: www/vignettes/intro_to_pomp.Rnw =================================================================== --- www/vignettes/intro_to_pomp.Rnw 2015-02-22 22:49:40 UTC (rev 1091) +++ www/vignettes/intro_to_pomp.Rnw 2015-02-23 14:05:48 UTC (rev 1092) @@ -1181,7 +1181,7 @@ out <- nlf( gompertz, start=c(r=1,K=2,sigma=0.5,tau=0.5,X.0=1), - transform.params=TRUE, + transform=TRUE, est=c("K","r"), lags=c(1,2) ) @@ -1214,7 +1214,7 @@ gompertz, start=starts[[j]], transform.data=log, - transform.params=TRUE, + transform=TRUE, est=c("K","r"), lags=c(1,2), seed=7639873L, @@ -1390,7 +1390,7 @@ <>= true.fit <- nlf( gompertz, - transform.params=TRUE, + transform=TRUE, est=c("K","r"), lags=2, seed=7639873, @@ -1435,7 +1435,7 @@ fit <- nlf( gompertz, start=coef(gompertz), - transform.params=TRUE, + transform=TRUE, est=c("K","r"), lags=lags, seed=7639873, @@ -1488,7 +1488,7 @@ for (j in seq_len(nreps)) { fit <- nlf( gompertz, - transform.params=TRUE, + transform=TRUE, est=c("K","r"), lags=lags, seed=7639873L, Modified: www/vignettes/intro_to_pomp.pdf =================================================================== (Binary files differ) Modified: www/vignettes/nlf-block-boot.rda =================================================================== (Binary files differ) Modified: www/vignettes/nlf-boot.rda =================================================================== (Binary files differ) Modified: www/vignettes/nlf-fit-from-truth.rda =================================================================== (Binary files differ) Modified: www/vignettes/nlf-fits.rda =================================================================== (Binary files differ) Modified: www/vignettes/nlf-lag-tests.rda =================================================================== (Binary files differ) Modified: www/vignettes/nlf-multi-short.rda =================================================================== (Binary files differ) Modified: www/vignettes/plugin-C-code.rda =================================================================== (Binary files differ) Modified: www/vignettes/plugin-R-code.rda =================================================================== (Binary files differ) Modified: www/vignettes/pomp.pdf =================================================================== (Binary files differ) Modified: www/vignettes/ricker-comparison.rda =================================================================== (Binary files differ) Modified: www/vignettes/ricker-first-probe.rda =================================================================== (Binary files differ) Modified: www/vignettes/ricker-mif.rda =================================================================== (Binary files differ) Modified: www/vignettes/ricker-probe-match.rda =================================================================== (Binary files differ) Modified: www/vignettes/ricker-probe.rda =================================================================== (Binary files differ) Modified: www/vignettes/vectorized-C-code.rda =================================================================== (Binary files differ) Modified: www/vignettes/vectorized-R-code.rda =================================================================== (Binary files differ) From noreply at r-forge.r-project.org Wed Feb 25 13:18:36 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 25 Feb 2015 13:18:36 +0100 (CET) Subject: [Pomp-commits] r1093 - in pkg/pompExamples: . inst inst/examples man tests vignettes Message-ID: <20150225121836.2722718555F@r-forge.r-project.org> Author: kingaa Date: 2015-02-25 13:18:35 +0100 (Wed, 25 Feb 2015) New Revision: 1093 Modified: pkg/pompExamples/DESCRIPTION pkg/pompExamples/inst/NEWS pkg/pompExamples/inst/NEWS.Rd pkg/pompExamples/inst/examples/parus.R pkg/pompExamples/man/parus.Rd pkg/pompExamples/tests/parus.R pkg/pompExamples/tests/parus.Rout.save pkg/pompExamples/vignettes/parus.Rmd Log: - reconfigure parus major example Modified: pkg/pompExamples/DESCRIPTION =================================================================== --- pkg/pompExamples/DESCRIPTION 2015-02-23 14:05:48 UTC (rev 1092) +++ pkg/pompExamples/DESCRIPTION 2015-02-25 12:18:35 UTC (rev 1093) @@ -1,8 +1,8 @@ Package: pompExamples Type: Package Title: Additional pomp examples -Version: 0.26-6 -Date: 2015-02-11 +Version: 0.27-1 +Date: 2015-02-25 Maintainer: Aaron A. King Authors at R: c(person(given=c("Aaron","A."),family="King",role=c("aut","cre"), email="kingaa at umich.edu"), Modified: pkg/pompExamples/inst/NEWS =================================================================== --- pkg/pompExamples/inst/NEWS 2015-02-23 14:05:48 UTC (rev 1092) +++ pkg/pompExamples/inst/NEWS 2015-02-25 12:18:35 UTC (rev 1093) @@ -1,5 +1,10 @@ _N_e_w_s _f_o_r _P_a_c_k_a_g_e '_p_o_m_p_E_x_a_m_p_l_e_s' +_C_h_a_n_g_e_s _i_n '_p_o_m_p_E_x_a_m_p_l_e_s' _v_e_r_s_i_o_n _0._2_7-_1: + + ? _Parus major_ example (?pompExample(parus)?) reworked + slightly. + _C_h_a_n_g_e_s _i_n '_p_o_m_p_E_x_a_m_p_l_e_s' _v_e_r_s_i_o_n _0._2_4-_1: ? Examples included in the package can now be accessed using Modified: pkg/pompExamples/inst/NEWS.Rd =================================================================== --- pkg/pompExamples/inst/NEWS.Rd 2015-02-23 14:05:48 UTC (rev 1092) +++ pkg/pompExamples/inst/NEWS.Rd 2015-02-25 12:18:35 UTC (rev 1093) @@ -1,5 +1,10 @@ \name{NEWS} \title{News for Package 'pompExamples'} +\section{Changes in \pkg{pompExamples} version 0.27-1}{ + \itemize{ + \item \emph{Parus major} example (\code{pompExample(parus)}) reworked slightly. + } +} \section{Changes in \pkg{pompExamples} version 0.24-1}{ \itemize{ \item Examples included in the package can now be accessed using \pkg{pomp}'s \code{pompExample} function. Modified: pkg/pompExamples/inst/examples/parus.R =================================================================== --- pkg/pompExamples/inst/examples/parus.R 2015-02-23 14:05:48 UTC (rev 1092) +++ pkg/pompExamples/inst/examples/parus.R 2015-02-25 12:18:35 UTC (rev 1093) @@ -50,8 +50,8 @@ dat <- read.csv(text=dat,comment.char="#") -parus.example <- function (proc = c("Gompertz","Ricker"), - meas = c("lognormal","Poisson","negbin")) { +parus <- function (proc = c("Gompertz","Ricker"), + meas = c("lognormal","Poisson","negbin")) { proc <- match.arg(proc) meas <- match.arg(meas) @@ -101,6 +101,4 @@ ) } -parus <- parus.example(proc,meas) - c("parus") Modified: pkg/pompExamples/man/parus.Rd =================================================================== --- pkg/pompExamples/man/parus.Rd 2015-02-23 14:05:48 UTC (rev 1092) +++ pkg/pompExamples/man/parus.Rd 2015-02-25 12:18:35 UTC (rev 1093) @@ -3,10 +3,14 @@ \alias{parus} \title{POMPs for time series of Parus major population counts from Wytham Wood} \description{ - \code{pompExample(parus,proc,meas)} constructs a \code{pomp} object containing one of several population-dynamics models and abundance data from Parus major in Wytham Wood. + \code{pompExample(parus)} constructs a function that constructs \code{pomp} objects implementing each of several population-dynamics models and abundance data from Parus major in Wytham Wood. - The model has one state variables, \eqn{N_t}, the true abundance. + The model has one state variable, \eqn{N_t}, the true abundance. There is one observable, \eqn{\mathrm{pop}_t}. + + The function defined is: \preformatted{ + parus(proc = c("Gompertz", "Ricker"), + meas = c("lognormal","Poisson","negbin"))} } \section{State process}{ If \code{proc="Gompertz"}, the state process is the stochastic Gompertz model @@ -31,12 +35,14 @@ \deqn{\mathrm{pop}_{t} \sim \mathrm{Lognormal}(\log(N_t),\theta).} } \examples{ -pompExample(parus,proc="Ricker",meas="negbin") -plot(parus) -plot(simulate(parus)) +pompExample(parus) +p1 <- parus(proc="Ricker",meas="negbin") +plot(p1) +plot(simulate(p1)) -pompExample(parus,proc="Gompertz",meas="lognormal") -plot(simulate(parus)) +p2 <- parus(proc="Gompertz",meas="lognormal") +plot(simulate(p2)) +pf <- pfilter(p2,Np=1000) } \seealso{\code{vignette("parus")}} \keyword{models,datasets} Modified: pkg/pompExamples/tests/parus.R =================================================================== --- pkg/pompExamples/tests/parus.R 2015-02-23 14:05:48 UTC (rev 1092) +++ pkg/pompExamples/tests/parus.R 2015-02-25 12:18:35 UTC (rev 1093) @@ -2,19 +2,21 @@ set.seed(47575684L) -po <- pompExample(parus,proc="Ricker",meas="lognormal",envir=NULL) -pf <- pfilter(simulate(po$parus),Np=100,max.fail=Inf) -tj <- trajectory(po$parus) +pompExample(parus) -po <- pompExample(parus,proc="Ricker",meas="negbin",envir=NULL) -pf <- pfilter(simulate(po$parus),Np=100,max.fail=Inf) +po <- parus(proc="Ricker",meas="lognormal") +pf <- pfilter(simulate(po),Np=100,max.fail=Inf) +tj <- trajectory(po) -po <- pompExample(parus,proc="Ricker",meas="Poisson",envir=NULL) -pf <- pfilter(simulate(po$parus),Np=100,max.fail=Inf) +po <- parus(proc="Ricker",meas="negbin") +pf <- pfilter(simulate(po),Np=100,max.fail=Inf) -po <- pompExample(parus,proc="Gompertz",meas="Poisson",envir=NULL) -pf <- pfilter(simulate(po[[1]]),Np=100,max.fail=Inf) -tj <- trajectory(po[[1]]) +po <- parus(proc="Ricker",meas="Poisson") +pf <- pfilter(simulate(po),Np=100,max.fail=Inf) -po <- pompExample(parus,proc="Gompertz",meas="lognormal",envir=NULL) -pf <- pfilter(simulate(po$parus),Np=100,max.fail=Inf) +po <- parus(proc="Gompertz",meas="Poisson") +pf <- pfilter(simulate(po),Np=100,max.fail=Inf) +tj <- trajectory(po) + +po <- parus(proc="Gompertz",meas="lognormal") +pf <- pfilter(simulate(po),Np=100,max.fail=Inf) Modified: pkg/pompExamples/tests/parus.Rout.save =================================================================== --- pkg/pompExamples/tests/parus.Rout.save 2015-02-23 14:05:48 UTC (rev 1092) +++ pkg/pompExamples/tests/parus.Rout.save 2015-02-25 12:18:35 UTC (rev 1093) @@ -22,23 +22,27 @@ > > set.seed(47575684L) > -> po <- pompExample(parus,proc="Ricker",meas="lognormal",envir=NULL) -> pf <- pfilter(simulate(po$parus),Np=100,max.fail=Inf) -> tj <- trajectory(po$parus) +> pompExample(parus) +newly created object(s): + parus > -> po <- pompExample(parus,proc="Ricker",meas="negbin",envir=NULL) -> pf <- pfilter(simulate(po$parus),Np=100,max.fail=Inf) +> po <- parus(proc="Ricker",meas="lognormal") +> pf <- pfilter(simulate(po),Np=100,max.fail=Inf) +> tj <- trajectory(po) > -> po <- pompExample(parus,proc="Ricker",meas="Poisson",envir=NULL) -> pf <- pfilter(simulate(po$parus),Np=100,max.fail=Inf) +> po <- parus(proc="Ricker",meas="negbin") +> pf <- pfilter(simulate(po),Np=100,max.fail=Inf) > -> po <- pompExample(parus,proc="Gompertz",meas="Poisson",envir=NULL) -> pf <- pfilter(simulate(po[[1]]),Np=100,max.fail=Inf) -> tj <- trajectory(po[[1]]) +> po <- parus(proc="Ricker",meas="Poisson") +> pf <- pfilter(simulate(po),Np=100,max.fail=Inf) > -> po <- pompExample(parus,proc="Gompertz",meas="lognormal",envir=NULL) -> pf <- pfilter(simulate(po$parus),Np=100,max.fail=Inf) +> po <- parus(proc="Gompertz",meas="Poisson") +> pf <- pfilter(simulate(po),Np=100,max.fail=Inf) +> tj <- trajectory(po) > +> po <- parus(proc="Gompertz",meas="lognormal") +> pf <- pfilter(simulate(po),Np=100,max.fail=Inf) +> > proc.time() user system elapsed - 0.638 0.025 0.650 + 0.575 0.033 0.596 Modified: pkg/pompExamples/vignettes/parus.Rmd =================================================================== --- pkg/pompExamples/vignettes/parus.Rmd 2015-02-23 14:05:48 UTC (rev 1092) +++ pkg/pompExamples/vignettes/parus.Rmd 2015-02-25 12:18:35 UTC (rev 1093) @@ -48,8 +48,9 @@ ### Load and plot the data ```{r} -pompExample(parus,proc='Gompertz',meas='Poisson') -plot(parus) +pompExample(parus) +pGP <- parus(proc='Gompertz',meas='Poisson') +plot(pGP) ``` ## Model description @@ -79,15 +80,15 @@ $$\mathrm{pop}_{t} \sim \mathrm{Lognormal}(\log(N_t),\theta).$$ ```{r} -coef(parus) +coef(pGP) ``` ## Trajectory matching ```{r} -logLik(traj.match(parus)) +logLik(traj.match(pGP)) bake("parus-tm1.rds",{ - tm <- parus + tm <- pGP coef(tm,c("sigma","theta")) <- c(0,NA) traj.match(tm,est=c("K","r"),transform=T) -> tm traj.match(tm,method='subplex') -> tm @@ -95,7 +96,7 @@ }) -> tm ``` ```{r} -ggplot(data=simulate(parus,params=unlist(tm),nsim=10,obs=TRUE, +ggplot(data=simulate(pGP,params=unlist(tm),nsim=10,obs=TRUE, as.data.frame=TRUE,include.data=TRUE), mapping=aes(x=time,y=pop,group=sim,alpha=sim=="data"))+ geom_line()+ @@ -107,7 +108,7 @@ ```{r} bake("parus-mf.rds",{ - mf <- parus + mf <- pGP coef(mf,"theta") <- NA mif(mf,rw.sd=c(K=0.02,r=0.02,sigma=0.02), cooling.fraction=0.8,var.factor=2, @@ -125,7 +126,7 @@ }) -> mf ``` ```{r} -ggplot(data=simulate(parus,params=unlist(mf),nsim=10,obs=TRUE, +ggplot(data=simulate(pGP,params=unlist(mf),nsim=10,obs=TRUE, as.data.frame=TRUE,include.data=TRUE), mapping=aes(x=time,y=pop,group=sim,alpha=sim=="data"))+ geom_line()+ From noreply at r-forge.r-project.org Thu Feb 26 10:42:51 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 26 Feb 2015 10:42:51 +0100 (CET) Subject: [Pomp-commits] r1094 - in pkg/pomp: . R inst man Message-ID: <20150226094251.4A62018629D@r-forge.r-project.org> Author: kingaa Date: 2015-02-26 10:42:50 +0100 (Thu, 26 Feb 2015) New Revision: 1094 Modified: pkg/pomp/DESCRIPTION pkg/pomp/NAMESPACE pkg/pomp/R/abc.R pkg/pomp/R/bsmc.R pkg/pomp/R/bsmc2.R pkg/pomp/R/builder.R pkg/pomp/R/dmeasure-pomp.R pkg/pomp/R/dprior-pomp.R pkg/pomp/R/dprocess-pomp.R pkg/pomp/R/init-state-pomp.R pkg/pomp/R/mif.R pkg/pomp/R/minim.R pkg/pomp/R/nlf.R pkg/pomp/R/pfilter.R pkg/pomp/R/pmcmc.R pkg/pomp/R/pomp-class.R pkg/pomp/R/pomp.R pkg/pomp/R/probe-match.R pkg/pomp/R/probe.R pkg/pomp/R/rmeasure-pomp.R pkg/pomp/R/rprior-pomp.R pkg/pomp/R/rprocess-pomp.R pkg/pomp/R/simulate-pomp.R pkg/pomp/R/skeleton-pomp.R pkg/pomp/R/spect-match.R pkg/pomp/R/spect.R pkg/pomp/R/traj-match.R pkg/pomp/R/trajectory-pomp.R pkg/pomp/inst/NEWS pkg/pomp/inst/NEWS.Rd pkg/pomp/man/builder.Rd Log: - 'pompLoad' and 'pompUnload' have been removed from the export list - all top-level functions now call 'pompLoad' on call and 'pompUnload' before exit - in 'pompBuilder', 'link' argument has been removed - in 'pompCBuilder', 'link' and 'save' arguments have been removed. A new argument, 'dir', specifying the directory to use for C codes has been added; the default is to use tempdir(). - in dynamically built codes, the number of load calls is now tracked. Unloading only occurs when the number reaches zero. - the 'pomp' object 'solibfile' slot now contains a list (one element for each separate shared-object library) Modified: pkg/pomp/DESCRIPTION =================================================================== --- pkg/pomp/DESCRIPTION 2015-02-25 12:18:35 UTC (rev 1093) +++ pkg/pomp/DESCRIPTION 2015-02-26 09:42:50 UTC (rev 1094) @@ -1,8 +1,8 @@ Package: pomp Type: Package Title: Statistical Inference for Partially Observed Markov Processes -Version: 0.60-1 -Date: 2015-02-22 +Version: 0.61-1 +Date: 2015-02-24 Authors at R: c(person(given=c("Aaron","A."),family="King", role=c("aut","cre"),email="kingaa at umich.edu"), person(given=c("Edward","L."),family="Ionides",role=c("aut")), Modified: pkg/pomp/NAMESPACE =================================================================== --- pkg/pomp/NAMESPACE 2015-02-25 12:18:35 UTC (rev 1093) +++ pkg/pomp/NAMESPACE 2015-02-26 09:42:50 UTC (rev 1094) @@ -56,7 +56,6 @@ exportMethods( pomp, plot,show,print,coerce,summary,logLik,window,"$", - pompLoad,pompUnload, dprocess,rprocess,rmeasure,dmeasure,init.state,skeleton, dprior,rprior, data.array,obs,partrans,coef,"coef<-", Modified: pkg/pomp/R/abc.R =================================================================== --- pkg/pomp/R/abc.R 2015-02-25 12:18:35 UTC (rev 1093) +++ pkg/pomp/R/abc.R 2015-02-26 09:42:50 UTC (rev 1094) @@ -36,6 +36,8 @@ epsilon <- as.numeric(epsilon) epssq <- epsilon*epsilon + pompLoad(object) + if (length(start)==0) stop( "abc error: ",sQuote("start")," must be specified if ", @@ -140,6 +142,8 @@ pars <- apply(conv.rec,2,function(x)diff(range(x))>0) pars <- names(pars[pars]) + pompUnload(object) + new( 'abc', object, Modified: pkg/pomp/R/bsmc.R =================================================================== --- pkg/pomp/R/bsmc.R 2015-02-25 12:18:35 UTC (rev 1093) +++ pkg/pomp/R/bsmc.R 2015-02-26 09:42:50 UTC (rev 1094) @@ -40,6 +40,8 @@ .getnativesymbolinfo = TRUE, ...) { + pompLoad(object) + gnsi.rproc <- gnsi.dmeas <- as.logical(.getnativesymbolinfo) ptsi.inv <- ptsi.for <- TRUE transform <- as.logical(transform) @@ -335,6 +337,8 @@ ## replace parameters with point estimate (posterior median) coef(object,transform=transform) <- apply(params,1,median) + pompUnload(object) + new( "bsmcd.pomp", object, Modified: pkg/pomp/R/bsmc2.R =================================================================== --- pkg/pomp/R/bsmc2.R 2015-02-25 12:18:35 UTC (rev 1093) +++ pkg/pomp/R/bsmc2.R 2015-02-26 09:42:50 UTC (rev 1094) @@ -15,6 +15,8 @@ max.fail, transform, .getnativesymbolinfo = TRUE, ...) { + pompLoad(object) + gnsi.rproc <- gnsi.dmeas <- as.logical(.getnativesymbolinfo) ptsi.inv <- ptsi.for <- TRUE transform <- as.logical(transform) @@ -216,6 +218,8 @@ ## replace parameters with point estimate (posterior median) coef(object,transform=transform) <- apply(params,1,median) + pompUnload(object) + new( "bsmcd.pomp", object, Modified: pkg/pomp/R/builder.R =================================================================== --- pkg/pomp/R/builder.R 2015-02-25 12:18:35 UTC (rev 1093) +++ pkg/pomp/R/builder.R 2015-02-26 09:42:50 UTC (rev 1094) @@ -5,7 +5,7 @@ skelmap.delta.t = 1, parameter.transform, parameter.inv.transform, rprior, dprior, - globals, ..., link = TRUE, save = FALSE) { + globals, ..., save = FALSE) { if (!is.data.frame(data)) stop(sQuote("data")," must be a data-frame") obsnames <- names(data) @@ -44,12 +44,10 @@ rprior=rprior, dprior=dprior, globals=globals, - link=link, - save=save - ) -> bret + dir=if (save) getwd() else NULL + ) -> solib - name <- bret[1] - solib <- bret[2] + name <- solib[1] pomp( data=data, @@ -75,24 +73,27 @@ tcovar=tcovar, covar=covar, ..., - .solibfile=solib + .solibfile=list(solib) ) } -pompLoad.internal <- function (object, ..., - verbose = getOption("verbose",FALSE)) { +pompLoad.internal <- function (object, ..., verbose = getOption("verbose",FALSE)) { for (lib in object at solibfile) { - if (verbose) cat("loading",sQuote(lib),"\n") - dyn.load(lib) + if (!is.loaded("__pomp_load_stack_incr",PACKAGE=lib[1])) dyn.load(lib[2]) + if (verbose) cat("loading",sQuote(lib[2]),"\n") + .C("__pomp_load_stack_incr",PACKAGE=lib[1]) } invisible(NULL) } - -pompUnload.internal <- function (object, ..., - verbose = getOption("verbose",FALSE)) { + +pompUnload.internal <- function (object, ..., verbose = getOption("verbose",FALSE)) { for (lib in object at solibfile) { - if (verbose) cat("unloading",sQuote(lib),"\n") - dyn.unload(lib) + if (is.loaded("__pomp_load_stack_decr",PACKAGE=lib[1])) { + st <- .C("__pomp_load_stack_decr",st=integer(1),PACKAGE=lib[1])$st + stopifnot(st>=0) + if (st==0) dyn.unload(lib[2]) + if (verbose) cat("unloading",sQuote(lib[2]),"\n") + } } invisible(NULL) } @@ -120,6 +121,15 @@ header <- list( file="/* pomp model file: {%name%} */\n\n#include <{%pompheader%}>\n#include \n\n", + stackhandling=" +static int __pomp_load_stack = 0;\n +void __pomp_load_stack_incr (void) { + ++__pomp_load_stack; +}\n +void __pomp_load_stack_decr (int *val) { + *val = (--__pomp_load_stack); +} +", rmeasure="\nvoid {%name%}_rmeasure (double *__y, double *__x, double *__p, int *__obsindex, int *__stateindex, int *__parindex, int *__covindex, int __ncovars, double *__covars, double t)\n{\n", dmeasure= "\nvoid {%name%}_dmeasure (double *__lik, double *__y, double *__x, double *__p, int give_log, int *__obsindex, int *__stateindex, int *__parindex, int *__covindex, int __ncovars, double *__covars, double t)\n{\n", step.fn="\nvoid {%name%}_stepfn (double *__x, const double *__p, const int *__stateindex, const int *__parindex, const int *__covindex, int __covdim, const double *__covars, double t, double dt)\n{\n", @@ -188,11 +198,12 @@ statenames, paramnames, covarnames, obsnames, rmeasure, dmeasure, step.fn, skeleton, parameter.transform, parameter.inv.transform, - rprior, dprior, globals, save = FALSE, link = TRUE, + rprior, dprior, globals, dir = NULL, verbose = getOption("verbose",FALSE)) { if (is.null(name)) name <- randomName() + if (is.null(dir)) dir <- tempdir() has.trans <- !(missing(parameter.transform)) @@ -204,7 +215,7 @@ covarnames <- cleanForC(covarnames) obsnames <- cleanForC(obsnames) - stem <- if (save) name else file.path(tempdir(),name) + stem <- file.path(dir,name) if (.Platform$OS.type=="windows") { stem <- gsub("\\","/",stem,fixed=TRUE) } @@ -222,6 +233,8 @@ cat(file=out,render(header$file,name=name,pompheader=pompheader)) + cat(file=out,header$stackhandling) + for (f in utility.fns) { cat(file=out,f) } @@ -325,8 +338,6 @@ cat("model codes written to",sQuote(modelfile), "\nlink to shared-object library",sQuote(solib),"\n") - if (link) dyn.load(solib) - invisible(c(name,solib)) } Modified: pkg/pomp/R/dmeasure-pomp.R =================================================================== --- pkg/pomp/R/dmeasure-pomp.R 2015-02-25 12:18:35 UTC (rev 1093) +++ pkg/pomp/R/dmeasure-pomp.R 2015-02-26 09:42:50 UTC (rev 1094) @@ -1,10 +1,14 @@ ## evaluate the measurement model density function dmeasure.internal <- function (object, y, x, times, params, log = FALSE, .getnativesymbolinfo = TRUE, ...) { - .Call(do_dmeasure,object,y,x,times,params,log,.getnativesymbolinfo) + pompLoad(object) + rv <- .Call(do_dmeasure,object,y,x,times,params,log,.getnativesymbolinfo) + pompUnload(object) + rv } -setMethod("dmeasure","pomp", +setMethod("dmeasure", + signature=signature("pomp"), function (object, y, x, times, params, log = FALSE, ...) dmeasure.internal(object=object,y=y,x=x,times=times,params=params,log=log,...) ) Modified: pkg/pomp/R/dprior-pomp.R =================================================================== --- pkg/pomp/R/dprior-pomp.R 2015-02-25 12:18:35 UTC (rev 1093) +++ pkg/pomp/R/dprior-pomp.R 2015-02-26 09:42:50 UTC (rev 1094) @@ -2,10 +2,14 @@ dprior.internal <- function (object, params, log = FALSE, .getnativesymbolinfo = TRUE, ...) { - .Call(do_dprior,object,params,log,.getnativesymbolinfo) + pompLoad(object) + rv <- .Call(do_dprior,object,params,log,.getnativesymbolinfo) + pompUnload(object) + rv } -setMethod("dprior","pomp", +setMethod("dprior", + signature=signature("pomp"), function (object, params, log = FALSE, ...) dprior.internal(object=object,params=params,log=log,...) ) Modified: pkg/pomp/R/dprocess-pomp.R =================================================================== --- pkg/pomp/R/dprocess-pomp.R 2015-02-25 12:18:35 UTC (rev 1093) +++ pkg/pomp/R/dprocess-pomp.R 2015-02-26 09:42:50 UTC (rev 1094) @@ -1,9 +1,15 @@ ## evaluate the process model density function -dprocess.internal <- function (object, x, times, params, log = FALSE, .getnativesymbolinfo = TRUE, ...) - .Call(do_dprocess,object,x,times,params,log,.getnativesymbolinfo) +dprocess.internal <- function (object, x, times, params, log = FALSE, .getnativesymbolinfo = TRUE, ...) { + pompLoad(object) + rv <- .Call(do_dprocess,object,x,times,params,log,.getnativesymbolinfo) + pompUnload(object) + rv +} + -setMethod("dprocess","pomp", - function (object, x, times, params, log = FALSE, ...) +setMethod("dprocess", + signature=signature("pomp"), + definition = function (object, x, times, params, log = FALSE, ...) dprocess.internal(object=object,x=x,times=times,params=params,log=log,...) ) Modified: pkg/pomp/R/init-state-pomp.R =================================================================== --- pkg/pomp/R/init-state-pomp.R 2015-02-25 12:18:35 UTC (rev 1093) +++ pkg/pomp/R/init-state-pomp.R 2015-02-26 09:42:50 UTC (rev 1094) @@ -3,13 +3,15 @@ init.state.internal <- function (object, params, t0, ...) { if (missing(t0)) t0 <- object at t0 if (missing(params)) params <- coef(object) - .Call(do_init_state,object,params,t0) + pompLoad(object) + rv <- .Call(do_init_state,object,params,t0) + pompUnload(object) + rv } -setMethod( - 'init.state', - 'pomp', - function (object, params, t0, ...) { +setMethod('init.state', + signature=signature('pomp'), + definition=function (object, params, t0, ...) { init.state.internal(object=object,params=params,t0=t0,...) } ) Modified: pkg/pomp/R/mif.R =================================================================== --- pkg/pomp/R/mif.R 2015-02-25 12:18:35 UTC (rev 1093) +++ pkg/pomp/R/mif.R 2015-02-26 09:42:50 UTC (rev 1094) @@ -118,6 +118,8 @@ .getnativesymbolinfo = TRUE, ...) { + pompLoad(object) + gnsi <- as.logical(.getnativesymbolinfo) transform <- as.logical(transform) @@ -386,6 +388,8 @@ ## back transform the parameter estimate if necessary if (transform) theta <- partrans(pfp,theta,dir="forward") + pompUnload(object) + new( "mif", pfp, Modified: pkg/pomp/R/minim.R =================================================================== --- pkg/pomp/R/minim.R 2015-02-25 12:18:35 UTC (rev 1093) +++ pkg/pomp/R/minim.R 2015-02-26 09:42:50 UTC (rev 1094) @@ -1,6 +1,8 @@ minim.internal <- function(objfun, start, est, object, method, transform, verbose, ...) { + pompLoad(object) + transform <- as.logical(transform) est <- as.character(est) @@ -62,6 +64,8 @@ if (transform) start <- partrans(object,start,dir='forward') + pompUnload(object) + list( params=start, est=est, Modified: pkg/pomp/R/nlf.R =================================================================== --- pkg/pomp/R/nlf.R 2015-02-25 12:18:35 UTC (rev 1093) +++ pkg/pomp/R/nlf.R 2015-02-26 09:42:50 UTC (rev 1094) @@ -59,6 +59,8 @@ eval.only, transform.data, ...) { + pompLoad(object) + if (eval.only) est <- character(0) if (missing(start)) start <- coef(object) if (transform) @@ -374,6 +376,8 @@ opt$npts <- npts } + pompUnload(object) + new( "nlfd.pomp", object, Modified: pkg/pomp/R/pfilter.R =================================================================== --- pkg/pomp/R/pfilter.R 2015-02-25 12:18:35 UTC (rev 1093) +++ pkg/pomp/R/pfilter.R 2015-02-26 09:42:50 UTC (rev 1094) @@ -44,6 +44,8 @@ .transform, .getnativesymbolinfo = TRUE) { + pompLoad(object) + ptsi.inv <- ptsi.for <- gnsi.rproc <- gnsi.dmeas <- as.logical(.getnativesymbolinfo) mif2 <- as.logical(.mif2) transform <- as.logical(.transform) @@ -334,6 +336,8 @@ msg2="%d filtering failures occurred in "),nfail), sQuote("pfilter"),call.=FALSE) + pompUnload(object) + new( "pfilterd.pomp", object, Modified: pkg/pomp/R/pmcmc.R =================================================================== --- pkg/pomp/R/pmcmc.R 2015-02-25 12:18:35 UTC (rev 1093) +++ pkg/pomp/R/pmcmc.R 2015-02-26 09:42:50 UTC (rev 1094) @@ -30,6 +30,8 @@ gnsi <- as.logical(.getnativesymbolinfo) .ndone <- as.integer(.ndone) + pompLoad(object) + if (missing(start)) stop(sQuote("start")," must be specified",call.=FALSE) if (length(start)==0) @@ -169,6 +171,8 @@ pars <- apply(conv.rec,2,function(x)diff(range(x))>0) pars <- names(pars[pars]) + pompUnload(object) + new( "pmcmc", pfp, Modified: pkg/pomp/R/pomp-class.R =================================================================== --- pkg/pomp/R/pomp-class.R 2015-02-25 12:18:35 UTC (rev 1093) +++ pkg/pomp/R/pomp-class.R 2015-02-26 09:42:50 UTC (rev 1094) @@ -34,7 +34,7 @@ has.trans = 'logical', par.trans = 'pomp.fun', par.untrans = 'pomp.fun', - solibfile = 'character', + solibfile = 'list', userdata = 'list' ), prototype=prototype( @@ -59,7 +59,7 @@ has.trans=FALSE, par.trans=pomp.fun(), par.untrans=pomp.fun(), - solibfile=character(0), + solibfile=list(), userdata=list() ), validity=function (object) { Modified: pkg/pomp/R/pomp.R =================================================================== --- pkg/pomp/R/pomp.R 2015-02-25 12:18:35 UTC (rev 1093) +++ pkg/pomp/R/pomp.R 2015-02-26 09:42:50 UTC (rev 1094) @@ -17,7 +17,7 @@ if (missing(times)) stop(sQuote("times")," is a required argument") if (missing(t0)) stop(sQuote("t0")," is a required argument") if (missing(params)) params <- numeric(0) - if (missing(.solibfile)) .solibfile <- character(0) + if (missing(.solibfile)) .solibfile <- list() if (missing(userdata)) userdata <- list() added.userdata <- list(...) @@ -144,8 +144,6 @@ paramnames=paramnames, covarnames=covarnames, globals=globals, - link=TRUE, - save=FALSE, verbose=verbose ), snips @@ -157,8 +155,8 @@ stop("in ",sQuote("pomp"),": error in building shared-object library from Csnippets:\n", libname,call.=FALSE) } else { - .solibfile <- c(.solibfile,libname[2L]) - libname <- libname[1L] + .solibfile <- c(.solibfile,list(libname)) + libname <- libname[1] } } else { libname <- '' @@ -703,6 +701,7 @@ parameter.inv.transform=par.untrans, params=params, globals=globals, + .solibfile=data at solibfile, userdata=data at userdata, ... ) Modified: pkg/pomp/R/probe-match.R =================================================================== --- pkg/pomp/R/probe-match.R 2015-02-25 12:18:35 UTC (rev 1093) +++ pkg/pomp/R/probe-match.R 2015-02-26 09:42:50 UTC (rev 1094) @@ -65,6 +65,8 @@ function (par) { + pompLoad(object) + params[par.est.idx] <- par if (transform) @@ -82,6 +84,7 @@ ) ll <- .Call(synth_loglik,simval,datval) + pompUnload(object) if (is.finite(ll)||is.na(fail.value)) -ll else fail.value } } @@ -136,6 +139,8 @@ transform = FALSE, ...) { + pompLoad(object) + if (missing(start)) start <- coef(object) if (missing(probes)) stop(sQuote("probes")," must be supplied") if (missing(nsim)) stop(sQuote("nsim")," must be supplied") @@ -167,6 +172,8 @@ coef(object) <- m$params + pompUnload(object) + new( "probe.matched.pomp", probe( Modified: pkg/pomp/R/probe.R =================================================================== --- pkg/pomp/R/probe.R 2015-02-25 12:18:35 UTC (rev 1093) +++ pkg/pomp/R/probe.R 2015-02-26 09:42:50 UTC (rev 1094) @@ -14,6 +14,8 @@ probe.internal <- function (object, probes, params, nsim = 1, seed = NULL, ...) { + pompLoad(object) + if (!is.list(probes)) probes <- list(probes) if (!all(sapply(probes,is.function))) stop(sQuote("probes")," must be a function or a list of functions") @@ -56,6 +58,8 @@ coef(object) <- params + pompUnload(object) + new( "probed.pomp", object, Modified: pkg/pomp/R/rmeasure-pomp.R =================================================================== --- pkg/pomp/R/rmeasure-pomp.R 2015-02-25 12:18:35 UTC (rev 1093) +++ pkg/pomp/R/rmeasure-pomp.R 2015-02-26 09:42:50 UTC (rev 1094) @@ -2,10 +2,14 @@ rmeasure.internal <- function (object, x, times, params, .getnativesymbolinfo = TRUE, ...) { - .Call(do_rmeasure,object,x,times,params,.getnativesymbolinfo) + pompLoad(object) + rv <- .Call(do_rmeasure,object,x,times,params,.getnativesymbolinfo) + pompUnload(object) + rv } -setMethod("rmeasure","pomp", - function (object, x, times, params, ...) +setMethod("rmeasure", + signature=signature("pomp"), + definition=function (object, x, times, params, ...) rmeasure.internal(object=object,x=x,times=times,params=params,...) ) Modified: pkg/pomp/R/rprior-pomp.R =================================================================== --- pkg/pomp/R/rprior-pomp.R 2015-02-25 12:18:35 UTC (rev 1093) +++ pkg/pomp/R/rprior-pomp.R 2015-02-26 09:42:50 UTC (rev 1094) @@ -1,10 +1,14 @@ ## simulate from the prior rprior.internal <- function (object, params, .getnativesymbolinfo = TRUE, ...) { - .Call(do_rprior,object,params,.getnativesymbolinfo) + pompLoad(object) + rv <- .Call(do_rprior,object,params,.getnativesymbolinfo) + pompUnload(object) + rv } -setMethod("rprior","pomp", - function (object, params, ...) +setMethod("rprior", + signature=signature("pomp"), + definition=function (object, params, ...) rprior.internal(object=object,params=params,...) ) Modified: pkg/pomp/R/rprocess-pomp.R =================================================================== --- pkg/pomp/R/rprocess-pomp.R 2015-02-25 12:18:35 UTC (rev 1093) +++ pkg/pomp/R/rprocess-pomp.R 2015-02-26 09:42:50 UTC (rev 1094) @@ -1,7 +1,12 @@ ## simulate the process model -rprocess.internal <- function (object, xstart, times, params, offset = 0, .getnativesymbolinfo = TRUE, ...) - .Call(do_rprocess,object,xstart,times,params,offset,.getnativesymbolinfo) +rprocess.internal <- function (object, xstart, times, params, offset = 0, .getnativesymbolinfo = TRUE, ...) { + pompLoad(object) + rv <- .Call(do_rprocess,object,xstart,times,params,offset,.getnativesymbolinfo) + pompUnload(object) + rv +} + setMethod( "rprocess", Modified: pkg/pomp/R/simulate-pomp.R =================================================================== --- pkg/pomp/R/simulate-pomp.R 2015-02-25 12:18:35 UTC (rev 1093) +++ pkg/pomp/R/simulate-pomp.R 2015-02-26 09:42:50 UTC (rev 1094) @@ -5,6 +5,7 @@ times, t0, as.data.frame = FALSE, include.data = FALSE, .getnativesymbolinfo = TRUE, ...) { + pompLoad(object) if (missing(times)) times <- time(object,t0=FALSE) @@ -122,6 +123,8 @@ } + pompUnload(object) + retval } Modified: pkg/pomp/R/skeleton-pomp.R =================================================================== --- pkg/pomp/R/skeleton-pomp.R 2015-02-25 12:18:35 UTC (rev 1093) +++ pkg/pomp/R/skeleton-pomp.R 2015-02-26 09:42:50 UTC (rev 1094) @@ -1,10 +1,14 @@ ## evaluate the deterministic skeleton skeleton.internal <- function (object, x, t, params, .getnativesymbolinfo = TRUE, ...) { - .Call(do_skeleton,object,x,t,params,.getnativesymbolinfo) + pompLoad(object) + rv <- .Call(do_skeleton,object,x,t,params,.getnativesymbolinfo) + pompUnload(object) + rv } -setMethod("skeleton","pomp", - function (object, x, t, params, ...) +setMethod("skeleton", + signature=signature("pomp"), + definition=function (object, x, t, params, ...) skeleton.internal(object=object,x=x,t=t,params=params,...) ) Modified: pkg/pomp/R/spect-match.R =================================================================== --- pkg/pomp/R/spect-match.R 2015-02-25 12:18:35 UTC (rev 1093) +++ pkg/pomp/R/spect-match.R 2015-02-26 09:42:50 UTC (rev 1094) @@ -20,6 +20,8 @@ if (missing(est)) est <- integer(0) if (missing(params)) params <- coef(object) + pompLoad(object) + params[est] <- par ## vector of frequencies and estimated power spectum of data @@ -55,6 +57,7 @@ mismatch <- sum(discrep) } + pompUnload(object) mismatch } @@ -67,6 +70,8 @@ verbose = getOption("verbose"), eval.only = FALSE, fail.value = NA, ...) { + pompLoad(object) + obj.fn <- spect.mismatch if (!is(object,"pomp")) @@ -213,6 +218,8 @@ msg <- opt$message } + pompUnload(object) + new( "spect.matched.pomp", spect( Modified: pkg/pomp/R/spect.R =================================================================== --- pkg/pomp/R/spect.R 2015-02-25 12:18:35 UTC (rev 1093) +++ pkg/pomp/R/spect.R 2015-02-26 09:42:50 UTC (rev 1094) @@ -144,6 +144,8 @@ detrend = c("none","mean","linear","quadratic"), ...) { + pompLoad(object) + if (missing(params)) params <- coef(object) if (missing(vars)) @@ -199,6 +201,8 @@ coef(object) <- params + pompUnload(object) + new( "spect.pomp", object, Modified: pkg/pomp/R/traj-match.R =================================================================== --- pkg/pomp/R/traj-match.R 2015-02-25 12:18:35 UTC (rev 1093) +++ pkg/pomp/R/traj-match.R 2015-02-26 09:42:50 UTC (rev 1094) @@ -48,6 +48,7 @@ stop("parameter(s): ",sQuote(est[is.na(par.est.idx)])," not found in ",sQuote("params")) function (par) { + pompLoad(object) params[par.est.idx] <- par if (transform) tparams <- partrans(object,params,dir="forward") @@ -63,6 +64,7 @@ params=if (transform) tparams else params, log=TRUE ) + pompUnload(object) -sum(d) } } Modified: pkg/pomp/R/trajectory-pomp.R =================================================================== --- pkg/pomp/R/trajectory-pomp.R 2015-02-25 12:18:35 UTC (rev 1093) +++ pkg/pomp/R/trajectory-pomp.R 2015-02-26 09:42:50 UTC (rev 1094) @@ -1,5 +1,7 @@ trajectory.internal <- function (object, params, times, t0, as.data.frame = FALSE, .getnativesymbolinfo = TRUE, ...) { + pompLoad(object) + if (missing(times)) times <- time(object,t0=FALSE) else @@ -111,6 +113,8 @@ x$traj <- factor(x$traj) } + pompUnload(object) + x } Modified: pkg/pomp/inst/NEWS =================================================================== --- pkg/pomp/inst/NEWS 2015-02-25 12:18:35 UTC (rev 1093) +++ pkg/pomp/inst/NEWS 2015-02-26 09:42:50 UTC (rev 1094) @@ -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 _0._6_1-_1: + + ? When using ?Csnippet?s or ?pompBuilder?, it is no longer + necessary to manually load and unload the dynamically + loadable library. This is now handled automatically. + Accordingly, the ?link? argument of ?pompBuilder? and the + ?pompLoad? and ?pompUnload? functions have been removed. + _C_h_a_n_g_e_s _i_n '_p_o_m_p' _v_e_r_s_i_o_n _0._6_0-_1: ? ?pmcmc? and ?abc? can now use arbitrary symmetric proposal Modified: pkg/pomp/inst/NEWS.Rd =================================================================== --- pkg/pomp/inst/NEWS.Rd 2015-02-25 12:18:35 UTC (rev 1093) +++ pkg/pomp/inst/NEWS.Rd 2015-02-26 09:42:50 UTC (rev 1094) @@ -1,5 +1,12 @@ \name{NEWS} \title{News for package `pomp'} +\section{Changes in \pkg{pomp} version 0.61-1}{ + \itemize{ + \item When using \code{Csnippet}s or \code{pompBuilder}, it is no longer necessary to manually load and unload the dynamically loadable library. + This is now handled automatically. + Accordingly, the \code{link} argument of \code{pompBuilder} and the \code{pompLoad} and \code{pompUnload} functions have been removed. + } +} \section{Changes in \pkg{pomp} version 0.60-1}{ \itemize{ \item \code{pmcmc} and \code{abc} can now use arbitrary symmetric proposal distributions via the \code{proposal} argument. Modified: pkg/pomp/man/builder.Rd =================================================================== --- pkg/pomp/man/builder.Rd 2015-02-25 12:18:35 UTC (rev 1093) +++ pkg/pomp/man/builder.Rd 2015-02-26 09:42:50 UTC (rev 1094) @@ -1,6 +1,6 @@ \name{pompBuilder} \alias{pompBuilder} -\title{Write, compile, link, and build a pomp object using native codes} +\title{Write, compile, and build a pomp object using native codes} \description{ \code{pompBuilder} is a facility for producing compiled \code{pomp} objects. } @@ -11,8 +11,7 @@ skeleton, skeleton.type = c("map","vectorfield"), skelmap.delta.t = 1, parameter.transform, parameter.inv.transform, - rprior, dprior, - globals, \dots, link = TRUE, save = FALSE) + rprior, dprior, globals, \dots, save = FALSE) } \arguments{ \item{data, times, t0}{ @@ -58,9 +57,6 @@ \item{\dots}{ additional arguments are passed to \code{\link{pomp}} } - \item{link}{ - logical; if TRUE, the resulting code will be linked after compilation. - } \item{save}{ logical; if TRUE, the resulting C code will be saved in the current working directory. The shared-object library will also be created in this directory. @@ -70,16 +66,13 @@ \value{ The constructed \code{pomp} object. A side-effect is the writing and compilation of a C code into a dynamics shared object. - These files will reside in the current working directory (see \code{\link{getwd}}). - If \code{pompBuilder} has been called with \code{link=FALSE}, this dynamic shared object must be linked (see \code{\link{dyn.load}}) before the \code{pomp} object can be used. \strong{Parallel computing caution:} note that, since a side-effect of running \code{pompBuilder} is the writing and compilation of a file, caution must be used when running parallel computations. Simultaneous execution of \code{pompBuilder} on nodes sharing a common disk will cause all nodes to attempt to write the same file at the same time; the results will be undefined. - If multiple nodes are to work on the same \code{pomp} object built by \code{pompBuilder}, first run \code{pompBuilder} once (perhaps with \code{link=FALSE}) to write the C file and compile it into a dynamic shared object file. + If multiple nodes are to work on the same \code{pomp} object built by \code{pompBuilder}, first run \code{pompBuilder} once (with \code{save = TRUE}) to write the C file and compile it into a dynamic shared object file. The \code{pomp} object returned by \code{pompBuilder} can then be shared with all worker nodes. - Note, however, that all worker nodes must dynamically load (using \code{\link{dyn.load}}) the dynamic shared object file before anything can be done with the \code{pomp} object. } \details{ \code{pompBuilder} with \code{save=TRUE} assumes that files can be written to the current working directory and that dynamic shared objects can be compiled and linked, i.e., that \code{R CMD SHLIB} will work. From noreply at r-forge.r-project.org Thu Feb 26 10:42:53 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 26 Feb 2015 10:42:53 +0100 (CET) Subject: [Pomp-commits] r1095 - pkg/pomp/R Message-ID: <20150226094254.026251862BE@r-forge.r-project.org> Author: kingaa Date: 2015-02-26 10:42:53 +0100 (Thu, 26 Feb 2015) New Revision: 1095 Modified: pkg/pomp/R/builder.R Log: - correction with (verbose=TRUE) messages Modified: pkg/pomp/R/builder.R =================================================================== --- pkg/pomp/R/builder.R 2015-02-26 09:42:50 UTC (rev 1094) +++ pkg/pomp/R/builder.R 2015-02-26 09:42:53 UTC (rev 1095) @@ -79,8 +79,10 @@ pompLoad.internal <- function (object, ..., verbose = getOption("verbose",FALSE)) { for (lib in object at solibfile) { - if (!is.loaded("__pomp_load_stack_incr",PACKAGE=lib[1])) dyn.load(lib[2]) - if (verbose) cat("loading",sQuote(lib[2]),"\n") + if (!is.loaded("__pomp_load_stack_incr",PACKAGE=lib[1])) { + dyn.load(lib[2]) + if (verbose) cat("loading",sQuote(lib[2]),"\n") + } .C("__pomp_load_stack_incr",PACKAGE=lib[1]) } invisible(NULL) @@ -91,8 +93,10 @@ if (is.loaded("__pomp_load_stack_decr",PACKAGE=lib[1])) { st <- .C("__pomp_load_stack_decr",st=integer(1),PACKAGE=lib[1])$st stopifnot(st>=0) - if (st==0) dyn.unload(lib[2]) - if (verbose) cat("unloading",sQuote(lib[2]),"\n") + if (st==0) { + dyn.unload(lib[2]) + if (verbose) cat("unloading",sQuote(lib[2]),"\n") + } } } invisible(NULL) From noreply at r-forge.r-project.org Thu Feb 26 10:42:56 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 26 Feb 2015 10:42:56 +0100 (CET) Subject: [Pomp-commits] r1096 - in pkg/pomp: R src Message-ID: <20150226094256.D1AC218629D@r-forge.r-project.org> Author: kingaa Date: 2015-02-26 10:42:56 +0100 (Thu, 26 Feb 2015) New Revision: 1096 Modified: pkg/pomp/R/builder.R pkg/pomp/src/pomp_fun.c Log: - put load-stack stuff at bottom of temporary C file - streamline pomp_fun.c Modified: pkg/pomp/R/builder.R =================================================================== --- pkg/pomp/R/builder.R 2015-02-26 09:42:53 UTC (rev 1095) +++ pkg/pomp/R/builder.R 2015-02-26 09:42:56 UTC (rev 1096) @@ -237,8 +237,6 @@ cat(file=out,render(header$file,name=name,pompheader=pompheader)) - cat(file=out,header$stackhandling) - for (f in utility.fns) { cat(file=out,f) } @@ -324,6 +322,9 @@ for (v in seq_along(paramnames)) { cat(file=out,render(undefine$var,variable=paste0("T",paramnames[v]))) } + + cat(file=out,header$stackhandling) + close(out) cflags <- paste0("PKG_CFLAGS=\"", Modified: pkg/pomp/src/pomp_fun.c =================================================================== --- pkg/pomp/src/pomp_fun.c 2015-02-26 09:42:53 UTC (rev 1095) +++ pkg/pomp/src/pomp_fun.c 2015-02-26 09:42:56 UTC (rev 1096) @@ -25,8 +25,7 @@ PROTECT(nf = GET_SLOT(pfun,install("native.fun"))); nprotect++; PROTECT(pack = GET_SLOT(pfun,install("PACKAGE"))); nprotect++; if (LENGTH(pack) < 1) { - PROTECT(pack = NEW_CHARACTER(1)); nprotect++; - SET_STRING_ELT(pack,0,mkChar("")); + PROTECT(pack = mkString("")); nprotect++; } PROTECT(nsi = eval(lang3(install("getNativeSymbolInfo"),nf,pack),R_BaseEnv)); nprotect++; PROTECT(f = getListElement(nsi,"address")); nprotect++; From noreply at r-forge.r-project.org Thu Feb 26 10:43:03 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 26 Feb 2015 10:43:03 +0100 (CET) Subject: [Pomp-commits] r1097 - in pkg/pomp: . R src Message-ID: <20150226094303.11BC718629D@r-forge.r-project.org> Author: kingaa Date: 2015-02-26 10:43:02 +0100 (Thu, 26 Feb 2015) New Revision: 1097 Modified: pkg/pomp/NAMESPACE pkg/pomp/R/builder.R pkg/pomp/src/pomp_fun.c Log: - use .Call interface for load-stack adjustments Modified: pkg/pomp/NAMESPACE =================================================================== --- pkg/pomp/NAMESPACE 2015-02-26 09:42:56 UTC (rev 1096) +++ pkg/pomp/NAMESPACE 2015-02-26 09:43:02 UTC (rev 1097) @@ -7,6 +7,7 @@ euler_model_simulator, euler_model_density, lookup_in_table, + load_stack_incr,load_stack_decr, SSA_simulator, R_Euler_Multinom,D_Euler_Multinom,R_GammaWN, mif_update, Modified: pkg/pomp/R/builder.R =================================================================== --- pkg/pomp/R/builder.R 2015-02-26 09:42:56 UTC (rev 1096) +++ pkg/pomp/R/builder.R 2015-02-26 09:43:02 UTC (rev 1097) @@ -83,7 +83,7 @@ dyn.load(lib[2]) if (verbose) cat("loading",sQuote(lib[2]),"\n") } - .C("__pomp_load_stack_incr",PACKAGE=lib[1]) + .Call(load_stack_incr,lib[1]) } invisible(NULL) } @@ -91,8 +91,7 @@ pompUnload.internal <- function (object, ..., verbose = getOption("verbose",FALSE)) { for (lib in object at solibfile) { if (is.loaded("__pomp_load_stack_decr",PACKAGE=lib[1])) { - st <- .C("__pomp_load_stack_decr",st=integer(1),PACKAGE=lib[1])$st - stopifnot(st>=0) + st <- .Call(load_stack_decr,lib[1]) if (st==0) { dyn.unload(lib[2]) if (verbose) cat("unloading",sQuote(lib[2]),"\n") @@ -125,15 +124,19 @@ header <- list( file="/* pomp model file: {%name%} */\n\n#include <{%pompheader%}>\n#include \n\n", + registration=" +void R_init_{%name%} (DllInfo *info) { + R_RegisterCCallable(\"{%name%}\", \"__pomp_load_stack_incr\", (DL_FUNC) __pomp_load_stack_incr); + R_RegisterCCallable(\"{%name%}\", \"__pomp_load_stack_decr\", (DL_FUNC) __pomp_load_stack_decr); +}\n\n", stackhandling=" static int __pomp_load_stack = 0;\n void __pomp_load_stack_incr (void) { ++__pomp_load_stack; }\n void __pomp_load_stack_decr (int *val) { - *val = (--__pomp_load_stack); -} -", + *val = --__pomp_load_stack; +}\n", rmeasure="\nvoid {%name%}_rmeasure (double *__y, double *__x, double *__p, int *__obsindex, int *__stateindex, int *__parindex, int *__covindex, int __ncovars, double *__covars, double t)\n{\n", dmeasure= "\nvoid {%name%}_dmeasure (double *__lik, double *__y, double *__x, double *__p, int give_log, int *__obsindex, int *__stateindex, int *__parindex, int *__covindex, int __ncovars, double *__covars, double t)\n{\n", step.fn="\nvoid {%name%}_stepfn (double *__x, const double *__p, const int *__stateindex, const int *__parindex, const int *__covindex, int __covdim, const double *__covars, double t, double dt)\n{\n", @@ -144,7 +147,6 @@ dprior="\nvoid {%name%}_dprior (double *__lik, double *__p, int give_log, int *__parindex)\n{\n" ) - fnames <- list( rmeasure="{%name%}_rmeasure", dmeasure= "{%name%}_dmeasure", @@ -209,8 +211,6 @@ if (is.null(name)) name <- randomName() if (is.null(dir)) dir <- tempdir() - has.trans <- !(missing(parameter.transform)) - if (missing(globals)) globals <- "" name <- cleanForC(name) @@ -264,17 +264,20 @@ } cat(file=out,render(define$var.alt,variable="lik",ptr='__lik',index=0)) - if (has.trans) { - ## parameter transformation function - cat(file=out,render(header$parameter.transform,name=name)) - cat(file=out,callable.decl(parameter.transform)) - cat(file=out,parameter.transform,footer$parameter.transform) - ## inverse parameter transformation function - cat(file=out,render(header$parameter.inv.transform,name=name)) - cat(file=out,callable.decl(parameter.inv.transform)) - cat(file=out,parameter.inv.transform,footer$parameter.inv.transform) - } + ## parameter transformation function + if (missing(parameter.transform)) + parameter.transform <- missing.fun("parameter.transform") + cat(file=out,render(header$parameter.transform,name=name)) + cat(file=out,callable.decl(parameter.transform)) + cat(file=out,parameter.transform,footer$parameter.transform) + ## inverse parameter transformation function + if (missing(parameter.inv.transform)) + parameter.inv.transform <- missing.fun("parameter.inv.transform") + cat(file=out,render(header$parameter.inv.transform,name=name)) + cat(file=out,callable.decl(parameter.inv.transform)) + cat(file=out,parameter.inv.transform,footer$parameter.inv.transform) + ## rmeasure function if (missing(rmeasure)) rmeasure <- missing.fun("rmeasure") cat(file=out,render(header$rmeasure,name=name),rmeasure,footer$rmeasure) @@ -325,6 +328,8 @@ cat(file=out,header$stackhandling) + cat(file=out,render(header$registration,name=name)) + close(out) cflags <- paste0("PKG_CFLAGS=\"", Modified: pkg/pomp/src/pomp_fun.c =================================================================== --- pkg/pomp/src/pomp_fun.c 2015-02-26 09:42:56 UTC (rev 1096) +++ pkg/pomp/src/pomp_fun.c 2015-02-26 09:43:02 UTC (rev 1097) @@ -42,3 +42,25 @@ UNPROTECT(nprotect); return f; } + +SEXP load_stack_incr (SEXP pack) { + char *pkg; + void (*ff)(void); + pkg = CHARACTER_DATA(STRING_ELT(pack,0)); + ff = R_GetCCallable(pkg,"__pomp_load_stack_incr"); + ff(); + return R_NilValue; +} + +SEXP load_stack_decr (SEXP pack) { + SEXP s; + char *pkg; + void (*ff)(int *); + PROTECT(s = NEW_INTEGER(1)); + pkg = CHARACTER_DATA(STRING_ELT(pack,0)); + ff = R_GetCCallable(pkg,"__pomp_load_stack_decr"); + ff(INTEGER(s)); + if (*(INTEGER(s)) < 0) error("impossible!"); + UNPROTECT(1); + return s; +} From noreply at r-forge.r-project.org Thu Feb 26 10:43:05 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 26 Feb 2015 10:43:05 +0100 (CET) Subject: [Pomp-commits] r1098 - in pkg/pomp: . inst Message-ID: <20150226094305.1BCE818629D@r-forge.r-project.org> Author: kingaa Date: 2015-02-26 10:43:04 +0100 (Thu, 26 Feb 2015) New Revision: 1098 Modified: pkg/pomp/NAMESPACE pkg/pomp/inst/NEWS pkg/pomp/inst/NEWS.Rd Log: - re-export 'pompLoad' and 'pompUnload' Modified: pkg/pomp/NAMESPACE =================================================================== --- pkg/pomp/NAMESPACE 2015-02-26 09:43:02 UTC (rev 1097) +++ pkg/pomp/NAMESPACE 2015-02-26 09:43:04 UTC (rev 1098) @@ -57,6 +57,7 @@ exportMethods( pomp, plot,show,print,coerce,summary,logLik,window,"$", + pompLoad,pompUnload, dprocess,rprocess,rmeasure,dmeasure,init.state,skeleton, dprior,rprior, data.array,obs,partrans,coef,"coef<-", Modified: pkg/pomp/inst/NEWS =================================================================== --- pkg/pomp/inst/NEWS 2015-02-26 09:43:02 UTC (rev 1097) +++ pkg/pomp/inst/NEWS 2015-02-26 09:43:04 UTC (rev 1098) @@ -5,8 +5,10 @@ ? When using ?Csnippet?s or ?pompBuilder?, it is no longer necessary to manually load and unload the dynamically loadable library. This is now handled automatically. - Accordingly, the ?link? argument of ?pompBuilder? and the - ?pompLoad? and ?pompUnload? functions have been removed. + Accordingly, the ?link? argument of ?pompBuilder? has been + removed. The ?pompLoad? and ?pompUnload? functions + introduced in 0.58-1 remain available, though they should + rarely be needed. _C_h_a_n_g_e_s _i_n '_p_o_m_p' _v_e_r_s_i_o_n _0._6_0-_1: Modified: pkg/pomp/inst/NEWS.Rd =================================================================== --- pkg/pomp/inst/NEWS.Rd 2015-02-26 09:43:02 UTC (rev 1097) +++ pkg/pomp/inst/NEWS.Rd 2015-02-26 09:43:04 UTC (rev 1098) @@ -4,7 +4,8 @@ \itemize{ \item When using \code{Csnippet}s or \code{pompBuilder}, it is no longer necessary to manually load and unload the dynamically loadable library. This is now handled automatically. - Accordingly, the \code{link} argument of \code{pompBuilder} and the \code{pompLoad} and \code{pompUnload} functions have been removed. + Accordingly, the \code{link} argument of \code{pompBuilder} has been removed. + The \code{pompLoad} and \code{pompUnload} functions introduced in 0.58-1 remain available, though they should rarely be needed. } } \section{Changes in \pkg{pomp} version 0.60-1}{ From noreply at r-forge.r-project.org Thu Feb 26 10:43:07 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 26 Feb 2015 10:43:07 +0100 (CET) Subject: [Pomp-commits] r1099 - pkg/pomp/R Message-ID: <20150226094307.3B2D118629D@r-forge.r-project.org> Author: kingaa Date: 2015-02-26 10:43:06 +0100 (Thu, 26 Feb 2015) New Revision: 1099 Modified: pkg/pomp/R/builder.R Log: - better templating Modified: pkg/pomp/R/builder.R =================================================================== --- pkg/pomp/R/builder.R 2015-02-26 09:43:04 UTC (rev 1098) +++ pkg/pomp/R/builder.R 2015-02-26 09:43:06 UTC (rev 1099) @@ -124,19 +124,7 @@ header <- list( file="/* pomp model file: {%name%} */\n\n#include <{%pompheader%}>\n#include \n\n", - registration=" -void R_init_{%name%} (DllInfo *info) { - R_RegisterCCallable(\"{%name%}\", \"__pomp_load_stack_incr\", (DL_FUNC) __pomp_load_stack_incr); - R_RegisterCCallable(\"{%name%}\", \"__pomp_load_stack_decr\", (DL_FUNC) __pomp_load_stack_decr); -}\n\n", - stackhandling=" -static int __pomp_load_stack = 0;\n -void __pomp_load_stack_incr (void) { - ++__pomp_load_stack; -}\n -void __pomp_load_stack_decr (int *val) { - *val = --__pomp_load_stack; -}\n", + registration="\nvoid R_init_{%name%} (DllInfo *info)\n{\n", rmeasure="\nvoid {%name%}_rmeasure (double *__y, double *__x, double *__p, int *__obsindex, int *__stateindex, int *__parindex, int *__covindex, int __ncovars, double *__covars, double t)\n{\n", dmeasure= "\nvoid {%name%}_dmeasure (double *__lik, double *__y, double *__x, double *__p, int give_log, int *__obsindex, int *__stateindex, int *__parindex, int *__covindex, int __ncovars, double *__covars, double t)\n{\n", step.fn="\nvoid {%name%}_stepfn (double *__x, const double *__p, const int *__stateindex, const int *__parindex, const int *__covindex, int __covdim, const double *__covars, double t, double dt)\n{\n", @@ -158,6 +146,19 @@ dprior="{%name%}_dprior" ) +regist <- list( + rmeasure="R_RegisterCCallable(\"{%name%}\", \"{%name%}_rmeasure\", (DL_FUNC) {%name%}_rmeasure);\n", + dmeasure="R_RegisterCCallable(\"{%name%}\", \"{%name%}_dmeasure\", (DL_FUNC) {%name%}_dmeasure);\n", + step.fn="R_RegisterCCallable(\"{%name%}\", \"{%name%}_stepfn\", (DL_FUNC) {%name%}_stepfn);\n", + skeleton="R_RegisterCCallable(\"{%name%}\", \"{%name%}_skelfn\", (DL_FUNC) {%name%}_skelfn);\n", + parameter.transform="R_RegisterCCallable(\"{%name%}\", \"{%name%}_par_trans\", (DL_FUNC) {%name%}_par_trans);\n", + parameter.inv.transform="R_RegisterCCallable(\"{%name%}\", \"{%name%}_par_untrans\", (DL_FUNC) {%name%}_par_untrans);\n", + rprior="R_RegisterCCallable(\"{%name%}\", \"{%name%}_rprior\", (DL_FUNC) {%name%}_rprior);\n", + dprior="R_RegisterCCallable(\"{%name%}\", \"{%name%}_dprior\", (DL_FUNC) {%name%}_dprior);\n", + loadstack.incr="R_RegisterCCallable(\"{%name%}\", \"__pomp_load_stack_incr\", (DL_FUNC) __pomp_load_stack_incr);\n", + loadstack.decr="R_RegisterCCallable(\"{%name%}\", \"__pomp_load_stack_decr\", (DL_FUNC) __pomp_load_stack_decr);\n" + ) + decl <- list( periodic_bspline_basis_eval="\tvoid (*periodic_bspline_basis_eval)(double,double,int,int,double*);\nperiodic_bspline_basis_eval = (void (*)(double,double,int,int,double*)) R_GetCCallable(\"pomp\",\"periodic_bspline_basis_eval\");\n", get_pomp_userdata_int="\tconst int * (*get_pomp_userdata_int)(const char *);\nget_pomp_userdata_int = (const int *(*)(const char*)) R_GetCCallable(\"pomp\",\"get_pomp_userdata_int\");\n", @@ -174,9 +175,19 @@ parameter.inv.transform="\n}\n\n", rprior="\n}\n\n", dprior="\n}\n\n", - globals="\n" + globals="\n", + registration="}\n\n" ) + stackhandling <- " +static int __pomp_load_stack = 0;\n +void __pomp_load_stack_incr (void) { + ++__pomp_load_stack; +}\n +void __pomp_load_stack_decr (int *val) { + *val = --__pomp_load_stack; +}\n" + utility.fns <- list() callable.decl <- function (code) { @@ -326,9 +337,13 @@ cat(file=out,render(undefine$var,variable=paste0("T",paramnames[v]))) } - cat(file=out,header$stackhandling) + cat(file=out,stackhandling) + ## registration cat(file=out,render(header$registration,name=name)) + for (v in names(regist)) + cat(file=out,render(regist[[v]],name=name)) + cat(file=out,footer$registration) close(out) From noreply at r-forge.r-project.org Thu Feb 26 10:43:09 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 26 Feb 2015 10:43:09 +0100 (CET) Subject: [Pomp-commits] r1100 - pkg/pomp/R Message-ID: <20150226094309.4186918629D@r-forge.r-project.org> Author: kingaa Date: 2015-02-26 10:43:09 +0100 (Thu, 26 Feb 2015) New Revision: 1100 Modified: pkg/pomp/R/builder.R Log: - move templates Modified: pkg/pomp/R/builder.R =================================================================== --- pkg/pomp/R/builder.R 2015-02-26 09:43:06 UTC (rev 1099) +++ pkg/pomp/R/builder.R 2015-02-26 09:43:09 UTC (rev 1100) @@ -113,83 +113,6 @@ pompUnload.internal(object,...) }) -define <- list( - var="#define {%variable%}\t({%ptr%}[{%ilist%}[{%index%}]])\n", - var.alt="#define {%variable%}\t({%ptr%}[{%index%}])\n" - ) - -undefine <- list( - var="#undef {%variable%}\n" - ) - -header <- list( - file="/* pomp model file: {%name%} */\n\n#include <{%pompheader%}>\n#include \n\n", - registration="\nvoid R_init_{%name%} (DllInfo *info)\n{\n", - rmeasure="\nvoid {%name%}_rmeasure (double *__y, double *__x, double *__p, int *__obsindex, int *__stateindex, int *__parindex, int *__covindex, int __ncovars, double *__covars, double t)\n{\n", - dmeasure= "\nvoid {%name%}_dmeasure (double *__lik, double *__y, double *__x, double *__p, int give_log, int *__obsindex, int *__stateindex, int *__parindex, int *__covindex, int __ncovars, double *__covars, double t)\n{\n", - step.fn="\nvoid {%name%}_stepfn (double *__x, const double *__p, const int *__stateindex, const int *__parindex, const int *__covindex, int __covdim, const double *__covars, double t, double dt)\n{\n", - skeleton="\nvoid {%name%}_skelfn (double *__f, double *__x, double *__p, int *__stateindex, int *__parindex, int *__covindex, int __ncovars, double *__covars, double t)\n{\n", - parameter.transform="\nvoid {%name%}_par_trans (double *__pt, double *__p, int *__parindex)\n{\n", - parameter.inv.transform="\nvoid {%name%}_par_untrans (double *__pt, double *__p, int *__parindex)\n{\n", - rprior="\nvoid {%name%}_rprior (double *__p, int *__parindex)\n{\n", - dprior="\nvoid {%name%}_dprior (double *__lik, double *__p, int give_log, int *__parindex)\n{\n" - ) - -fnames <- list( - rmeasure="{%name%}_rmeasure", - dmeasure= "{%name%}_dmeasure", - step.fn="{%name%}_stepfn", - skeleton="{%name%}_skelfn", - parameter.transform="{%name%}_par_trans", - parameter.inv.transform="{%name%}_par_untrans", - rprior="{%name%}_rprior", - dprior="{%name%}_dprior" - ) - -regist <- list( - rmeasure="R_RegisterCCallable(\"{%name%}\", \"{%name%}_rmeasure\", (DL_FUNC) {%name%}_rmeasure);\n", - dmeasure="R_RegisterCCallable(\"{%name%}\", \"{%name%}_dmeasure\", (DL_FUNC) {%name%}_dmeasure);\n", - step.fn="R_RegisterCCallable(\"{%name%}\", \"{%name%}_stepfn\", (DL_FUNC) {%name%}_stepfn);\n", - skeleton="R_RegisterCCallable(\"{%name%}\", \"{%name%}_skelfn\", (DL_FUNC) {%name%}_skelfn);\n", - parameter.transform="R_RegisterCCallable(\"{%name%}\", \"{%name%}_par_trans\", (DL_FUNC) {%name%}_par_trans);\n", - parameter.inv.transform="R_RegisterCCallable(\"{%name%}\", \"{%name%}_par_untrans\", (DL_FUNC) {%name%}_par_untrans);\n", - rprior="R_RegisterCCallable(\"{%name%}\", \"{%name%}_rprior\", (DL_FUNC) {%name%}_rprior);\n", - dprior="R_RegisterCCallable(\"{%name%}\", \"{%name%}_dprior\", (DL_FUNC) {%name%}_dprior);\n", - loadstack.incr="R_RegisterCCallable(\"{%name%}\", \"__pomp_load_stack_incr\", (DL_FUNC) __pomp_load_stack_incr);\n", - loadstack.decr="R_RegisterCCallable(\"{%name%}\", \"__pomp_load_stack_decr\", (DL_FUNC) __pomp_load_stack_decr);\n" - ) - -decl <- list( - periodic_bspline_basis_eval="\tvoid (*periodic_bspline_basis_eval)(double,double,int,int,double*);\nperiodic_bspline_basis_eval = (void (*)(double,double,int,int,double*)) R_GetCCallable(\"pomp\",\"periodic_bspline_basis_eval\");\n", - get_pomp_userdata_int="\tconst int * (*get_pomp_userdata_int)(const char *);\nget_pomp_userdata_int = (const int *(*)(const char*)) R_GetCCallable(\"pomp\",\"get_pomp_userdata_int\");\n", - get_pomp_userdata_double="\tconst double * (*get_pomp_userdata_double)(const char *);\nget_pomp_userdata_double = (const double *(*)(const char*)) R_GetCCallable(\"pomp\",\"get_pomp_userdata_double\");\n", - `get_pomp_userdata(\\b|[^_])`="\tconst SEXP (*get_pomp_userdata)(const char *);\nget_pomp_userdata = (const SEXP (*)(const char*)) R_GetCCallable(\"pomp\",\"get_pomp_userdata\");\n" - ) - -footer <- list( - rmeasure="\n}\n\n", - dmeasure="\n}\n\n", - step.fn="\n}\n\n", - skeleton="\n}\n\n", - parameter.transform="\n}\n\n", - parameter.inv.transform="\n}\n\n", - rprior="\n}\n\n", - dprior="\n}\n\n", - globals="\n", - registration="}\n\n" - ) - - stackhandling <- " -static int __pomp_load_stack = 0;\n -void __pomp_load_stack_incr (void) { - ++__pomp_load_stack; -}\n -void __pomp_load_stack_decr (int *val) { - *val = --__pomp_load_stack; -}\n" - -utility.fns <- list() - callable.decl <- function (code) { fns <- vapply(names(decl),grepl,logical(1),code,perl=TRUE) do.call(paste0,decl[fns]) @@ -394,3 +317,81 @@ do.call(paste0,retval) } +## TEMPLATES + +define <- list( + var="#define {%variable%}\t({%ptr%}[{%ilist%}[{%index%}]])\n", + var.alt="#define {%variable%}\t({%ptr%}[{%index%}])\n" + ) + +undefine <- list( + var="#undef {%variable%}\n" + ) + +header <- list( + file="/* pomp model file: {%name%} */\n\n#include <{%pompheader%}>\n#include \n\n", + registration="\nvoid R_init_{%name%} (DllInfo *info)\n{\n", + rmeasure="\nvoid {%name%}_rmeasure (double *__y, double *__x, double *__p, int *__obsindex, int *__stateindex, int *__parindex, int *__covindex, int __ncovars, double *__covars, double t)\n{\n", + dmeasure= "\nvoid {%name%}_dmeasure (double *__lik, double *__y, double *__x, double *__p, int give_log, int *__obsindex, int *__stateindex, int *__parindex, int *__covindex, int __ncovars, double *__covars, double t)\n{\n", + step.fn="\nvoid {%name%}_stepfn (double *__x, const double *__p, const int *__stateindex, const int *__parindex, const int *__covindex, int __covdim, const double *__covars, double t, double dt)\n{\n", + skeleton="\nvoid {%name%}_skelfn (double *__f, double *__x, double *__p, int *__stateindex, int *__parindex, int *__covindex, int __ncovars, double *__covars, double t)\n{\n", + parameter.transform="\nvoid {%name%}_par_trans (double *__pt, double *__p, int *__parindex)\n{\n", + parameter.inv.transform="\nvoid {%name%}_par_untrans (double *__pt, double *__p, int *__parindex)\n{\n", + rprior="\nvoid {%name%}_rprior (double *__p, int *__parindex)\n{\n", + dprior="\nvoid {%name%}_dprior (double *__lik, double *__p, int give_log, int *__parindex)\n{\n" + ) + +fnames <- list( + rmeasure="{%name%}_rmeasure", + dmeasure= "{%name%}_dmeasure", + step.fn="{%name%}_stepfn", + skeleton="{%name%}_skelfn", + parameter.transform="{%name%}_par_trans", + parameter.inv.transform="{%name%}_par_untrans", + rprior="{%name%}_rprior", + dprior="{%name%}_dprior" + ) + +regist <- list( + rmeasure="R_RegisterCCallable(\"{%name%}\", \"{%name%}_rmeasure\", (DL_FUNC) {%name%}_rmeasure);\n", + dmeasure="R_RegisterCCallable(\"{%name%}\", \"{%name%}_dmeasure\", (DL_FUNC) {%name%}_dmeasure);\n", + step.fn="R_RegisterCCallable(\"{%name%}\", \"{%name%}_stepfn\", (DL_FUNC) {%name%}_stepfn);\n", + skeleton="R_RegisterCCallable(\"{%name%}\", \"{%name%}_skelfn\", (DL_FUNC) {%name%}_skelfn);\n", + parameter.transform="R_RegisterCCallable(\"{%name%}\", \"{%name%}_par_trans\", (DL_FUNC) {%name%}_par_trans);\n", + parameter.inv.transform="R_RegisterCCallable(\"{%name%}\", \"{%name%}_par_untrans\", (DL_FUNC) {%name%}_par_untrans);\n", + rprior="R_RegisterCCallable(\"{%name%}\", \"{%name%}_rprior\", (DL_FUNC) {%name%}_rprior);\n", + dprior="R_RegisterCCallable(\"{%name%}\", \"{%name%}_dprior\", (DL_FUNC) {%name%}_dprior);\n", + loadstack.incr="R_RegisterCCallable(\"{%name%}\", \"__pomp_load_stack_incr\", (DL_FUNC) __pomp_load_stack_incr);\n", + loadstack.decr="R_RegisterCCallable(\"{%name%}\", \"__pomp_load_stack_decr\", (DL_FUNC) __pomp_load_stack_decr);\n" + ) + +decl <- list( + periodic_bspline_basis_eval="\tvoid (*periodic_bspline_basis_eval)(double,double,int,int,double*);\nperiodic_bspline_basis_eval = (void (*)(double,double,int,int,double*)) R_GetCCallable(\"pomp\",\"periodic_bspline_basis_eval\");\n", + get_pomp_userdata_int="\tconst int * (*get_pomp_userdata_int)(const char *);\nget_pomp_userdata_int = (const int *(*)(const char*)) R_GetCCallable(\"pomp\",\"get_pomp_userdata_int\");\n", + get_pomp_userdata_double="\tconst double * (*get_pomp_userdata_double)(const char *);\nget_pomp_userdata_double = (const double *(*)(const char*)) R_GetCCallable(\"pomp\",\"get_pomp_userdata_double\");\n", + `get_pomp_userdata(\\b|[^_])`="\tconst SEXP (*get_pomp_userdata)(const char *);\nget_pomp_userdata = (const SEXP (*)(const char*)) R_GetCCallable(\"pomp\",\"get_pomp_userdata\");\n" + ) + +footer <- list( + rmeasure="\n}\n\n", + dmeasure="\n}\n\n", + step.fn="\n}\n\n", + skeleton="\n}\n\n", + parameter.transform="\n}\n\n", + parameter.inv.transform="\n}\n\n", + rprior="\n}\n\n", + dprior="\n}\n\n", + globals="\n", + registration="}\n\n" + ) + +stackhandling <- " +static int __pomp_load_stack = 0;\n +void __pomp_load_stack_incr (void) { + ++__pomp_load_stack; +}\n +void __pomp_load_stack_decr (int *val) { + *val = --__pomp_load_stack; +}\n" + +utility.fns <- list() From noreply at r-forge.r-project.org Thu Feb 26 10:43:11 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 26 Feb 2015 10:43:11 +0100 (CET) Subject: [Pomp-commits] r1101 - pkg/pomp/R Message-ID: <20150226094311.9B74518629D@r-forge.r-project.org> Author: kingaa Date: 2015-02-26 10:43:11 +0100 (Thu, 26 Feb 2015) New Revision: 1101 Modified: pkg/pomp/R/builder.R Log: - rename functions in C files built by pompCBuilder Modified: pkg/pomp/R/builder.R =================================================================== --- pkg/pomp/R/builder.R 2015-02-26 09:43:09 UTC (rev 1100) +++ pkg/pomp/R/builder.R 2015-02-26 09:43:11 UTC (rev 1101) @@ -331,36 +331,36 @@ header <- list( file="/* pomp model file: {%name%} */\n\n#include <{%pompheader%}>\n#include \n\n", registration="\nvoid R_init_{%name%} (DllInfo *info)\n{\n", - rmeasure="\nvoid {%name%}_rmeasure (double *__y, double *__x, double *__p, int *__obsindex, int *__stateindex, int *__parindex, int *__covindex, int __ncovars, double *__covars, double t)\n{\n", - dmeasure= "\nvoid {%name%}_dmeasure (double *__lik, double *__y, double *__x, double *__p, int give_log, int *__obsindex, int *__stateindex, int *__parindex, int *__covindex, int __ncovars, double *__covars, double t)\n{\n", - step.fn="\nvoid {%name%}_stepfn (double *__x, const double *__p, const int *__stateindex, const int *__parindex, const int *__covindex, int __covdim, const double *__covars, double t, double dt)\n{\n", - skeleton="\nvoid {%name%}_skelfn (double *__f, double *__x, double *__p, int *__stateindex, int *__parindex, int *__covindex, int __ncovars, double *__covars, double t)\n{\n", - parameter.transform="\nvoid {%name%}_par_trans (double *__pt, double *__p, int *__parindex)\n{\n", - parameter.inv.transform="\nvoid {%name%}_par_untrans (double *__pt, double *__p, int *__parindex)\n{\n", - rprior="\nvoid {%name%}_rprior (double *__p, int *__parindex)\n{\n", - dprior="\nvoid {%name%}_dprior (double *__lik, double *__p, int give_log, int *__parindex)\n{\n" + rmeasure="\nvoid __pomp_rmeasure (double *__y, double *__x, double *__p, int *__obsindex, int *__stateindex, int *__parindex, int *__covindex, int __ncovars, double *__covars, double t)\n{\n", + dmeasure= "\nvoid __pomp_dmeasure (double *__lik, double *__y, double *__x, double *__p, int give_log, int *__obsindex, int *__stateindex, int *__parindex, int *__covindex, int __ncovars, double *__covars, double t)\n{\n", + step.fn="\nvoid __pomp_stepfn (double *__x, const double *__p, const int *__stateindex, const int *__parindex, const int *__covindex, int __covdim, const double *__covars, double t, double dt)\n{\n", + skeleton="\nvoid __pomp_skelfn (double *__f, double *__x, double *__p, int *__stateindex, int *__parindex, int *__covindex, int __ncovars, double *__covars, double t)\n{\n", + parameter.transform="\nvoid __pomp_par_trans (double *__pt, double *__p, int *__parindex)\n{\n", + parameter.inv.transform="\nvoid __pomp_par_untrans (double *__pt, double *__p, int *__parindex)\n{\n", + rprior="\nvoid __pomp_rprior (double *__p, int *__parindex)\n{\n", + dprior="\nvoid __pomp_dprior (double *__lik, double *__p, int give_log, int *__parindex)\n{\n" ) fnames <- list( - rmeasure="{%name%}_rmeasure", - dmeasure= "{%name%}_dmeasure", - step.fn="{%name%}_stepfn", - skeleton="{%name%}_skelfn", - parameter.transform="{%name%}_par_trans", - parameter.inv.transform="{%name%}_par_untrans", - rprior="{%name%}_rprior", - dprior="{%name%}_dprior" + rmeasure="__pomp_rmeasure", + dmeasure= "__pomp_dmeasure", + step.fn="__pomp_stepfn", + skeleton="__pomp_skelfn", + parameter.transform="__pomp_par_trans", + parameter.inv.transform="__pomp_par_untrans", + rprior="__pomp_rprior", + dprior="__pomp_dprior" ) regist <- list( - rmeasure="R_RegisterCCallable(\"{%name%}\", \"{%name%}_rmeasure\", (DL_FUNC) {%name%}_rmeasure);\n", - dmeasure="R_RegisterCCallable(\"{%name%}\", \"{%name%}_dmeasure\", (DL_FUNC) {%name%}_dmeasure);\n", - step.fn="R_RegisterCCallable(\"{%name%}\", \"{%name%}_stepfn\", (DL_FUNC) {%name%}_stepfn);\n", - skeleton="R_RegisterCCallable(\"{%name%}\", \"{%name%}_skelfn\", (DL_FUNC) {%name%}_skelfn);\n", - parameter.transform="R_RegisterCCallable(\"{%name%}\", \"{%name%}_par_trans\", (DL_FUNC) {%name%}_par_trans);\n", - parameter.inv.transform="R_RegisterCCallable(\"{%name%}\", \"{%name%}_par_untrans\", (DL_FUNC) {%name%}_par_untrans);\n", - rprior="R_RegisterCCallable(\"{%name%}\", \"{%name%}_rprior\", (DL_FUNC) {%name%}_rprior);\n", - dprior="R_RegisterCCallable(\"{%name%}\", \"{%name%}_dprior\", (DL_FUNC) {%name%}_dprior);\n", + rmeasure="R_RegisterCCallable(\"{%name%}\", \"__pomp_rmeasure\", (DL_FUNC) __pomp_rmeasure);\n", + dmeasure="R_RegisterCCallable(\"{%name%}\", \"__pomp_dmeasure\", (DL_FUNC) __pomp_dmeasure);\n", + step.fn="R_RegisterCCallable(\"{%name%}\", \"__pomp_stepfn\", (DL_FUNC) __pomp_stepfn);\n", + skeleton="R_RegisterCCallable(\"{%name%}\", \"__pomp_skelfn\", (DL_FUNC) __pomp_skelfn);\n", + parameter.transform="R_RegisterCCallable(\"{%name%}\", \"__pomp_par_trans\", (DL_FUNC) __pomp_par_trans);\n", + parameter.inv.transform="R_RegisterCCallable(\"{%name%}\", \"__pomp_par_untrans\", (DL_FUNC) __pomp_par_untrans);\n", + rprior="R_RegisterCCallable(\"{%name%}\", \"__pomp_rprior\", (DL_FUNC) __pomp_rprior);\n", + dprior="R_RegisterCCallable(\"{%name%}\", \"__pomp_dprior\", (DL_FUNC) __pomp_dprior);\n", loadstack.incr="R_RegisterCCallable(\"{%name%}\", \"__pomp_load_stack_incr\", (DL_FUNC) __pomp_load_stack_incr);\n", loadstack.decr="R_RegisterCCallable(\"{%name%}\", \"__pomp_load_stack_decr\", (DL_FUNC) __pomp_load_stack_decr);\n" ) From noreply at r-forge.r-project.org Thu Feb 26 10:43:14 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 26 Feb 2015 10:43:14 +0100 (CET) Subject: [Pomp-commits] r1102 - in pkg/pomp: R src Message-ID: <20150226094314.66FEF18629D@r-forge.r-project.org> Author: kingaa Date: 2015-02-26 10:43:14 +0100 (Thu, 26 Feb 2015) New Revision: 1102 Modified: pkg/pomp/R/pomp-fun.R pkg/pomp/R/pomp.R pkg/pomp/src/dmeasure.c pkg/pomp/src/dprior.c pkg/pomp/src/euler.c pkg/pomp/src/partrans.c pkg/pomp/src/pomp_fun.c pkg/pomp/src/pomp_internal.h pkg/pomp/src/rmeasure.c pkg/pomp/src/rprior.c pkg/pomp/src/skeleton.c pkg/pomp/src/trajectory.c Log: - use R_GetCCallable() instead of getNativeSymbolInfo() when Csnippet codes are used - replace int mode with enum mode Modified: pkg/pomp/R/pomp-fun.R =================================================================== --- pkg/pomp/R/pomp-fun.R 2015-02-26 09:43:11 UTC (rev 1101) +++ pkg/pomp/R/pomp-fun.R 2015-02-26 09:43:14 UTC (rev 1102) @@ -1,6 +1,8 @@ ## a class for functions that may be defined in R, ## using pre-written native routines, or C snippets +pompfunmode <- list(undef=-1L,Rfun=0L,native=1L,regNative=2L) + setClass( 'pomp.fun', slots=c( @@ -20,7 +22,7 @@ }, native.fun=character(0), PACKAGE=character(0), - mode=-1L, ## undefined behavior + mode=pompfunmode$undef, obsnames = character(0), statenames = character(0), paramnames = character(0), @@ -58,7 +60,7 @@ stop(sQuote(fname)," must be a function of prototype ", deparse(proto),call.=FALSE) } - new("pomp.fun",R.fun=f,mode=1L) + new("pomp.fun",R.fun=f,mode=pompfunmode$Rfun) } ) @@ -72,7 +74,7 @@ "pomp.fun", native.fun=f, PACKAGE=as.character(PACKAGE), - mode=2L, + mode=pompfunmode$native, obsnames=obsnames, statenames=statenames, paramnames=paramnames, @@ -97,7 +99,7 @@ "pomp.fun", native.fun=render(fnames[[slotname]],name=libname), PACKAGE=as.character(libname), - mode=2L, + mode=pompfunmode$regNative, obsnames=obsnames, statenames=statenames, paramnames=paramnames, @@ -114,16 +116,21 @@ setMethod( 'show', - 'pomp.fun', - function (object) { + signature=signature('pomp.fun'), + definition=function (object) { mode <- object at mode - if (mode==1L) { + if (mode==pompfunmode$Rfun) { # R function show(object at R.fun) - } else if (mode==2L) { + } else if (mode==pompfunmode$native) { # user supplied native code cat("native function ",sQuote(object at native.fun),sep="") if (length(object at PACKAGE)>0) cat(", dynamically loaded from ",sQuote(object at PACKAGE),sep="") cat ("\n") + } else if (mode==pompfunmode$regNative) { # built from Csnippets + cat("native function ",sQuote(object at native.fun),sep="") + if (length(object at PACKAGE)>0) + cat(", dynamically loaded from ",sQuote(object at PACKAGE),sep="") + cat ("\n") } else { cat("function not specified\n") } Modified: pkg/pomp/R/pomp.R =================================================================== --- pkg/pomp/R/pomp.R 2015-02-26 09:43:11 UTC (rev 1101) +++ pkg/pomp/R/pomp.R 2015-02-26 09:43:14 UTC (rev 1102) @@ -318,25 +318,28 @@ par.trans <- pomp.fun() par.untrans <- pomp.fun() } - if (has.trans && par.trans at mode<0 && par.untrans at mode<0) has.trans <- FALSE + if (has.trans && + par.trans at mode==pompfunmode$undef && + par.untrans at mode==pompfunmode$undef + ) has.trans <- FALSE if (nrow(covar)>0) { if ( - (skeleton at mode==1L) + (skeleton at mode==pompfunmode$Rfun) &&!("covars"%in%names(formals(skeleton at R.fun))) ) warning("a covariate table has been given, yet the ", sQuote("skeleton")," function does not have ", sQuote("covars")," as a formal argument",call.=FALSE) if ( - (rmeasure at mode==1L) + (rmeasure at mode==pompfunmode$Rfun) &&!("covars"%in%names(formals(rmeasure at R.fun))) ) warning("a covariate table has been given, yet the ", sQuote("rmeasure")," function does not have ", sQuote("covars")," as a formal argument",call.=FALSE) if ( - (dmeasure at mode==1L) + (dmeasure at mode==pompfunmode$Rfun) &&!("covars"%in%names(formals(dmeasure at R.fun))) ) warning("a covariate table has been given, yet the ", Modified: pkg/pomp/src/dmeasure.c =================================================================== --- pkg/pomp/src/dmeasure.c 2015-02-26 09:43:11 UTC (rev 1101) +++ pkg/pomp/src/dmeasure.c 2015-02-26 09:43:14 UTC (rev 1102) @@ -11,7 +11,7 @@ SEXP do_dmeasure (SEXP object, SEXP y, SEXP x, SEXP times, SEXP params, SEXP log, SEXP gnsi) { int nprotect = 0; - int mode = -1; + pompfunmode mode = undef; int give_log; int ntimes, nvars, npars, ncovars, nreps, nrepsx, nrepsp, nobs; SEXP Snames, Pnames, Cnames, Onames; @@ -76,7 +76,7 @@ // first do setup switch (mode) { - case 0: // R function + case Rfun: // R function PROTECT(tvec = NEW_NUMERIC(1)); nprotect++; PROTECT(xvec = NEW_NUMERIC(nvars)); nprotect++; @@ -106,7 +106,7 @@ break; - case 1: // native code + case native: // native code // construct state, parameter, covariate, observable indices oidx = INTEGER(PROTECT(name_index(Onames,pompfun,"obsnames"))); nprotect++; @@ -137,7 +137,7 @@ // now do computations switch (mode) { - case 0: // R function + case Rfun: // R function { int first = 1; @@ -190,7 +190,7 @@ break; - case 1: // native code + case native: // native code set_pomp_userdata(fcall); Modified: pkg/pomp/src/dprior.c =================================================================== --- pkg/pomp/src/dprior.c 2015-02-26 09:43:11 UTC (rev 1101) +++ pkg/pomp/src/dprior.c 2015-02-26 09:43:14 UTC (rev 1102) @@ -15,7 +15,7 @@ SEXP do_dprior (SEXP object, SEXP params, SEXP log, SEXP gnsi) { int nprotect = 0; - int mode = -1; + pompfunmode mode = undef; int npars, nreps; SEXP Pnames, F, fn, fcall; SEXP pompfun; @@ -39,7 +39,7 @@ // first do setup switch (mode) { - case 0: // use R function + case Rfun: // use R function { SEXP pvec, rho, ans; @@ -74,7 +74,7 @@ break; - case 1: // use native routine + case native: // use native routine { int give_log, *pidx = 0; Modified: pkg/pomp/src/euler.c =================================================================== --- pkg/pomp/src/euler.c 2015-02-26 09:43:11 UTC (rev 1101) +++ pkg/pomp/src/euler.c 2015-02-26 09:43:14 UTC (rev 1102) @@ -9,7 +9,7 @@ SEXP tcovar, SEXP covar, SEXP args, SEXP gnsi) { int nprotect = 0; - int mode = -1; + pompfunmode mode = undef; int nstep, nvars, npars, nreps, ntimes, nzeros, ncovars, covlen; SEXP X; SEXP fn, fcall, rho, ans, nm; @@ -48,7 +48,7 @@ // set up switch (mode) { - case 0: // R function + case Rfun: // R function PROTECT(dtvec = NEW_NUMERIC(1)); nprotect++; PROTECT(tvec = NEW_NUMERIC(1)); nprotect++; @@ -75,7 +75,7 @@ break; - case 1: // native code + case native: // native code // construct state, parameter, covariate indices sidx = INTEGER(PROTECT(matchnames(Snames,GET_SLOT(func,install("statenames")),"state variables"))); nprotect++; @@ -87,7 +87,7 @@ break; default: - error("unrecognized 'mode' in 'euler_simulator'"); + error("unrecognized 'mode' %d in 'euler_simulator'",mode); break; } @@ -163,7 +163,7 @@ switch (mode) { - case 0: // R function + case Rfun: // R function { double *xp = REAL(xvec); @@ -211,13 +211,13 @@ break; - case 1: // native code + case native: // native code (*ff)(xm,pm,sidx,pidx,cidx,ncovars,cp,t,dt); break; default: - error("unrecognized 'mode' in 'euler_simulator'"); + error("unrecognized 'mode' %d in 'euler_simulator'",mode); break; } @@ -283,7 +283,7 @@ switch (mode) { - case 0: // R function + case Rfun: // R function PROTECT(t1vec = NEW_NUMERIC(1)); nprotect++; PROTECT(t2vec = NEW_NUMERIC(1)); nprotect++; @@ -313,7 +313,7 @@ break; - case 1: // native code + case native: // native code // construct state, parameter, covariate indices sidx = INTEGER(PROTECT(matchnames(Snames,GET_SLOT(func,install("statenames")),"state variables"))); nprotect++; @@ -325,7 +325,7 @@ break; default: - error("unrecognized 'mode' in 'euler_model_density'"); + error("unrecognized 'mode' %d in 'euler_model_density'",mode); break; } @@ -337,7 +337,7 @@ switch (mode) { - case 0: // R function + case Rfun: // R function { double *cp = REAL(cvec); @@ -379,7 +379,7 @@ break; - case 1: // native code + case native: // native code set_pomp_userdata(args); @@ -415,7 +415,7 @@ break; default: - error("unrecognized 'mode' in 'euler_model_density'"); + error("unrecognized 'mode' %d in 'euler_model_density'",mode); break; } Modified: pkg/pomp/src/partrans.c =================================================================== --- pkg/pomp/src/partrans.c 2015-02-26 09:43:11 UTC (rev 1101) +++ pkg/pomp/src/partrans.c 2015-02-26 09:43:14 UTC (rev 1102) @@ -14,7 +14,7 @@ SEXP pdim, pvec; SEXP pompfun; SEXP tparams = R_NilValue; - int mode = -1; + pompfunmode mode = undef; char direc; int qmat; int ndim[2], *dim, *idx; @@ -54,7 +54,7 @@ switch (mode) { - case 0: // use user-supplied R function + case Rfun: // use user-supplied R function // set up the function call if (qmat) { // matrix case @@ -110,7 +110,7 @@ break; - case 1: // use native routine + case native: // use native routine ff = (pomp_transform_fn *) R_ExternalPtrAddr(fn); Modified: pkg/pomp/src/pomp_fun.c =================================================================== --- pkg/pomp/src/pomp_fun.c 2015-02-26 09:43:11 UTC (rev 1101) +++ pkg/pomp/src/pomp_fun.c 2015-02-26 09:43:14 UTC (rev 1102) @@ -9,31 +9,65 @@ // returns either the R function or the address of the native routine // on return, use_native tells whether to use the native or the R function -SEXP pomp_fun_handler (SEXP pfun, SEXP gnsi, int *mode) +SEXP pomp_fun_handler (SEXP pfun, SEXP gnsi, pompfunmode *mode) { int nprotect = 0; - SEXP nf, pack, nsi, f = R_NilValue; + SEXP f = R_NilValue; - *mode = *(INTEGER(GET_SLOT(pfun,install("mode"))))-1; + *mode = *(INTEGER(GET_SLOT(pfun,install("mode")))); switch (*mode) { - case 0: // R function + + case Rfun: // R function + PROTECT(f = GET_SLOT(pfun,install("R.fun"))); nprotect++; + break; - case 1: // native code - if (*(INTEGER(gnsi))) { // get native symbol information + + case native: case regNative: // native code + + if (*(INTEGER(gnsi))) { // get native symbol information? + + SEXP nf, pack; PROTECT(nf = GET_SLOT(pfun,install("native.fun"))); nprotect++; PROTECT(pack = GET_SLOT(pfun,install("PACKAGE"))); nprotect++; if (LENGTH(pack) < 1) { PROTECT(pack = mkString("")); nprotect++; } - PROTECT(nsi = eval(lang3(install("getNativeSymbolInfo"),nf,pack),R_BaseEnv)); nprotect++; - PROTECT(f = getListElement(nsi,"address")); nprotect++; + + switch (*mode) { + case native: + { + SEXP nsi; + PROTECT(nsi = eval(lang3(install("getNativeSymbolInfo"),nf,pack),R_BaseEnv)); nprotect++; + PROTECT(f = getListElement(nsi,"address")); nprotect++; + } + break; + + case regNative: + { + const char *fname, *pkg; + DL_FUNC ff; + fname = (const char *) CHARACTER_DATA(STRING_ELT(nf,0)); + pkg = (const char *) CHARACTER_DATA(STRING_ELT(pack,0)); + ff = R_GetCCallable(pkg,fname); + PROTECT(f = R_MakeExternalPtr(ff,pfun,R_NilValue)); nprotect++; + } + break; + } + SET_SLOT(pfun,install("address"),f); - } else { + + } else { // native symbol info is stored + PROTECT(f = GET_SLOT(pfun,install("address"))); nprotect++; + } + + *mode = native; + break; + default: error("operation cannot be completed: some needed function has not been specified"); break; @@ -44,21 +78,21 @@ } SEXP load_stack_incr (SEXP pack) { - char *pkg; + const char *pkg; void (*ff)(void); - pkg = CHARACTER_DATA(STRING_ELT(pack,0)); - ff = R_GetCCallable(pkg,"__pomp_load_stack_incr"); + pkg = (const char *) CHARACTER_DATA(STRING_ELT(pack,0)); + ff = (void (*)(void)) R_GetCCallable(pkg,"__pomp_load_stack_incr"); ff(); return R_NilValue; } SEXP load_stack_decr (SEXP pack) { SEXP s; - char *pkg; + const char *pkg; void (*ff)(int *); PROTECT(s = NEW_INTEGER(1)); - pkg = CHARACTER_DATA(STRING_ELT(pack,0)); - ff = R_GetCCallable(pkg,"__pomp_load_stack_decr"); + pkg = (const char *) CHARACTER_DATA(STRING_ELT(pack,0)); + ff = (void (*)(int *)) R_GetCCallable(pkg,"__pomp_load_stack_decr"); ff(INTEGER(s)); if (*(INTEGER(s)) < 0) error("impossible!"); UNPROTECT(1); Modified: pkg/pomp/src/pomp_internal.h =================================================================== --- pkg/pomp/src/pomp_internal.h 2015-02-26 09:43:11 UTC (rev 1101) +++ pkg/pomp/src/pomp_internal.h 2015-02-26 09:43:14 UTC (rev 1102) @@ -40,7 +40,8 @@ SEXP sobol_sequence(SEXP dim); // pomp_fun.c -SEXP pomp_fun_handler (SEXP pfun, SEXP gnsi, int *mode); +typedef enum {undef=-1,Rfun=0,native=1,regNative=2} pompfunmode; +SEXP pomp_fun_handler (SEXP pfun, SEXP gnsi, pompfunmode *mode); // lookup_table.c SEXP lookup_in_table (SEXP ttable, SEXP xtable, SEXP t); Modified: pkg/pomp/src/rmeasure.c =================================================================== --- pkg/pomp/src/rmeasure.c 2015-02-26 09:43:11 UTC (rev 1101) +++ pkg/pomp/src/rmeasure.c 2015-02-26 09:43:14 UTC (rev 1102) @@ -11,7 +11,7 @@ SEXP do_rmeasure (SEXP object, SEXP x, SEXP times, SEXP params, SEXP gnsi) { int nprotect = 0; - int mode = -1; + pompfunmode mode = undef; int ntimes, nvars, npars, ncovars, nreps, nrepsx, nrepsp, nobs; SEXP Snames, Pnames, Cnames, Onames; SEXP tvec, xvec, pvec, cvec; @@ -76,7 +76,7 @@ // first do setup switch (mode) { - case 0: // use R function + case Rfun: // use R function PROTECT(tvec = NEW_NUMERIC(1)); nprotect++; PROTECT(xvec = NEW_NUMERIC(nvars)); nprotect++; @@ -100,7 +100,7 @@ break; - case 1: // use native routine + case native: // use native routine // construct state, parameter, covariate, observable indices oidx = INTEGER(PROTECT(name_index(Onames,pompfun,"obsnames"))); nprotect++; @@ -123,7 +123,7 @@ // now do computations switch (mode) { - case 0: // R function + case Rfun: // R function { int first = 1; @@ -192,7 +192,7 @@ break; - case 1: // native routine + case native: // native routine { double *yt = REAL(Y); Modified: pkg/pomp/src/rprior.c =================================================================== --- pkg/pomp/src/rprior.c 2015-02-26 09:43:11 UTC (rev 1101) +++ pkg/pomp/src/rprior.c 2015-02-26 09:43:14 UTC (rev 1102) @@ -15,7 +15,7 @@ SEXP do_rprior (SEXP object, SEXP params, SEXP gnsi) { int nprotect = 0; - int mode = -1; + pompfunmode mode = undef; int npars, nreps; SEXP Pnames, P, fn, fcall; SEXP pompfun; @@ -37,7 +37,7 @@ // first do setup switch (mode) { - case 0: // use R function + case Rfun: // use R function { SEXP pvec, rho, ans, nm; @@ -106,7 +106,7 @@ break; - case 1: // use native routine + case native: // use native routine { double *pp, *ps; Modified: pkg/pomp/src/skeleton.c =================================================================== --- pkg/pomp/src/skeleton.c 2015-02-26 09:43:11 UTC (rev 1101) +++ pkg/pomp/src/skeleton.c 2015-02-26 09:43:14 UTC (rev 1102) @@ -89,7 +89,7 @@ { int nprotect = 0; int nvars, npars, nrepp, nrepx, nreps, ntimes, ncovars; - int mode = -1; + pompfunmode mode = undef; int *dim; SEXP Snames, Cnames, Pnames; SEXP pompfun; @@ -139,7 +139,7 @@ // first do setup switch (mode) { - case 0: // R skeleton + case Rfun: // R skeleton { int nprotect = 0; SEXP tvec, xvec, pvec, cvec, fcall, rho; @@ -173,7 +173,7 @@ UNPROTECT(nprotect); } break; - case 1: // native skeleton + case native: // native skeleton { int nprotect = 0; int *sidx, *pidx, *cidx; Modified: pkg/pomp/src/trajectory.c =================================================================== --- pkg/pomp/src/trajectory.c 2015-02-26 09:43:11 UTC (rev 1101) +++ pkg/pomp/src/trajectory.c 2015-02-26 09:43:14 UTC (rev 1102) @@ -97,7 +97,7 @@ SEXP iterate_map (SEXP object, SEXP times, SEXP t0, SEXP x0, SEXP params, SEXP gnsi) { int nprotect = 0; - int mode = -1; + pompfunmode mode = undef; SEXP fn, args; SEXP X; SEXP Snames, Pnames, Cnames; @@ -156,7 +156,7 @@ // set up the computations switch (mode) { - case 0: // R function + case Rfun: // R function { int nprotect = 0; SEXP cvec, tvec, xvec, pvec; @@ -190,7 +190,7 @@ UNPROTECT(nprotect); } break; - case 1: // native skeleton + case native: // native skeleton { int nprotect = 0; int *sidx, *pidx, *cidx; @@ -218,7 +218,7 @@ static struct { struct { - int mode; + pompfunmode mode; SEXP object; SEXP params; lookup_table covar_table; @@ -250,7 +250,7 @@ SEXP pomp_desolve_setup (SEXP object, SEXP x0, SEXP params, SEXP gnsi) { int nprotect = 0; - int mode = -1; + pompfunmode mode = undef; SEXP fn, args; SEXP Snames, Pnames, Cnames; SEXP pompfun; @@ -290,7 +290,7 @@ PROTECT(Cnames = GET_COLNAMES(GET_DIMNAMES(GET_SLOT(object,install("covar"))))); nprotect++; switch (COMMON(mode)) { - case 0: // R function + case Rfun: // R function // arguments of the R function PROTECT(RFUN(tvec) = NEW_NUMERIC(1)); nprotect++; PROTECT(RFUN(xvec) = NEW_NUMERIC(nvars)); nprotect++; @@ -330,7 +330,7 @@ R_PreserveObject(RFUN(cvec)); break; - case 1: // native code + case native: // native code // set aside userdata NAT(args) = args; // construct index vectors @@ -362,14 +362,14 @@ void pomp_vf_eval (int *neq, double *t, double *y, double *ydot, double *yout, int *ip) { switch (COMMON(mode)) { - case 0: // R function + case Rfun: // R function eval_skeleton_R(ydot,t,y,REAL(COMMON(params)), RFUN(fcall),RFUN(rho),RFUN(Snames), REAL(RFUN(tvec)),REAL(RFUN(xvec)),REAL(RFUN(pvec)),REAL(RFUN(cvec)), COMMON(nvars),COMMON(npars),1,COMMON(nreps),COMMON(nreps),COMMON(nreps), &COMMON(covar_table)); break; - case 1: // native code + case native: // native code eval_skeleton_native(ydot,t,y,REAL(COMMON(params)), COMMON(nvars),COMMON(npars),COMMON(ncovars),1, COMMON(nreps),COMMON(nreps),COMMON(nreps), @@ -392,7 +392,7 @@ COMMON(ncovars) = 0; COMMON(nreps) = 0; switch (COMMON(mode)) { - case 0: // R function + case Rfun: // R function R_ReleaseObject(RFUN(fcall)); R_ReleaseObject(RFUN(rho)); R_ReleaseObject(RFUN(Snames)); @@ -408,7 +408,7 @@ RFUN(pvec) = R_NilValue; RFUN(cvec) = R_NilValue; break; - case 1: // native code + case native: // native code NAT(fun) = 0; R_ReleaseObject(NAT(args)); R_ReleaseObject(NAT(sindex)); From noreply at r-forge.r-project.org Thu Feb 26 10:43:16 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 26 Feb 2015 10:43:16 +0100 (CET) Subject: [Pomp-commits] r1103 - pkg Message-ID: <20150226094316.6DC4C18629D@r-forge.r-project.org> Author: kingaa Date: 2015-02-26 10:43:16 +0100 (Thu, 26 Feb 2015) New Revision: 1103 Modified: pkg/Makefile Log: - better cransrc target Modified: pkg/Makefile =================================================================== --- pkg/Makefile 2015-02-26 09:43:14 UTC (rev 1102) +++ pkg/Makefile 2015-02-26 09:43:16 UTC (rev 1103) @@ -70,7 +70,7 @@ %.cransrc: mkdir -p cran check $(RM) -r cran/$* - git archive --format=tar master $* | (cd cran; tar -xf -) + git archive --format=tar HEAD $* | (cd cran; tar -xf -) $(RM) -r cran/$*/tests $(TOUCH) $@ From noreply at r-forge.r-project.org Thu Feb 26 12:13:49 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 26 Feb 2015 12:13:49 +0100 (CET) Subject: [Pomp-commits] r1104 - in pkg/pomp: . R Message-ID: <20150226111349.83B5D185A52@r-forge.r-project.org> Author: kingaa Date: 2015-02-26 12:13:49 +0100 (Thu, 26 Feb 2015) New Revision: 1104 Added: pkg/pomp/R/load.R Modified: pkg/pomp/DESCRIPTION pkg/pomp/R/builder.R Log: - rearrange some codes - streamline some of the CBuilder templates Modified: pkg/pomp/DESCRIPTION =================================================================== --- pkg/pomp/DESCRIPTION 2015-02-26 09:43:16 UTC (rev 1103) +++ pkg/pomp/DESCRIPTION 2015-02-26 11:13:49 UTC (rev 1104) @@ -1,8 +1,8 @@ Package: pomp Type: Package Title: Statistical Inference for Partially Observed Markov Processes -Version: 0.61-1 -Date: 2015-02-24 +Version: 0.61-2 +Date: 2015-02-26 Authors at R: c(person(given=c("Aaron","A."),family="King", role=c("aut","cre"),email="kingaa at umich.edu"), person(given=c("Edward","L."),family="Ionides",role=c("aut")), @@ -24,7 +24,7 @@ LazyData: true MailingList: Subscribe to pomp-announce at r-forge.r-project.org for announcements by going to http://lists.r-forge.r-project.org/mailman/listinfo/pomp-announce. Collate: aaa.R authors.R generics.R eulermultinom.R - csnippet.R pomp-fun.R plugins.R + csnippet.R pomp-fun.R plugins.R builder.R load.R parmat.R logmeanexp.R slice-design.R profile-design.R sobol.R bsplines.R sannbox.R pomp-class.R pomp.R pomp-methods.R @@ -39,4 +39,4 @@ nlf-funcs.R nlf-guts.R nlf-objfun.R nlf.R probe.R probe-match.R basic-probes.R spect.R spect-match.R abc.R abc-methods.R - builder.R example.R + example.R Modified: pkg/pomp/R/builder.R =================================================================== --- pkg/pomp/R/builder.R 2015-02-26 09:43:16 UTC (rev 1103) +++ pkg/pomp/R/builder.R 2015-02-26 11:13:49 UTC (rev 1104) @@ -1,139 +1,3 @@ -pompBuilder <- function (data, times, t0, name, - statenames, paramnames, tcovar, covar, - rmeasure, dmeasure, step.fn, step.fn.delta.t, - skeleton, skeleton.type = c("map","vectorfield"), - skelmap.delta.t = 1, - parameter.transform, parameter.inv.transform, - rprior, dprior, - globals, ..., save = FALSE) { - - if (!is.data.frame(data)) stop(sQuote("data")," must be a data-frame") - obsnames <- names(data) - obsnames <- setdiff(obsnames,times) - if (!missing(covar)) { - if (!is.data.frame(covar)) stop(sQuote("covar")," must be a data-frame") - covarnames <- colnames(covar) - covarnames <- setdiff(covarnames,tcovar) - } else { - covar <- matrix(data=0,nrow=0,ncol=0) - tcovar <- numeric(0) - covarnames <- character(0) - } - skeleton.type <- match.arg(skeleton.type) - - if (missing(statenames)) stop(sQuote("statenames")," must be supplied"); - if (missing(paramnames)) stop(sQuote("paramnames")," must be supplied"); - - mpt <- missing(parameter.transform) - mpit <- missing(parameter.inv.transform) - if (xor(mpt,mpit)) - stop("if you supply one transformation function, you must supply its inverse") - - pompCBuilder( - name=name, - statenames=statenames, - paramnames=paramnames, - covarnames=covarnames, - obsnames=obsnames, - rmeasure=rmeasure, - dmeasure=dmeasure, - step.fn=step.fn, - skeleton=skeleton, - parameter.transform=parameter.transform, - parameter.inv.transform=parameter.inv.transform, - rprior=rprior, - dprior=dprior, - globals=globals, - dir=if (save) getwd() else NULL - ) -> solib - - name <- solib[1] - - pomp( - data=data, - times=times, - t0=t0, - rprocess=euler.sim( - step.fun=render(fnames$step.fn,name=name), - delta.t=step.fn.delta.t, - PACKAGE=name - ), - rmeasure=render(fnames$rmeasure,name=name), - dmeasure=render(fnames$dmeasure,name=name), - skeleton=render(fnames$skeleton,name=name), - skeleton.type=skeleton.type, - skelmap.delta.t=skelmap.delta.t, - parameter.transform=render(fnames$parameter.transform,name=name), - parameter.inv.transform=render(fnames$parameter.inv.transform,name=name), - rprior=render(fnames$rprior,name=name), - dprior=render(fnames$dprior,name=name), - PACKAGE=name, - statenames=statenames, - paramnames=paramnames, - tcovar=tcovar, - covar=covar, - ..., - .solibfile=list(solib) - ) -} - -pompLoad.internal <- function (object, ..., verbose = getOption("verbose",FALSE)) { - for (lib in object at solibfile) { - if (!is.loaded("__pomp_load_stack_incr",PACKAGE=lib[1])) { - dyn.load(lib[2]) - if (verbose) cat("loading",sQuote(lib[2]),"\n") - } - .Call(load_stack_incr,lib[1]) - } - invisible(NULL) -} - -pompUnload.internal <- function (object, ..., verbose = getOption("verbose",FALSE)) { - for (lib in object at solibfile) { - if (is.loaded("__pomp_load_stack_decr",PACKAGE=lib[1])) { - st <- .Call(load_stack_decr,lib[1]) - if (st==0) { - dyn.unload(lib[2]) - if (verbose) cat("unloading",sQuote(lib[2]),"\n") - } - } - } - invisible(NULL) -} - -setMethod("pompLoad", - signature=signature(object='pomp'), - definition = function (object, ...) { - pompLoad.internal(object,...) - }) - -setMethod("pompUnload", - signature=signature(object='pomp'), - definition = function (object, ...) { - pompUnload.internal(object,...) - }) - -callable.decl <- function (code) { - fns <- vapply(names(decl),grepl,logical(1),code,perl=TRUE) - do.call(paste0,decl[fns]) -} - -missing.fun <- function (name) { - paste0(" error(\"'",name,"' not defined\");") -} - -randomName <- function (stem = "pomp", size = 2) { - paste0(stem, - paste( - format( - as.hexmode(ceiling(runif(n=size,max=2^24))), - upper.case=TRUE - ), - collapse="" - ) - ) -} - pompCBuilder <- function (name = NULL, statenames, paramnames, covarnames, obsnames, rmeasure, dmeasure, step.fn, skeleton, @@ -145,7 +9,7 @@ if (is.null(name)) name <- randomName() if (is.null(dir)) dir <- tempdir() - if (missing(globals)) globals <- "" + if (missing(globals)) globals <- character(0) name <- cleanForC(name) statenames <- cleanForC(statenames) @@ -157,7 +21,6 @@ if (.Platform$OS.type=="windows") { stem <- gsub("\\","/",stem,fixed=TRUE) } - modelfile <- paste0(stem,".c") solib <- paste0(stem,.Platform$dynlib.ext) @@ -198,47 +61,64 @@ } cat(file=out,render(define$var.alt,variable="lik",ptr='__lik',index=0)) + ## list of functions to register + registry <- c("load_stack_incr","load_stack_decr") + ## parameter transformation function - if (missing(parameter.transform)) - parameter.transform <- missing.fun("parameter.transform") - cat(file=out,render(header$parameter.transform,name=name)) - cat(file=out,callable.decl(parameter.transform)) - cat(file=out,parameter.transform,footer$parameter.transform) + if (!missing(parameter.transform)) { + registry <- c(registry,"par_trans") + cat(file=out,render(header$parameter.transform,name=name)) + cat(file=out,callable.decl(parameter.transform)) + cat(file=out,parameter.transform,footer$parameter.transform) + } ## inverse parameter transformation function - if (missing(parameter.inv.transform)) - parameter.inv.transform <- missing.fun("parameter.inv.transform") - cat(file=out,render(header$parameter.inv.transform,name=name)) - cat(file=out,callable.decl(parameter.inv.transform)) - cat(file=out,parameter.inv.transform,footer$parameter.inv.transform) + if (!missing(parameter.inv.transform)) { + registry <- c(registry,"par_untrans") + cat(file=out,render(header$parameter.inv.transform,name=name)) + cat(file=out,callable.decl(parameter.inv.transform)) + cat(file=out,parameter.inv.transform,footer$parameter.inv.transform) + } ## rmeasure function - if (missing(rmeasure)) rmeasure <- missing.fun("rmeasure") - cat(file=out,render(header$rmeasure,name=name),rmeasure,footer$rmeasure) + if (!missing(rmeasure)) { + registry <- c(registry,"rmeasure") + cat(file=out,render(header$rmeasure,name=name),rmeasure,footer$rmeasure) + } ## dmeasure function - if (missing(dmeasure)) dmeasure <- missing.fun("dmeasure") - cat(file=out,render(header$dmeasure,name=name),dmeasure,footer$dmeasure) + if (!missing(dmeasure)) { + registry <- c(registry,"dmeasure") + cat(file=out,render(header$dmeasure,name=name),dmeasure,footer$dmeasure) + } ## Euler step function - if (missing(step.fn)) step.fn <- missing.fun("step.fn") - cat(file=out,render(header$step.fn,name=name)) - cat(file=out,callable.decl(step.fn)) - cat(file=out,step.fn,footer$step.fn) + if (!missing(step.fn)) { + registry <- c(registry,"stepfn") + cat(file=out,render(header$step.fn,name=name)) + cat(file=out,callable.decl(step.fn)) + cat(file=out,step.fn,footer$step.fn) + } ## skeleton function - if (missing(skeleton)) skeleton <- missing.fun("skeleton") - cat(file=out,render(header$skeleton,name=name)) - cat(file=out,callable.decl(skeleton)) - cat(file=out,skeleton,footer$skeleton) + if (!missing(skeleton)) { + registry <- c(registry,"skelfn") + cat(file=out,render(header$skeleton,name=name)) + cat(file=out,callable.decl(skeleton)) + cat(file=out,skeleton,footer$skeleton) + } ## rprior function - if (missing(rprior)) rprior <- missing.fun("rprior") - cat(file=out,render(header$rprior,name=name),rprior,footer$rprior) + if (!missing(rprior)) { + registry <- c(registry,"rprior") + cat(file=out,render(header$rprior,name=name),rprior,footer$rprior) + } ## dprior function - if (missing(dprior)) dprior <- missing.fun("dprior") - cat(file=out,render(header$dprior,name=name),dprior,footer$dprior) + if (!missing(dprior)) { + registry <- c(registry,"dprior") + cat(file=out,render(header$dprior,name=name),dprior,footer$dprior) + } ## undefine variables for (v in seq_along(paramnames)) { @@ -264,8 +144,8 @@ ## registration cat(file=out,render(header$registration,name=name)) - for (v in names(regist)) - cat(file=out,render(regist[[v]],name=name)) + for (v in registry) + cat(file=out,render(registration,name=name,fun=v)) cat(file=out,footer$registration) close(out) @@ -289,6 +169,27 @@ invisible(c(name,solib)) } +callable.decl <- function (code) { + fns <- vapply(names(decl),grepl,logical(1),code,perl=TRUE) + do.call(paste0,decl[fns]) +} + +missing.fun <- function (name) { + paste0(" error(\"'",name,"' not defined\");") +} + +randomName <- function (stem = "pomp", size = 2) { + paste0(stem, + paste( + format( + as.hexmode(ceiling(runif(n=size,max=2^24))), + upper.case=TRUE + ), + collapse="" + ) + ) +} + cleanForC <- function (text) { text <- as.character(text) text <- gsub("\\.","_",text) @@ -317,6 +218,85 @@ do.call(paste0,retval) } +pompBuilder <- function (data, times, t0, name, + statenames, paramnames, tcovar, covar, + rmeasure, dmeasure, step.fn, step.fn.delta.t, + skeleton, skeleton.type = c("map","vectorfield"), + skelmap.delta.t = 1, + parameter.transform, parameter.inv.transform, + rprior, dprior, + globals, ..., save = FALSE) { + + if (!is.data.frame(data)) stop(sQuote("data")," must be a data-frame") + obsnames <- names(data) + obsnames <- setdiff(obsnames,times) + if (!missing(covar)) { + if (!is.data.frame(covar)) stop(sQuote("covar")," must be a data-frame") + covarnames <- colnames(covar) + covarnames <- setdiff(covarnames,tcovar) + } else { + covar <- matrix(data=0,nrow=0,ncol=0) + tcovar <- numeric(0) + covarnames <- character(0) + } + skeleton.type <- match.arg(skeleton.type) + + if (missing(statenames)) stop(sQuote("statenames")," must be supplied"); + if (missing(paramnames)) stop(sQuote("paramnames")," must be supplied"); + + mpt <- missing(parameter.transform) + mpit <- missing(parameter.inv.transform) + if (xor(mpt,mpit)) + stop("if you supply one transformation function, you must supply its inverse") + + pompCBuilder( + name=name, + statenames=statenames, + paramnames=paramnames, + covarnames=covarnames, + obsnames=obsnames, + rmeasure=rmeasure, + dmeasure=dmeasure, + step.fn=step.fn, + skeleton=skeleton, + parameter.transform=parameter.transform, + parameter.inv.transform=parameter.inv.transform, + rprior=rprior, + dprior=dprior, + globals=globals, + dir=if (save) getwd() else NULL + ) -> solib + + name <- solib[1] + + pomp( + data=data, + times=times, + t0=t0, + rprocess=euler.sim( + step.fun=render(fnames$step.fn,name=name), + delta.t=step.fn.delta.t, + PACKAGE=name + ), + rmeasure=render(fnames$rmeasure,name=name), + dmeasure=render(fnames$dmeasure,name=name), + skeleton=render(fnames$skeleton,name=name), + skeleton.type=skeleton.type, + skelmap.delta.t=skelmap.delta.t, + parameter.transform=render(fnames$parameter.transform,name=name), + parameter.inv.transform=render(fnames$parameter.inv.transform,name=name), + rprior=render(fnames$rprior,name=name), + dprior=render(fnames$dprior,name=name), + PACKAGE=name, + statenames=statenames, + paramnames=paramnames, + tcovar=tcovar, + covar=covar, + ..., + .solibfile=list(solib) + ) +} + ## TEMPLATES define <- list( @@ -352,18 +332,7 @@ dprior="__pomp_dprior" ) -regist <- list( - rmeasure="R_RegisterCCallable(\"{%name%}\", \"__pomp_rmeasure\", (DL_FUNC) __pomp_rmeasure);\n", - dmeasure="R_RegisterCCallable(\"{%name%}\", \"__pomp_dmeasure\", (DL_FUNC) __pomp_dmeasure);\n", - step.fn="R_RegisterCCallable(\"{%name%}\", \"__pomp_stepfn\", (DL_FUNC) __pomp_stepfn);\n", - skeleton="R_RegisterCCallable(\"{%name%}\", \"__pomp_skelfn\", (DL_FUNC) __pomp_skelfn);\n", - parameter.transform="R_RegisterCCallable(\"{%name%}\", \"__pomp_par_trans\", (DL_FUNC) __pomp_par_trans);\n", - parameter.inv.transform="R_RegisterCCallable(\"{%name%}\", \"__pomp_par_untrans\", (DL_FUNC) __pomp_par_untrans);\n", - rprior="R_RegisterCCallable(\"{%name%}\", \"__pomp_rprior\", (DL_FUNC) __pomp_rprior);\n", - dprior="R_RegisterCCallable(\"{%name%}\", \"__pomp_dprior\", (DL_FUNC) __pomp_dprior);\n", - loadstack.incr="R_RegisterCCallable(\"{%name%}\", \"__pomp_load_stack_incr\", (DL_FUNC) __pomp_load_stack_incr);\n", - loadstack.decr="R_RegisterCCallable(\"{%name%}\", \"__pomp_load_stack_decr\", (DL_FUNC) __pomp_load_stack_decr);\n" - ) +registration <- "R_RegisterCCallable(\"{%name%}\", \"__pomp_{%fun%}\", (DL_FUNC) __pomp_{%fun%});\n" decl <- list( periodic_bspline_basis_eval="\tvoid (*periodic_bspline_basis_eval)(double,double,int,int,double*);\nperiodic_bspline_basis_eval = (void (*)(double,double,int,int,double*)) R_GetCCallable(\"pomp\",\"periodic_bspline_basis_eval\");\n", Added: pkg/pomp/R/load.R =================================================================== --- pkg/pomp/R/load.R (rev 0) +++ pkg/pomp/R/load.R 2015-02-26 11:13:49 UTC (rev 1104) @@ -0,0 +1,35 @@ +pompLoad.internal <- function (object, ..., verbose = getOption("verbose",FALSE)) { + for (lib in object at solibfile) { + if (!is.loaded("__pomp_load_stack_incr",PACKAGE=lib[1])) { + dyn.load(lib[2]) + if (verbose) cat("loading",sQuote(lib[2]),"\n") + } + .Call(load_stack_incr,lib[1]) + } + invisible(NULL) +} + +pompUnload.internal <- function (object, ..., verbose = getOption("verbose",FALSE)) { + for (lib in object at solibfile) { + if (is.loaded("__pomp_load_stack_decr",PACKAGE=lib[1])) { + st <- .Call(load_stack_decr,lib[1]) + if (st==0) { + dyn.unload(lib[2]) + if (verbose) cat("unloading",sQuote(lib[2]),"\n") + } + } + } + invisible(NULL) +} + +setMethod("pompLoad", + signature=signature(object='pomp'), + definition = function (object, ...) { + pompLoad.internal(object,...) + }) + +setMethod("pompUnload", + signature=signature(object='pomp'), + definition = function (object, ...) { + pompUnload.internal(object,...) + }) From noreply at r-forge.r-project.org Fri Feb 27 03:57:37 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 27 Feb 2015 03:57:37 +0100 (CET) Subject: [Pomp-commits] r1105 - pkg/pomp/R pkg/pomp/man pkg/pomp/tests www/content www/vignettes Message-ID: <20150227025737.7E6A31876B8@r-forge.r-project.org> Author: kingaa Date: 2015-02-27 03:57:36 +0100 (Fri, 27 Feb 2015) New Revision: 1105 Added: pkg/pomp/man/lowlevel.Rd Removed: pkg/pomp/man/dmeasure-pomp.Rd pkg/pomp/man/dprocess-pomp.Rd pkg/pomp/man/init.state-pomp.Rd pkg/pomp/man/prior-pomp.Rd pkg/pomp/man/rmeasure-pomp.Rd pkg/pomp/man/rprocess-pomp.Rd pkg/pomp/man/skeleton-pomp.Rd pkg/pomp/man/trajectory-pomp.Rd Modified: pkg/pomp/R/pomp-methods.R pkg/pomp/man/plugins.Rd pkg/pomp/man/pomp-methods.Rd pkg/pomp/man/pomp-package.Rd pkg/pomp/man/pomp.Rd pkg/pomp/tests/ou2-kalman.R pkg/pomp/tests/ou2-kalman.Rout.save pkg/pomp/tests/rw2.R pkg/pomp/tests/rw2.Rout.save pkg/pomp/tests/synlik.R pkg/pomp/tests/synlik.Rout.save www/content/refs.htm www/content/refs.tex www/vignettes/pomp.bib Log: - rework some of the help pages - deprecate 'data.array' - update references Modified: pkg/pomp/R/pomp-methods.R =================================================================== --- pkg/pomp/R/pomp-methods.R 2015-02-26 11:13:49 UTC (rev 1104) +++ pkg/pomp/R/pomp-methods.R 2015-02-27 02:57:36 UTC (rev 1105) @@ -51,8 +51,13 @@ ## a simple method to extract the data array setMethod("obs","pomp",obs.internal) -setMethod("data.array","pomp",obs.internal) +setMethod("data.array","pomp",function (object, ...) { + warning(sQuote("data.array")," is deprecated and will be removed ", + "in a future release. Use ",sQuote("obs")," instead.") + obs.internal(object,...) +}) + ## a simple method to extract the array of states states.internal <- function (object, vars, ...) { if (length(object at states)==0) { Deleted: pkg/pomp/man/dmeasure-pomp.Rd =================================================================== --- pkg/pomp/man/dmeasure-pomp.Rd 2015-02-26 11:13:49 UTC (rev 1104) +++ pkg/pomp/man/dmeasure-pomp.Rd 2015-02-27 02:57:36 UTC (rev 1105) @@ -1,47 +0,0 @@ -\name{dmeasure-pomp} -\docType{methods} -\alias{dmeasure} -\alias{dmeasure,pomp-method} -\alias{dmeasure-pomp} -\keyword{internal} -\title{Evaluate the probability density of observations given underlying states in a partially-observed Markov process} -\description{ - The method \code{dmeasure} evaluates the probability density of a set of measurements given the state of the system. - This function is part of the low-level interface to \code{pomp} objects. - This help page does not give instructions on the implementation of models: see \code{\link{pomp}} for instructions. -} -\usage{ -\S4method{dmeasure}{pomp}(object, y, x, times, params, log = FALSE, \dots) -} -\arguments{ - \item{object}{an object of class \code{pomp}.} - \item{y}{ - a rank-2 array containing observations. - The dimensions of \code{y} are \code{nobs} x \code{ntimes}, where \code{nobs} is the number of observables and \code{ntimes} is the length of \code{times}. - } - \item{x}{ - a rank-3 array containing the states of the unobserved process. - The dimensions of \code{x} are \code{nvars} x \code{nreps} x \code{ntimes}, where \code{nvars} is the number of state variables, \code{nreps} is the number of replicates, and \code{ntimes} is the length of \code{times}. - } - \item{times}{ - a numeric vector containing the times at which the observations were made. - } - \item{params}{ - a rank-2 array of parameters with columns corresponding to the columns of \code{x}. - Note that the \code{x} and \code{params} must agree in the number of their columns. - } - \item{log}{if TRUE, log probabilities are returned.} - \item{\dots}{at present, these are ignored.} -} -\value{ - Returns a matrix of dimensions \code{nreps} x \code{ntimes}. - If \code{d} is the returned matrix, \code{d[j,k]} is the likelihood of the observation \code{y[,k]} at time \code{times[k]} given the state \code{x[,j,k]}. -} -\details{ - This function is essentially a wrapper around the user-supplied \code{dmeasure} slot of the \code{pomp} object. - For specifications on writing such a function, see \code{\link{pomp}}. -} -\author{Aaron A. King \email{kingaa at umich dot edu}} -\seealso{\code{\link{pomp-class}}, \code{\link{pomp}}} -\keyword{models} -\keyword{ts} Deleted: pkg/pomp/man/dprocess-pomp.Rd =================================================================== --- pkg/pomp/man/dprocess-pomp.Rd 2015-02-26 11:13:49 UTC (rev 1104) +++ pkg/pomp/man/dprocess-pomp.Rd 2015-02-27 02:57:36 UTC (rev 1105) @@ -1,45 +0,0 @@ -\name{dprocess-pomp} -\docType{methods} -\alias{dprocess} -\alias{dprocess,pomp-method} -\alias{dprocess-pomp} -\keyword{internal} -\title{ - Evaluate the probability density of state transitions in a Markov process -} -\description{ - The method \code{dprocess} evaluates the probability density of a set of consecutive state transitions. - This function is part of the low-level interface to \code{pomp} objects. - This help page does not give instructions on the implementation of models: see \code{\link{pomp}} for instructions. -} -\usage{ -\S4method{dprocess}{pomp}(object, x, times, params, log = FALSE, \dots) -} -\arguments{ - \item{object}{an object of class \code{pomp}.} - \item{x}{ - a rank-3 array containing the states of the unobserved process. - The dimensions of \code{x} are \code{nvars} x \code{nreps} x \code{ntimes}, where \code{nvars} is the number of state variables, \code{nreps} is the number of replicates, and \code{ntimes} is the length of \code{times}. - } - \item{times}{ - a numeric vector containing the times corresponding to the given states. - } - \item{params}{ - a rank-2 array of parameters with columns corresponding to the columns of \code{x}. - Note that the \code{x} and \code{params} must agree in the number of their columns. - } - \item{log}{if TRUE, log probabilities are returned.} - \item{\dots}{at present, these are ignored.} -} -\value{ - Returns a matrix of dimensions \code{nreps} x \code{ntimes-1}. - If \code{d} is the returned matrix, \code{d[j,k]} is the likelihood of the transition from state \code{x[,j,k-1]} at time \code{times[k-1]} to state \code{x[,j,k]} at time \code{times[k]}. -} -\details{ - This function is essentially a wrapper around the user-supplied \code{dprocess} slot of the \code{pomp} object. - For specifications on writing such a function, see \code{\link{pomp}}. -} -\author{Aaron A. King \email{kingaa at umich dot edu}} -\seealso{\code{\link{pomp-class}}, \code{\link{pomp}}} -\keyword{models} -\keyword{ts} Deleted: pkg/pomp/man/init.state-pomp.Rd =================================================================== --- pkg/pomp/man/init.state-pomp.Rd 2015-02-26 11:13:49 UTC (rev 1104) +++ pkg/pomp/man/init.state-pomp.Rd 2015-02-27 02:57:36 UTC (rev 1105) @@ -1,39 +0,0 @@ -\name{init.state-pomp} -\docType{methods} -\alias{init.state} -\alias{init.state,pomp-method} -\alias{init.state-pomp} -\keyword{internal} -\title{Return a matrix of initial conditions given a vector of parameters and an initial time.} -\description{ - The method \code{init.state} returns a vector of initial conditions for the state process when given a vector of parameters \code{params} and an initial time \code{t0}. - This function is part of the low-level interface to \code{pomp} objects. - This help page does not give instructions on the implementation of models: see \code{\link{pomp}} for instructions. -} -\usage{ -\S4method{init.state}{pomp}(object, params, t0, \dots) -} -\arguments{ - \item{object}{an object of class \code{pomp}.} - \item{params}{ - a named vector of parameters. - } - \item{t0}{the initial time at which initial states are requested.} - \item{\dots}{at present, these are ignored.} -} -\value{ - Returns a matrix of initial states (with rownames). -} -\examples{ -pompExample(ou2) -coef(ou2) -init.state(ou2) - -pompExample(euler.sir) -coef(euler.sir) -init.state(euler.sir) -} -\author{Aaron A. King \email{kingaa at umich dot edu}} -\seealso{\code{\link{pomp-class}}} -\keyword{models} -\keyword{ts} Added: pkg/pomp/man/lowlevel.Rd =================================================================== --- pkg/pomp/man/lowlevel.Rd (rev 0) +++ pkg/pomp/man/lowlevel.Rd 2015-02-27 02:57:36 UTC (rev 1105) @@ -0,0 +1,182 @@ +\name{Low-level-interface} +\docType{methods} +\alias{pomp low-level interface} +\alias{rprocess} +\alias{rprocess,pomp-method} +\alias{rprocess-pomp} +\alias{dprocess} +\alias{dprocess,pomp-method} +\alias{dprocess-pomp} +\alias{rmeasure} +\alias{rmeasure,pomp-method} +\alias{rmeasure-pomp} +\alias{dmeasure} +\alias{dmeasure,pomp-method} +\alias{dmeasure-pomp} +\alias{dprior} +\alias{dprior,pomp-method} +\alias{dprior-pomp} +\alias{rprior} +\alias{rprior,pomp-method} +\alias{rprior-pomp} +\alias{init.state} +\alias{init.state,pomp-method} +\alias{init.state-pomp} +\alias{skeleton} +\alias{skeleton,pomp-method} +\alias{skeleton-pomp} +\alias{trajectory} +\alias{trajectory,pomp-method} +\alias{trajectory-pomp} +\title{The low-level interface to pomp objects} +\description{ + A \code{pomp} object implements a partially observed Markov process (POMP) model. + Basic operations on this model (with shorthand terms) include: + \enumerate{ + \item simulation of the state process given parameters (rprocess) + \item evaluation of the likelihood of a given state trajectory given parameters (dprocess) + \item simulation of the observation process given the states and parameters (rmeasure) + \item evaluation of the likelihood of a set of observations given the states and parameters (dmeasure) + \item simulation from the prior probability distribution (rprior) + \item evaluation of the prior probability density (dprior) + \item simulation from the distribution of initial states, given parameters (init.state) + \item evaluation of the deterministic skeleton at a point in state space, given parameters (skeleton) + \item computation of a trajetory of the deterministic skeleton given parameters (trajectory) + } + \pkg{pomp} provides S4 methods that implement each of these basic operations. + These operations can be combined to implement computations and statistical inference methods that depend only on a model's POMP structure. + For convenience, parameter transformations may also be enclosed in a \code{pomp} object. + + This page documents these elements. +} +\usage{ +\S4method{rprocess}{pomp}(object, xstart, times, params, offset = 0, \dots) +\S4method{dprocess}{pomp}(object, x, times, params, log = FALSE, \dots) +\S4method{rmeasure}{pomp}(object, x, times, params, \dots) +\S4method{dmeasure}{pomp}(object, y, x, times, params, log = FALSE, \dots) +\S4method{dprior}{pomp}(object, params, log = FALSE, \dots) +\S4method{rprior}{pomp}(object, params, \dots) +\S4method{init.state}{pomp}(object, params, t0, \dots) +\S4method{skeleton}{pomp}(object, x, t, params, \dots) +\S4method{trajectory}{pomp}(object, params, times, t0, as.data.frame = FALSE, \dots) +} +\arguments{ + \item{object}{an object of class \code{pomp}.} + \item{xstart}{ + an \code{nvar} x \code{nrep} matrix containing the starting state of the system. + Columns of \code{xstart} correspond to states; rows to components of the state vector. + One independent simulation will be performed for each column. + Note that in this case, \code{params} must also have \code{nrep} columns. + } + \item{x}{ + a rank-3 array containing states of the unobserved process. + The dimensions of \code{x} are \code{nvars} x \code{nrep} x \code{ntimes}, where \code{nvars} is the number of state variables, \code{nrep} is the number of replicates, and \code{ntimes} is the length of \code{times}. + } + \item{y}{ + a matrix containing observations. + The dimensions of \code{y} are \code{nobs} x \code{ntimes}, where \code{nobs} is the number of observables and \code{ntimes} is the length of \code{times}. + } + \item{times, t}{ + a numeric vector (length \code{ntimes}) containing times. + These must be in non-decreasing order. + } + \item{params}{ + a \code{npar} x \code{nrep} matrix of parameters. + Each column is an independent parameter set and is paired with the corresponding column of \code{x} or \code{xstart}. + + In the case of \code{init.state}, \code{params} is a named vector of parameters. + } + \item{offset}{ + integer; + the first \code{offset} times in \code{times} will not be returned. + } + \item{t0}{the initial time at which initial states are requested.} + \item{log}{if TRUE, log probabilities are returned.} + \item{as.data.frame}{ + logical; if \code{TRUE}, return the result as a data-frame. + } + \item{\dots}{ + In \code{trajectory}, additional arguments are passed to the ODE integrator (if the skeleton is a vectorfield) and ignored if it is a map. + See \code{\link[deSolve]{ode}} for a description of the additional arguments accepted. + + In all other cases, additional arguments are ignored. + } +} +\section{rprocess: simulating the process model}{ + \code{rprocess} runs simulations of the the process-model portion of partially-observed Markov process. + + When \code{rprocess} is called, the first entry of \code{times} is taken to be the initial time + (i.e., that corresponding to \code{xstart}). + Subsequent times are the additional times at which the state of the simulated processes are required. + + \code{rprocess} returns a rank-3 array with rownames. + Suppose \code{x} is the array returned. + Then \code{dim(x)=c(nvars,nrep,ntimes-offset)}, where \code{nvars} is the number of state variables (=\code{nrow(xstart)}), \code{nrep} is the number of independent realizations simulated (=\code{ncol(xstart)}), and \code{ntimes} is the length of the vector \code{times}. + \code{x[,j,k]} is the value of the state process in the \code{j}-th realization at time \code{times[k+offset]}. + The rownames of \code{x} must correspond to those of \code{xstart}. +} +\section{dprocess: evaluating the probability density of a sequence of state transitions}{ + \code{dprocess} evaluates the probability density of a set of consecutive state transitions. + + \code{dprocess} returns a matrix of dimensions \code{nrep} x \code{ntimes-1}. + If \code{d} is the returned matrix, \code{d[j,k]} is the likelihood of the transition from state \code{x[,j,k-1]} at time \code{times[k-1]} to state \code{x[,j,k]} at time \code{times[k]}. +} +\section{rmeasure}{ + \code{rmeasure} simulate the measurement model given states and parameters. + + \code{rmeasure} returns a rank-3 array of dimensions \code{nobs} x \code{nrep} x \code{ntimes}, where \code{nobs} is the number of observed variables. +} +\section{dmeasure}{ + \code{dmeasure} evaluates the probability density of observations given states. + + \code{dmeasure} returns a matrix of dimensions \code{nreps} x \code{ntimes}. + If \code{d} is the returned matrix, \code{d[j,k]} is the likelihood of the observation \code{y[,k]} at time \code{times[k]} given the state \code{x[,j,k]}. +} +\section{dprior, rprior}{ + \code{dprior} evaluates the prior probability density and \code{rprior} simulates from the prior. +} +\section{init.state}{ + \code{init.state} returns an \code{nvar} x \code{nrep} matrix of state-process initial conditions when given an \code{npar} x \code{nrep} matrix of parameters, \code{params}, and an initial time \code{t0}. + By default, \code{t0} is the initial time defined when the \code{pomp} object ws constructed. +} +\section{skeleton}{ + The method \code{skeleton} evaluates the deterministic skeleton at a point or points in state space, given parameters. + In the case of a discrete-time system, the skeleton is a map. + In the case of a continuous-time system, the skeleton is a vectorfield. + NB: \code{skeleton} just evaluates the deterministic skeleton; + it does not iterate or integrate. + + \code{skeleton} returns an array of dimensions \code{nvar} x \code{nrep} x \code{ntimes}. + If \code{f} is the returned matrix, \code{f[i,j,k]} is the i-th component of the deterministic skeleton at time \code{times[k]} given the state \code{x[,j,k]} and parameters \code{params[,j]}. +} +\section{trajectory}{ + \code{trajectory} computes a trajectory of the deterministic skeleton of a Markov process. + In the case of a discrete-time system, the deterministic skeleton is a map and a trajectory is obtained by iterating the map. + In the case of a continuous-time system, the deterministic skeleton is a vector-field; \code{trajectory} uses the numerical solvers in \pkg{\link[deSolve]{deSolve}} to integrate the vectorfield. + + \code{trajectory} returns an array of dimensions \code{nvar} x \code{nrep} x \code{ntimes}. + If \code{x} is the returned matrix, \code{x[i,j,k]} is the i-th component of the state vector at time \code{times[k]} given parameters \code{params[,j]}. + + When the skeleton is a vectorfield, \code{trajectory} integrates it using \code{\link[deSolve]{ode}}. + When the skeleton is a map, \code{trajectory} iterates it. + By default, time is advanced 1 unit per iteration. + The user can change this behavior by specifying the desired timestep using the argument \code{skelmap.delta.t} in the construction of the \code{pomp} object. +} +\section{Parameter transformations}{ + User-defined parameter transformations enclosed in the \code{pomp} object can be accessed via \code{\link{partrans}}. +} +\examples{ +pompExample(ricker) +p <- c(r=42,phi=10,sigma=0.3,N.0=7,e.0=0) +t <- c(1:10,20,30) +t0 <- 0 +x0 <- init.state(ricker,params=p,t0=t0) +x <- rprocess(ricker,xstart=x0,times=c(t0,t),params=p,offset=1) +y <- rmeasure(ricker,params=p,x=x,times=t) +ll <- dmeasure(ricker,y=y,x=x,times=t,params=p,log=TRUE) +f <- skeleton(ricker,x=x,t=t,params=p) +z <- trajectory(ricker,params=p,times=t,t0=t0) +} +\author{Aaron A. King \email{kingaa at umich dot edu}} +\seealso{\code{\link{pomp}}, \link{pomp methods}} +\keyword{programming} Modified: pkg/pomp/man/plugins.Rd =================================================================== --- pkg/pomp/man/plugins.Rd 2015-02-26 11:13:49 UTC (rev 1104) +++ pkg/pomp/man/plugins.Rd 2015-02-27 02:57:36 UTC (rev 1105) @@ -1,11 +1,12 @@ \name{plugins} \alias{plugins} +\alias{process model plugins} \alias{onestep.sim} \alias{euler.sim} \alias{discrete.time.sim} \alias{onestep.dens} \alias{gillespie.sim} -\title{Plug-ins for dynamical models based on stochastic Euler algorithms} +\title{Plug-ins for state-process models} \description{ Plug-in facilities for implementing discrete-time Markov processes and continuous-time Markov processes using the Euler algorithm. These can be used in the \code{rprocess} and \code{dprocess} slots of \code{pomp}. Modified: pkg/pomp/man/pomp-methods.Rd =================================================================== --- pkg/pomp/man/pomp-methods.Rd 2015-02-26 11:13:49 UTC (rev 1104) +++ pkg/pomp/man/pomp-methods.Rd 2015-02-27 02:57:36 UTC (rev 1105) @@ -1,5 +1,6 @@ \name{pomp-methods} \docType{methods} +\alias{pomp methods} \alias{pomp-methods} \alias{plot,pomp-method} \alias{plot-pomp} @@ -47,7 +48,6 @@ \S4method{coef}{pomp}(object, pars, transform = FALSE, \dots) \S4method{coef}{pomp}(object, pars, transform = FALSE, \dots) <- value \S4method{obs}{pomp}(object, vars, \dots) -\S4method{data.array}{pomp}(object, vars, \dots) \S4method{partrans}{pomp}(object, params, dir = c("forward","inverse"), \dots) \S4method{plot}{pomp}(x, y, variables, panel = lines, nc = NULL, yax.flip = FALSE, @@ -162,7 +162,7 @@ \code{coef(object,pars,transform=TRUE) <- value} first, discards any names the \code{value} may have, sets \code{names(value) <- pars}, and then replaces the elements of \code{object}'s \code{params} slot \code{parameter.transform(value)}. In this case, if some of the names in \code{pars} do not already name parameters in \code{coef(object,transform=TRUE)}, then they are concatenated. } - \item{obs, data.array}{ + \item{obs}{ These functions are synonymous. \code{obs(object)} returns the array of observations. \code{obs(object,vars)} gives just the observations of variables named \code{vars}. @@ -236,13 +236,7 @@ \author{Aaron A. King \email{kingaa at umich dot edu}} \seealso{ \code{\link{pomp}}, - \link{pomp-class}, - \code{\link{rprocess}}, - \code{\link{dprocess}}, - \code{\link{rmeasure}}, - \code{\link{dmeasure}}, - \code{\link{init.state}}, - \code{\link[=simulate-pomp]{simulate}} + \link{pomp low-level interface} } \keyword{models} \keyword{ts} Modified: pkg/pomp/man/pomp-package.Rd =================================================================== --- pkg/pomp/man/pomp-package.Rd 2015-02-26 11:13:49 UTC (rev 1104) +++ pkg/pomp/man/pomp-package.Rd 2015-02-27 02:57:36 UTC (rev 1105) @@ -1,20 +1,25 @@ \name{pomp-package} \docType{package} \alias{pomp-package} -\title{Partially-observed Markov processes} +\alias{pomp package} +\title{Inference for partially observed Markov processes} \description{ - The \pkg{pomp} package provides facilities for inference on time series data using partially-observed Markov processes (AKA state-space models or nonlinear stochastic dynamical systems). + The \pkg{pomp} package provides facilities for inference on time series data using partially-observed Markov process (POMP) models. + These models are also known as state-space models or nonlinear stochastic dynamical systems. One can use \pkg{pomp} to fit nonlinear, non-Gaussian dynamic models to time-series data. - The first step in using \pkg{pomp} is to encode one's model and data in an object of class \code{pomp}. - One does this via a call to \code{\link{pomp}}, which involves specifying the process and measurement components of the model in one or more of a variety of ways. + The package is both a set of tools for data analysis and a platform upon which statistical inference methods for POMP models can be implemented. +} +\section{Data analysis using \pkg{pomp}}{ + The first step in using \pkg{pomp} is to encode one's model(s) and data in objects of class \code{pomp}. + One does this via a call to \code{\link{pomp}}, which involves specifying the unobserved state process and the measurement process of the model. Details on this are given in the documentation for the \code{\link{pomp}} function. - Examples are given in the \href{http://pomp.r-forge.r-project.org/vignettes/intro_to_pomp.pdf}{\dQuote{Introduction to \pkg{pomp}}} document, in the demos (\code{demo(package='pomp')}), and via the \code{\link{pompExample}} function. + Examples are given in the vignettes (\code{vignette(package='pomp')}), in the demos (\code{demo(package='pomp')}), and via the \code{\link{pompExample}} function. \pkg{pomp} version \Sexpr[echo=F,stage=install,results=text]{packageDescription("pomp",fields="Version")} provides algorithms for \enumerate{ \item simulation of stochastic dynamical systems; see \code{\link[=simulate-pomp]{simulate}} \item particle filtering (AKA sequential Monte Carlo or sequential importance sampling); see \code{\link{pfilter}} - \item the iterated filtering method of Ionides et al. (2006, 2011); see \code{\link{mif}} + \item the iterated filtering method of Ionides et al. (2006, 2011, 2015); see \code{\link{mif}} \item the nonlinear forecasting algorithm of Kendall et al. (2005); see \code{\link{nlf}} \item the particle MCMC approach of Andrieu et al. (2010); see \code{\link{pmcmc}} \item the probe-matching method of Kendall et al. (1999, 2005); see \code{\link{probe.match}} @@ -22,19 +27,23 @@ \item synthetic likelihood a la Wood (2010); see \code{\link{probe}} \item approximate Bayesian computation (Toni et al. 2009); see \code{\link{abc}} \item the approximate Bayesian sequential Monte Carlo scheme of Liu & West (2001); see \code{\link{bsmc}} - \item basic trajectory matching; see \code{\link{traj.match}}. + \item simple trajectory matching; see \code{\link{traj.match}}. } - The package also provides various tools for plotting and extracting information on models and data as well as an API for algorithm development. - Future support for additional algorithms in envisioned. + The package also provides various tools for plotting and extracting information on models and data. +} +\section{History}{ Much of the groundwork for \pkg{pomp} was laid by a working group of the National Center for Ecological Analysis and Synthesis (\acronym{NCEAS}), \dQuote{Inference for Mechanistic Models}. - +} +\section{License}{ \pkg{pomp} is provided under the \acronym{GNU} Public License (\acronym{GPL}). +} +\section{Comments, bug reports, feature requests}{ Contributions are welcome, as are comments, feature requests, and bug reports. See the package website \url{http://pomp.r-forge.r-project.org} for more information, access to the package mailing list, links to the authors' websites, references to the literature, and up-to-date versions of the package source and documentation. } \section{Classes}{ \pkg{pomp} makes extensive use of S4 classes. - The basic class, \code{\link{pomp}}, encodes a partially-observed Markov process together with a uni- or multi-variate data set and (possibly) parameters. + The basic class, \code{\link{pomp}}, encodes a partially-observed Markov process together with a uni- or multivariate data set and (possibly) parameters. } \section{Documentation}{ The \href{http://pomp.r-forge.r-project.org/vignettes/intro_to_pomp.pdf}{\sQuote{Introduction to \pkg{pomp}}} document illustrates the facilities of the package using familiar stochastic processes. @@ -47,14 +56,14 @@ \author{Aaron A. King \email{kingaa at umich dot edu}} \seealso{ \code{\link{pomp}}, + \link{pomp low-level interface}, \code{\link{pfilter}}, \code{\link[=simulate-pomp]{simulate}}, - \code{\link{trajectory}}, \code{\link{mif}}, \code{\link{nlf}}, \code{\link{probe.match}}, \code{\link{traj.match}}, - \code{\link{bsmc}}, + \code{\link{bsmc2}}, \code{\link{pmcmc}} } \keyword{models} Modified: pkg/pomp/man/pomp.Rd =================================================================== --- pkg/pomp/man/pomp.Rd 2015-02-26 11:13:49 UTC (rev 1104) +++ pkg/pomp/man/pomp.Rd 2015-02-27 02:57:36 UTC (rev 1105) @@ -340,18 +340,9 @@ } \author{Aaron A. King \email{kingaa at umich dot edu}} \seealso{ - \link{pomp-methods}, - \link[pomp]{plugins}, - \code{\link[=pomp-methods]{time}}, - \code{\link[=pomp-methods]{time<-}}, - \code{\link[=pomp-methods]{timezero}}, - \code{\link[=pomp-methods]{timezero<-}}, - \code{\link[=pomp-methods]{coef}}, - \code{\link[=pomp-methods]{coef<-}}, - \code{\link[=pomp-methods]{obs}}, - \code{\link[=pomp-methods]{states}}, - \code{\link[=pomp-methods]{window}}, - \code{\link[=pomp-methods]{as.data.frame.pomp}} + \link{pomp methods}, + \link{pomp low-level interface}, + \link{process model plugins} } \keyword{models} \keyword{ts} Deleted: pkg/pomp/man/prior-pomp.Rd =================================================================== --- pkg/pomp/man/prior-pomp.Rd 2015-02-26 11:13:49 UTC (rev 1104) +++ pkg/pomp/man/prior-pomp.Rd 2015-02-27 02:57:36 UTC (rev 1105) @@ -1,35 +0,0 @@ -\name{prior-pomp} -\docType{methods} -\alias{dprior} -\alias{dprior,pomp-method} -\alias{dprior-pomp} -\alias{rprior} -\alias{rprior,pomp-method} -\alias{rprior-pomp} -\keyword{internal} -\title{Evaluate or simulate from the prior probability density} -\description{ - The method \code{dprior} evaluates the prior probability density and \code{rprior} simulates from it. - This function is part of the low-level interface to \code{pomp} objects. - This help page does not give instructions on the implementation of models: see \code{\link{pomp}} for instructions. -} -\usage{ -\S4method{dprior}{pomp}(object, params, log = FALSE, \dots) -\S4method{rprior}{pomp}(object, params, \dots) -} -\arguments{ - \item{object}{an object of class \code{pomp}.} - \item{params}{ - a rank-2 array of parameters with columns corresponding to the columns of \code{x}. - } - \item{log}{if TRUE, log probabilities are returned.} - \item{\dots}{at present, these are ignored.} -} -\details{ - These functions are essentially wrappers around the user-supplied \code{dprior} and \code{rprior} functions stored in the \code{pomp} object. - For specifications on writing these functions, see \code{\link{pomp}}. -} -\author{Aaron A. King \email{kingaa at umich dot edu}} -\seealso{\code{\link{pomp}}} -\keyword{models} -\keyword{ts} Deleted: pkg/pomp/man/rmeasure-pomp.Rd =================================================================== --- pkg/pomp/man/rmeasure-pomp.Rd 2015-02-26 11:13:49 UTC (rev 1104) +++ pkg/pomp/man/rmeasure-pomp.Rd 2015-02-27 02:57:36 UTC (rev 1105) @@ -1,42 +0,0 @@ -\name{rmeasure-pomp} -\docType{methods} -\alias{rmeasure} -\alias{rmeasure,pomp-method} -\alias{rmeasure-pomp} -\keyword{internal} -\title{Simulate the measurement model of a partially-observed Markov process} -\description{ - The method \code{rmeasure} draws from the distribution of measurements given the state of the system. - This function is part of the low-level interface to \code{pomp} objects. - This help page does not give instructions on the implementation of models: see \code{\link{pomp}} for instructions. -} -\usage{ -\S4method{rmeasure}{pomp}(object, x, times, params, \dots) -} -\arguments{ - \item{object}{an object of class \code{pomp}.} - \item{x}{ - a rank-3 array containing the states of the unobserved process. - The dimensions of \code{x} are \code{nvars} x \code{nreps} x \code{ntimes}, where \code{nvars} is the number of state variables, \code{nreps} is the number of simulations, and \code{ntimes} is the number of distinct times. - } - \item{times}{ - a numerical vector containing the times at which the measurements are to be made. - } - \item{params}{ - a rank-2 array (dimensions \code{npars} x \code{nreps}) of parameters with the parameters corresponding to the columns of \code{x}. - } - \item{\dots}{ - at present, these are ignored. - } -} -\value{ - Returns a rank-3 array of dimensions \code{nobs} x \code{nreps} x \code{ntimes}, where \code{nobs} is the number of observed variables. -} -\details{ - This function is essentially a wrapper around the user-supplied \code{rmeasure} slot of the \code{pomp} object. - For specifications on writing such a function, see \code{\link{pomp}}. -} -\author{Aaron A. King \email{kingaa at umich dot edu}} -\seealso{\code{\link{pomp-class}}, \code{\link{pomp}}} -\keyword{models} -\keyword{ts} Deleted: pkg/pomp/man/rprocess-pomp.Rd =================================================================== --- pkg/pomp/man/rprocess-pomp.Rd 2015-02-26 11:13:49 UTC (rev 1104) +++ pkg/pomp/man/rprocess-pomp.Rd 2015-02-27 02:57:36 UTC (rev 1105) @@ -1,51 +0,0 @@ -\name{rprocess-pomp} -\docType{methods} -\alias{rprocess} -\alias{rprocess,pomp-method} -\alias{rprocess-pomp} -\keyword{internal} -\title{Simulate the process model of a partially-observed Markov process} -\description{ - The method \code{rprocess} runs simulations of the the process-model portion of partially-observed Markov process. - This function is part of the low-level interface to \code{pomp} objects. - This help page does not give instructions on the implementation of models: see \code{\link{pomp}} for instructions. -} -\usage{ -\S4method{rprocess}{pomp}(object, xstart, times, params, offset, \dots) -} -\arguments{ - \item{object}{an object of class \code{pomp}.} - \item{xstart}{ - a rank-2 array containing the starting state of the system. - Columns of \code{xstart} correspond to states; rows to state variables. - If there is more than one column of \code{xstart}, multiple independent simulations will be performed, one corresponding to each column. - Note that in this case, \code{params} must have the same number of columns as \code{xstart}. - } - \item{times}{ - a numerical vector containing times. - The first entry of \code{times} is the initial time (corresponding to \code{xstart}). - Subsequent times are the additional times at which the state of the simulated processes are required. - } - \item{params}{ - a rank-2 array of parameters with the parameters corresponding to the columns of \code{xstart}. - } - \item{offset}{ - throw away the first \code{offset} times. - } - \item{\dots}{at present, these are ignored.} -} -\value{ - \code{rprocess} returns a rank-3 array with rownames. - Suppose \code{x} is the array returned. - Then \code{dim(x)=c(nvars,nreps,ntimes-offset)}, where \code{nvars} is the number of state variables (=\code{nrow(xstart)}), \code{nreps} is the number of independent realizations simulated (=\code{ncol(xstart)}), and \code{ntimes} is the length of the vector \code{times}. - \code{x[,j,k]} is the value of the state process in the \code{j}-th realization at time \code{times[k+offset]}. - The rownames of \code{x} must correspond to those of \code{xstart}. -} -\details{ - This function is essentially a wrapper around the user-supplied \code{rprocess} slot of the \code{pomp} object. - For specifications on writing such a function, see \code{\link{pomp}}. -} -\author{Aaron A. King \email{kingaa at umich dot edu}} -\seealso{\code{\link{pomp-class}}, \code{\link{pomp}}} -\keyword{models} -\keyword{ts} Deleted: pkg/pomp/man/skeleton-pomp.Rd =================================================================== --- pkg/pomp/man/skeleton-pomp.Rd 2015-02-26 11:13:49 UTC (rev 1104) +++ pkg/pomp/man/skeleton-pomp.Rd 2015-02-27 02:57:36 UTC (rev 1105) @@ -1,48 +0,0 @@ -\name{skeleton-pomp} -\docType{methods} -\alias{skeleton} -\alias{skeleton,pomp-method} -\alias{skeleton-pomp} -\keyword{internal} -\title{Evaluate the deterministic skeleton at the given points in state space.} -\description{ - The method \code{skeleton} computes the deterministic skeleton. - In the case of a discrete-time system, this is the one-step map. - In the case of a continuous-time system, this is the vector-field. - NB: \code{skeleton} just evaluates the deterministic skeleton; - it does not iterate or integrate. - This function is part of the low-level interface to \code{pomp} objects. [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/pomp -r 1105 From noreply at r-forge.r-project.org Fri Feb 27 03:57:40 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 27 Feb 2015 03:57:40 +0100 (CET) Subject: [Pomp-commits] r1106 - in pkg/pomp: . tests Message-ID: <20150227025740.D3162187846@r-forge.r-project.org> Author: kingaa Date: 2015-02-27 03:57:40 +0100 (Fri, 27 Feb 2015) New Revision: 1106 Modified: pkg/pomp/DESCRIPTION pkg/pomp/tests/ou2-kalman.Rout.save pkg/pomp/tests/rw2.Rout.save pkg/pomp/tests/synlik.Rout.save Log: - update tests Modified: pkg/pomp/DESCRIPTION =================================================================== --- pkg/pomp/DESCRIPTION 2015-02-27 02:57:36 UTC (rev 1105) +++ pkg/pomp/DESCRIPTION 2015-02-27 02:57:40 UTC (rev 1106) @@ -1,7 +1,7 @@ Package: pomp Type: Package Title: Statistical Inference for Partially Observed Markov Processes -Version: 0.61-2 +Version: 0.61-3 Date: 2015-02-26 Authors at R: c(person(given=c("Aaron","A."),family="King", role=c("aut","cre"),email="kingaa at umich.edu"), Modified: pkg/pomp/tests/ou2-kalman.Rout.save =================================================================== --- pkg/pomp/tests/ou2-kalman.Rout.save 2015-02-27 02:57:36 UTC (rev 1105) +++ pkg/pomp/tests/ou2-kalman.Rout.save 2015-02-27 02:57:40 UTC (rev 1106) @@ -55,7 +55,7 @@ + } > > kalman <- function (x, object, params) { -+ y <- data.array(object) ++ y <- obs(object) + p <- params + p[names(x)] <- x + x0 <- init.state(object,params=p) @@ -82,9 +82,6 @@ Kalman filter log likelihood at truth > print(loglik.truth <- -kalman(p.truth,ou2,p.truth),digits=4) [1] -479 -Warning message: -In data.array(object) : - 'data.array' is deprecated and will be removed in a future release. Use 'obs' instead. > > # make a wild guess > p.guess <- p.truth[c('alpha.1','alpha.4','x1.0','x2.0')]*exp(rnorm(n=4,mean=0,sd=0.5)) @@ -97,9 +94,6 @@ Kalman filter log likelihood at guess > print(loglik.guess <- -kalman(p.guess,ou2,p.truth),digits=4) [1] -511.8 -Warning message: -In data.array(object) : - 'data.array' is deprecated and will be removed in a future release. Use 'obs' instead. > > # find MLE using Kalman filter starting at the guess > cat("running Kalman filter estimation\n") @@ -168,10 +162,9 @@ HI-REDUCTION 115 477.241051 477.241042 Exiting from Nelder Mead minimizer 117 function evaluations used -There were 50 or more warnings (use warnings() to see the first 50) > toc <- Sys.time() > print(toc-tic) -Time difference of 3.404061 secs +Time difference of 3.41739 secs > tic <- Sys.time() > print(loglik.mle <- -kalm.fit1$value,digits=4) [1] -477.2 @@ -195,4 +188,4 @@ > > proc.time() user system elapsed - 3.924 0.040 3.956 + 3.933 0.035 3.954 Modified: pkg/pomp/tests/rw2.Rout.save =================================================================== --- pkg/pomp/tests/rw2.Rout.save 2015-02-27 02:57:36 UTC (rev 1105) +++ pkg/pomp/tests/rw2.Rout.save 2015-02-27 02:57:40 UTC (rev 1106) @@ -164,7 +164,7 @@ } y } - + measurement model density, dmeasure = function (y, x, t, params, log, covars, ...) { @@ -177,7 +177,7 @@ f else exp(f) } - + prior simulator, rprior = function not specified prior density, dprior = @@ -246,10 +246,7 @@ > x <- simulate(rw2,nsim=10,params=p,obs=T,states=T) > x <- simulate(rw2,nsim=10,params=p[,1]) > -> x <- data.array(rw2) -Warning message: -In data.array(rw2) : - 'data.array' is deprecated and will be removed in a future release. Use 'obs' instead. +> x <- obs(rw2) > t <- time(rw2) > > x0 <- init.state(rw2,params=p) @@ -345,4 +342,4 @@ > > proc.time() user system elapsed - 0.903 0.036 0.923 + 0.870 0.033 0.889 Modified: pkg/pomp/tests/synlik.Rout.save =================================================================== --- pkg/pomp/tests/synlik.Rout.save 2015-02-27 02:57:36 UTC (rev 1105) +++ pkg/pomp/tests/synlik.Rout.save 2015-02-27 02:57:40 UTC (rev 1106) @@ -59,7 +59,7 @@ + } > > kalman <- function (x, object, params) { -+ y <- data.array(object) ++ y <- obs(object) + p <- params + p[names(x)] <- x + x0 <- init.state(object,params=p) @@ -76,9 +76,6 @@ > # exact likelihood > p.truth <- coef(po) > loglik.truth <- -kalman(p.truth,po,p.truth) -Warning message: -In data.array(object) : - 'data.array' is deprecated and will be removed in a future release. Use 'obs' instead. > > ## likelihood from probes (works since ou2 is Gaussian) > loglik.probe <- replicate(n=500,logLik(probe(po,nsim=200,probes=function(x)x))) @@ -119,4 +116,4 @@ > > proc.time() user system elapsed - 7.404 0.033 7.432 + 7.286 0.042 7.322 From noreply at r-forge.r-project.org Fri Feb 27 03:57:52 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 27 Feb 2015 03:57:52 +0100 (CET) Subject: [Pomp-commits] r1107 - pkg/pomp/man www/content www/vignettes Message-ID: <20150227025752.5AFDE1876B8@r-forge.r-project.org> Author: kingaa Date: 2015-02-27 03:57:51 +0100 (Fri, 27 Feb 2015) New Revision: 1107 Added: pkg/pomp/man/design.Rd Removed: pkg/pomp/man/abc-methods.Rd pkg/pomp/man/mif-methods.Rd pkg/pomp/man/pfilter-methods.Rd pkg/pomp/man/profile-design.Rd pkg/pomp/man/slice-design.Rd pkg/pomp/man/sobol.Rd Modified: pkg/pomp/man/abc.Rd pkg/pomp/man/builder.Rd pkg/pomp/man/gompertz.Rd pkg/pomp/man/lowlevel.Rd pkg/pomp/man/mif.Rd pkg/pomp/man/ou2.Rd pkg/pomp/man/pfilter.Rd pkg/pomp/man/plugins.Rd pkg/pomp/man/pomp-methods.Rd pkg/pomp/man/pomp-package.Rd pkg/pomp/man/pomp.Rd pkg/pomp/man/proposals.Rd pkg/pomp/man/ricker.Rd pkg/pomp/man/rw2.Rd pkg/pomp/man/simulate-pomp.Rd pkg/pomp/man/sir.Rd www/content/NEWS.html www/vignettes/advanced_topics_in_pomp.pdf www/vignettes/bsmc-ricker-flat-prior.rda www/vignettes/bsmc-ricker-normal-prior.rda www/vignettes/gompertz-multi-mif.rda www/vignettes/gompertz-performance.rda www/vignettes/gompertz-trajmatch.rda www/vignettes/intro_to_pomp.R www/vignettes/intro_to_pomp.Rnw www/vignettes/intro_to_pomp.pdf www/vignettes/nlf-fit-from-truth.rda www/vignettes/nlf-fits.rda www/vignettes/plugin-C-code.rda www/vignettes/plugin-R-code.rda www/vignettes/pomp.pdf www/vignettes/ricker-first-probe.rda www/vignettes/ricker-mif.rda www/vignettes/ricker-probe-match.rda www/vignettes/ricker-probe.rda www/vignettes/vectorized-C-code.rda www/vignettes/vectorized-R-code.rda Log: - many edits to help pages - update vignettes Deleted: pkg/pomp/man/abc-methods.Rd =================================================================== --- pkg/pomp/man/abc-methods.Rd 2015-02-27 02:57:40 UTC (rev 1106) +++ pkg/pomp/man/abc-methods.Rd 2015-02-27 02:57:51 UTC (rev 1107) @@ -1,58 +0,0 @@ -\name{abc-methods} -\docType{methods} -\alias{abc-methods} -\alias{conv.rec,abc-method} -\alias{conv.rec-abc} -\alias{conv.rec,abcList-method} -\alias{conv.rec-abcList} -\alias{plot-abc} -\alias{plot,abc-method} -\alias{plot-abcList} -\alias{plot,abcList-method} -\alias{abcList-class} -\alias{c-abc} -\alias{c,abc-method} -\alias{c-abcList} -\alias{c,abcList-method} -\alias{[-abcList} -\alias{[,abcList-method} -\title{Methods of the "abc" class} -\description{Methods of the "abc" class.} -\usage{ -\S4method{conv.rec}{abc}(object, pars, \dots) -\S4method{conv.rec}{abcList}(object, \dots) -\S4method{plot}{abc}(x, y, pars, scatter = FALSE, \dots) -\S4method{plot}{abcList}(x, y, \dots) -\S4method{c}{abc}(x, \dots, recursive = FALSE) -\S4method{c}{abcList}(x, \dots, recursive = FALSE) -} -\arguments{ - \item{object, x}{The \code{abc} object.} - \item{pars}{Names of parameters.} - \item{y, recursive}{Ignored.} - \item{scatter}{ - optional logical; - If \code{TRUE}, draw scatterplots. - If \code{FALSE}, draw traceplots. - } - \item{\dots}{ - Further arguments (either ignored or passed to underlying functions). - } -} -\section{Methods}{ - \describe{ - \item{conv.rec}{ - \code{conv.rec(object, pars)} returns the columns of the convergence-record matrix corresponding to the names in \code{pars}. - By default, all rows are returned. - } - \item{c}{ - Concatenates \code{abc} objects into an \code{abcList}. - } - \item{plot}{ - Diagnostic plots. - } - } -} -\author{Edward L. Ionides \email{ionides at umich dot edu}, Aaron A. King \email{kingaa at umich dot edu}} -\seealso{\code{\link{abc}}, \code{\link{pomp}}} -\keyword{ts} Modified: pkg/pomp/man/abc.Rd =================================================================== --- pkg/pomp/man/abc.Rd 2015-02-27 02:57:40 UTC (rev 1106) +++ pkg/pomp/man/abc.Rd 2015-02-27 02:57:51 UTC (rev 1107) @@ -1,6 +1,8 @@ -\name{abc} +\title{Estimation by approximate Bayesian computation (ABC)} +\name{Approximate Bayesian computation} \docType{methods} \alias{abc} +\alias{ABC} \alias{abc-abc} \alias{abc,probed.pomp-method} \alias{abc-probed.pomp} @@ -11,7 +13,22 @@ \alias{continue,abc-method} \alias{continue-abc} \alias{abc-class} -\title{The ABC algorithm} +\alias{abc-methods} +\alias{conv.rec,abc-method} +\alias{conv.rec-abc} +\alias{conv.rec,abcList-method} +\alias{conv.rec-abcList} +\alias{plot-abc} +\alias{plot,abc-method} +\alias{plot-abcList} +\alias{plot,abcList-method} +\alias{abcList-class} +\alias{c-abc} +\alias{c,abc-method} +\alias{c-abcList} +\alias{c,abcList-method} +\alias{[-abcList} +\alias{[,abcList-method} \description{ The approximate Bayesian computation (ABC) algorithm for estimating the parameters of a partially-observed Markov process. } @@ -25,6 +42,10 @@ probes, scale, epsilon, verbose = getOption("verbose"), \dots) \S4method{continue}{abc}(object, Nabc = 1, \dots) +\S4method{conv.rec}{abc}(object, pars, \dots) +\S4method{conv.rec}{abcList}(object, \dots) +\S4method{plot}{abc}(x, y, pars, scatter = FALSE, \dots) +\S4method{plot}{abcList}(x, y, \dots) } \arguments{ \item{object}{ @@ -44,7 +65,6 @@ Several functions that construct appropriate proposal function are provided: see \link{MCMC proposal functions} for more information. } - \item{pars}{Deprecated and ignored. Will be removed in a future release.} \item{rw.sd}{ Deprecated. Will be removed in a future release. Specifying \code{rw.sd} is equivalent to setting \code{proposal=mvn.diag.rw(rw.sd)}. @@ -62,33 +82,48 @@ \item{verbose}{ logical; if TRUE, print progress reports. } + \item{pars}{Names of parameters.} + \item{scatter}{ + optional logical; + If \code{TRUE}, draw scatterplots. + If \code{FALSE}, draw traceplots. + } + \item{x}{\code{abc} object.} + \item{y}{Ignored.} \item{\dots}{ Additional arguments. These are currently ignored. } } -\value{ - An object of class \code{abc}. - This class inherits from class \code{\link[=probed.pomp-class]{probed.pomp}} and contains the following additional slots: - \describe{ - \item{pars, Nabc, dprior, hyperparams, scale, epsilon}{ - These slots hold the values of the corresponding arguments of the call to \code{abc}. - } - } +\section{Running ABC}{ + \code{abc} returns an object of class \code{abc}. + One or more \code{abc} objects can be joined to form an \code{abcList} object. } -\section{Re-running ABC Iterations}{ +\section{Re-running ABC iterations}{ To re-run a sequence of ABC iterations, one can use the \code{abc} method on a \code{abc} object. By default, the same parameters used for the original ABC run are re-used (except for \code{tol}, \code{max.fail}, and \code{verbose}, the defaults of which are shown above). If one does specify additional arguments, these will override the defaults. } -\section{Continuing ABC Iterations}{ +\section{Continuing ABC iterations}{ One can continue a series of ABC iterations from where one left off using the \code{continue} method. A call to \code{abc} to perform \code{Nabc=m} iterations followed by a call to \code{continue} to perform \code{Nabc=n} iterations will produce precisely the same effect as a single call to \code{abc} to perform \code{Nabc=m+n} iterations. By default, all the algorithmic parameters are the same as used in the original call to \code{abc}. Additional arguments will override the defaults. } -\section{Details}{ - TO APPEAR. +\section{Methods}{ + Methods that can be used to manipulate, display, or extract information from an \code{abc} object: + \describe{ + \item{conv.rec}{ + \code{conv.rec(object, pars)} returns the columns of the convergence-record matrix corresponding to the names in \code{pars}. + By default, all rows are returned. + } + \item{c}{ + Concatenates \code{abc} objects into an \code{abcList}. + } + \item{plot}{ + Diagnostic plots. + } + } } \references{ T. Toni and M. P. H. Stumpf, @@ -101,7 +136,6 @@ } \author{Edward L. Ionides \email{ionides at umich dot edu}, Aaron A. King \email{kingaa at umich dot edu}} \seealso{ - \link{abc-methods}, \code{\link{pomp}}, \code{\link{probe}}. - See the \dQuote{intro_to_pomp} vignette for an example + \code{\link{pomp}}, \code{\link{probe}}, and the tutorials on the \href{http://pomp.r-forge.r-project.org}{package website}. } \keyword{ts} Modified: pkg/pomp/man/builder.Rd =================================================================== --- pkg/pomp/man/builder.Rd 2015-02-27 02:57:40 UTC (rev 1106) +++ pkg/pomp/man/builder.Rd 2015-02-27 02:57:51 UTC (rev 1107) @@ -2,7 +2,9 @@ \alias{pompBuilder} \title{Write, compile, and build a pomp object using native codes} \description{ - \code{pompBuilder} is a facility for producing compiled \code{pomp} objects. + \code{pompBuilder} is a tool for producing compiled \code{pomp} objects. + It was an early attempt to facilitate the use of compiled codes but has been replaced by the more flexible use of \code{\link{Csnippet}}s in the regular \code{pomp} constructor function. + It is not being actively maintained and users are encouraged to migrate to using \code{\link{Csnippet}}s. } \usage{ pompBuilder(data, times, t0, name, statenames, paramnames, @@ -79,9 +81,8 @@ This will not typically be the case in out-of-the-box Windows installations. } \seealso{ - \code{\link{pomp}} and the demos. + \code{\link{pomp}}, \code{\link{Csnippet}} } \author{Aaron A. King \email{kingaa at umich dot edu}} -\examples{ - ## see the demos -} +\keyword{programming} +\keyword{internal} Added: pkg/pomp/man/design.Rd =================================================================== --- pkg/pomp/man/design.Rd (rev 0) +++ pkg/pomp/man/design.Rd 2015-02-27 02:57:51 UTC (rev 1107) @@ -0,0 +1,77 @@ +\name{design} +\title{Design matrices for pomp calculations} +\alias{profileDesign} +\alias{sobolDesign} +\alias{sobol} +\alias{sliceDesign} +\description{ + These functions are useful for generating designs for the exploration of parameter space. + \code{sobolDesign} generate a Latin hypercube design using the Sobol' low-discrepancy sequence. + \code{profileDesign} generates a data-frame where each row can be used as the starting point for a profile likelihood calculation. + \code{sliceDesign} generates points along slices through a specified point. +} +\usage{ +sobolDesign(lower, upper, nseq) +profileDesign(\dots, lower, upper, nprof, + stringsAsFactors = default.stringsAsFactors()) +sliceDesign(center, \dots) +} +\arguments{ + \item{lower, upper}{ + named numeric vectors giving the lower and upper bounds of the ranges, respectively. + } + \item{\dots}{ + In \code{profileDesign}, additional arguments specify the parameters over which to profile and the values of these parameters. + + In \code{sliceDesign}, additional numeric vector arguments specify the locations of points along the slices. + } + \item{nseq}{ + Total number of points requested. + } + \item{nprof}{ + The number of points per profile point. + } + \item{stringsAsFactors}{ + should character vectors be converted to factors? + } + \item{center}{ + \code{center} is a named numeric vector specifying the point through which the slice(s) is (are) to be taken. + } +} +\value{ + \code{sobolDesign} + + \code{profileDesign} returns a data frame with \code{nprof} points per profile point. + The other parameters in \code{vars} are sampled using \code{sobol}. +} +\examples{ +## Sobol' low-discrepancy design +plot(sobolDesign(lower=c(a=0,b=100),upper=c(b=200,a=1),100)) + +## A one-parameter profile design: +x <- profileDesign(p=1:10,lower=c(a=0,b=0),upper=c(a=1,b=5),nprof=20) +dim(x) +plot(x) + +## A two-parameter profile design: +x <- profileDesign(p=1:10,q=3:5,lower=c(a=0,b=0),upper=c(b=5,a=1),nprof=20) +dim(x) +plot(x) + +## A single 11-point slice through the point c(A=3,B=8,C=0) along the B direction. +x <- sliceDesign(center=c(A=3,B=8,C=0),B=seq(0,10,by=1)) +dim(x) +plot(x) + +## Two slices through the same point along the A and C directions. +x <- sliceDesign(c(A=3,B=8,C=0),A=seq(0,5,by=1),C=seq(0,5,length=11)) +dim(x) +plot(x) +} +\references{ + W. H. Press, S. A. Teukolsky, W. T. Vetterling, \& B. P. Flannery, + Numerical Recipes in C, + Cambridge University Press, 1992 +} +\author{Aaron A. King \email{kingaa at umich dot edu}} +\keyword{design} Modified: pkg/pomp/man/gompertz.Rd =================================================================== --- pkg/pomp/man/gompertz.Rd 2015-02-27 02:57:40 UTC (rev 1106) +++ pkg/pomp/man/gompertz.Rd 2015-02-27 02:57:51 UTC (rev 1107) @@ -18,6 +18,6 @@ coef(gompertz,transform=TRUE) } \seealso{ - the \href{http://pomp.r-forge.r-project.org/vignettes/intro_to_pomp.pdf}{\dQuote{Introduction to \pkg{pomp}}} tutorial. + \code{pomp}, \code{ricker}, and the tutorials at \url{http://pomp.r-forge.r-project.org}. } \keyword{datasets} Modified: pkg/pomp/man/lowlevel.Rd =================================================================== --- pkg/pomp/man/lowlevel.Rd 2015-02-27 02:57:40 UTC (rev 1106) +++ pkg/pomp/man/lowlevel.Rd 2015-02-27 02:57:51 UTC (rev 1107) @@ -1,5 +1,6 @@ \name{Low-level-interface} \docType{methods} +\title{pomp low-level interface} \alias{pomp low-level interface} \alias{rprocess} \alias{rprocess,pomp-method} @@ -28,9 +29,14 @@ \alias{trajectory} \alias{trajectory,pomp-method} \alias{trajectory-pomp} -\title{The low-level interface to pomp objects} +\alias{pompLoad} +\alias{pompLoad-pomp} +\alias{pompLoad,pomp-method} +\alias{pompUnload} +\alias{pompUnload-pomp} +\alias{pompUnload,pomp-method} \description{ - A \code{pomp} object implements a partially observed Markov process (POMP) model. + A \code{pomp} object implements a partially observed Markov process (\acronym{POMP}) model. Basic operations on this model (with shorthand terms) include: \enumerate{ \item simulation of the state process given parameters (rprocess) @@ -44,7 +50,7 @@ \item computation of a trajetory of the deterministic skeleton given parameters (trajectory) } \pkg{pomp} provides S4 methods that implement each of these basic operations. - These operations can be combined to implement computations and statistical inference methods that depend only on a model's POMP structure. + These operations can be combined to implement computations and statistical inference methods that depend only on a model's \acronym{POMP} structure. For convenience, parameter transformations may also be enclosed in a \code{pomp} object. This page documents these elements. @@ -59,6 +65,8 @@ \S4method{init.state}{pomp}(object, params, t0, \dots) \S4method{skeleton}{pomp}(object, x, t, params, \dots) \S4method{trajectory}{pomp}(object, params, times, t0, as.data.frame = FALSE, \dots) +\S4method{pompLoad}{pomp}(object, \dots) +\S4method{pompUnload}{pomp}(object, \dots) } \arguments{ \item{object}{an object of class \code{pomp}.} @@ -102,8 +110,8 @@ In all other cases, additional arguments are ignored. } } -\section{rprocess: simulating the process model}{ - \code{rprocess} runs simulations of the the process-model portion of partially-observed Markov process. +\section{rprocess}{ + \code{rprocess} simulates the process-model portion of partially-observed Markov process. When \code{rprocess} is called, the first entry of \code{times} is taken to be the initial time (i.e., that corresponding to \code{xstart}). @@ -111,12 +119,12 @@ \code{rprocess} returns a rank-3 array with rownames. Suppose \code{x} is the array returned. - Then \code{dim(x)=c(nvars,nrep,ntimes-offset)}, where \code{nvars} is the number of state variables (=\code{nrow(xstart)}), \code{nrep} is the number of independent realizations simulated (=\code{ncol(xstart)}), and \code{ntimes} is the length of the vector \code{times}. + Then \preformatted{dim(x)=c(nvars,nrep,ntimes-offset),} where \code{nvars} is the number of state variables (=\code{nrow(xstart)}), \code{nrep} is the number of independent realizations simulated (=\code{ncol(xstart)}), and \code{ntimes} is the length of the vector \code{times}. \code{x[,j,k]} is the value of the state process in the \code{j}-th realization at time \code{times[k+offset]}. - The rownames of \code{x} must correspond to those of \code{xstart}. + The rownames of \code{x} must correspond to those of \code{xstart}. } -\section{dprocess: evaluating the probability density of a sequence of state transitions}{ - \code{dprocess} evaluates the probability density of a set of consecutive state transitions. +\section{dprocess}{ + \code{dprocess} evaluates the probability density of a sequence of consecutive state transitions. \code{dprocess} returns a matrix of dimensions \code{nrep} x \code{ntimes-1}. If \code{d} is the returned matrix, \code{d[j,k]} is the likelihood of the transition from state \code{x[,j,k-1]} at time \code{times[k-1]} to state \code{x[,j,k]} at time \code{times[k]}. @@ -145,7 +153,7 @@ In the case of a continuous-time system, the skeleton is a vectorfield. NB: \code{skeleton} just evaluates the deterministic skeleton; it does not iterate or integrate. - + \code{skeleton} returns an array of dimensions \code{nvar} x \code{nrep} x \code{ntimes}. If \code{f} is the returned matrix, \code{f[i,j,k]} is the i-th component of the deterministic skeleton at time \code{times[k]} given the state \code{x[,j,k]} and parameters \code{params[,j]}. } @@ -165,8 +173,27 @@ \section{Parameter transformations}{ User-defined parameter transformations enclosed in the \code{pomp} object can be accessed via \code{\link{partrans}}. } +\section{\code{pompLoad}, \code{pompUnload}}{ + \code{pompLoad} and \code{pompUnload} cause compiled codes associated with \code{object} to be dynamically linked or unlinked, respectively. + When \code{Csnippet}s are used in the construction of a \code{pomp} object, the resulting shared-object library is dynamically loaded (linked) before each use, and unloaded afterward. + These functions are provided because in some instances, greater control may be desired. + These functions have no effect on shared-object libraries linked by the user. +} \examples{ pompExample(ricker) + +p <- parmat(c(r=42,phi=10,sigma=0.3,N.0=7,e.0=0),10) +t <- c(1:10,20,30) +t0 <- 0 +x0 <- init.state(ricker,params=p,t0=t0) +x <- rprocess(ricker,xstart=x0,times=c(t0,t),params=p,offset=1) +y <- rmeasure(ricker,params=p,x=x,times=t) +ll <- dmeasure(ricker,y=y[,3,,drop=FALSE],x=x,times=t,params=p,log=TRUE) +apply(ll,1,sum) +f <- skeleton(ricker,x=x,t=t,params=p) +z <- trajectory(ricker,params=p,times=t,t0=t0) + +## short arguments are recycled: p <- c(r=42,phi=10,sigma=0.3,N.0=7,e.0=0) t <- c(1:10,20,30) t0 <- 0 Deleted: pkg/pomp/man/mif-methods.Rd =================================================================== --- pkg/pomp/man/mif-methods.Rd 2015-02-27 02:57:40 UTC (rev 1106) +++ pkg/pomp/man/mif-methods.Rd 2015-02-27 02:57:51 UTC (rev 1107) @@ -1,73 +0,0 @@ -\name{mif-methods} -\docType{methods} -\alias{mif-methods} -\alias{logLik,mif-method} -\alias{logLik-mif} -\alias{conv.rec} -\alias{conv.rec,mif-method} -\alias{conv.rec-mif} -\alias{conv.rec,mifList-method} -\alias{conv.rec-mifList} -\alias{plot-mif} -\alias{plot,mif-method} -\alias{plot-mifList} -\alias{plot,mifList-method} -\alias{mifList-class} -\alias{c-mif} -\alias{c,mif-method} -\alias{c-mifList} -\alias{c,mifList-method} -\alias{[-mifList} -\alias{[,mifList-method} -\alias{compare.mif} -\title{Methods of the "mif" class} -\description{Methods of the \code{mif} class.} -\usage{ -\S4method{logLik}{mif}(object, \dots) -\S4method{conv.rec}{mif}(object, pars, transform = FALSE, \dots) -\S4method{conv.rec}{mifList}(object, \dots) -\S4method{plot}{mif}(x, y, \dots) -\S4method{plot}{mifList}(x, y, \dots) -\S4method{c}{mif}(x, \dots, recursive = FALSE) -\S4method{c}{mifList}(x, \dots, recursive = FALSE) -compare.mif(z) -} -\arguments{ - \item{object}{The \code{mif} object.} - \item{pars}{Names of parameters.} - \item{x}{The \code{mif} object.} - \item{y, recursive}{Ignored.} - \item{z}{A \code{mif} object or list of \code{mif} objects.} - \item{transform}{ - optional logical; - should the parameter transformations be applied? - See \code{\link[=coef-pomp]{coef}} for details. - } - \item{\dots}{ - Further arguments (either ignored or passed to underlying functions). - } -} -\section{Methods}{ - \describe{ - \item{conv.rec}{ - \code{conv.rec(object, pars = NULL)} returns the columns of the convergence-record matrix corresponding to the names in \code{pars}. - By default, all rows are returned. - } - \item{logLik}{ - Returns the value in the \code{loglik} slot. - } - \item{c}{ - Concatenates \code{mif} objects into an \code{mifList}. - } - \item{plot}{ - Plots a series of diagnostic plots. - } - \item{compare.mif}{ - Deprecated: use \code{plot} instead. - } - } -} -\author{Aaron A. King \email{kingaa at umich dot edu}} -\seealso{\code{\link{mif}}, \code{\link{pomp}}, \code{\link{pfilter}}} -\keyword{models} -\keyword{ts} Modified: pkg/pomp/man/mif.Rd =================================================================== --- pkg/pomp/man/mif.Rd 2015-02-27 02:57:40 UTC (rev 1106) +++ pkg/pomp/man/mif.Rd 2015-02-27 02:57:51 UTC (rev 1107) @@ -1,4 +1,5 @@ -\name{mif} +\name{Iterated filtering} +\title{Maximum likelihood by iterated filtering} \docType{methods} \alias{mif} \alias{mif,mif-method} @@ -11,12 +12,31 @@ \alias{continue,mif-method} \alias{continue-mif} \alias{mif-class} -\title{Iterated filtering} +\alias{mif-methods} +\alias{logLik,mif-method} +\alias{logLik-mif} +\alias{conv.rec} +\alias{conv.rec,mif-method} +\alias{conv.rec-mif} +\alias{conv.rec,mifList-method} +\alias{conv.rec-mifList} +\alias{plot-mif} +\alias{plot,mif-method} +\alias{plot-mifList} +\alias{plot,mifList-method} +\alias{mifList-class} +\alias{c-mif} +\alias{c,mif-method} +\alias{c-mifList} +\alias{c,mifList-method} +\alias{[-mifList} +\alias{[,mifList-method} +\alias{compare.mif} \description{ Iterated filtering algorithms for estimating the parameters of a partially-observed Markov process. } \usage{ -\S4method{mif}{pomp}(object, Nmif = 1, start, pars, ivps = character(0), +\S4method{mif}{pomp}(object, Nmif = 1, start, ivps = character(0), particles, rw.sd, Np, ic.lag, var.factor, cooling.type, cooling.fraction, cooling.factor, method = c("mif","unweighted","fp","mif2"), @@ -28,6 +48,9 @@ cooling.type, cooling.fraction, method, tol, transform, \dots) \S4method{continue}{mif}(object, Nmif = 1, \dots) +\S4method{logLik}{mif}(object, \dots) +\S4method{conv.rec}{mif}(object, pars, transform = FALSE, \dots) +\S4method{conv.rec}{mifList}(object, \dots) } \arguments{ \item{object}{ @@ -40,15 +63,10 @@ named numerical vector; the starting guess of the parameters. } - \item{pars}{ - optional character vector naming the ordinary parameters to be estimated. - Every parameter named in \code{pars} must have a positive random-walk standard deviation specified in \code{rw.sd}. - Leaving \code{pars} unspecified is equivalent to setting it equal to the names of all parameters with a positive value of \code{rw.sd} that are not \code{ivps}. - } \item{ivps}{ optional character vector naming the initial-value parameters (IVPs) to be estimated. Every parameter named in \code{ivps} must have a positive random-walk standard deviation specified in \code{rw.sd}. - If \code{pars} is empty, i.e., only IVPs are to be estimated, see below \dQuote{"Using MIF to estimate initial-value parameters only"}. + If there are no non-IVP parameters with positive \code{rw.sd}, i.e., only IVPs are to be estimated, see below \dQuote{"Using \code{mif} to estimate initial-value parameters only"}. } \item{particles}{ Function of prototype \code{particles(Np,center,sd,...)} which sets up the starting particle matrix by drawing a sample of size \code{Np} from the starting particle distribution centered at \code{center} and of width \code{sd}. @@ -81,28 +99,32 @@ The \code{mif} update for initial-value parameters consists of replacing them by their filtering mean at time \code{times[ic.lag]}, where \code{times=time(object)}. It makes no sense to set \code{ic.lag>length(times)}; if it is so set, \code{ic.lag} is set to \code{length(times)} with a warning. + For \code{method="mif2"}, the default is \code{ic.lag=length(times)}. } \item{var.factor}{ a positive number; the scaling coefficient relating the width of the starting particle distribution to \code{rw.sd}. - In particular, the width of the distribution of particles at the start of the first MIF iteration will be \code{random.walk.sd*var.factor}. + In particular, the width of the distribution of particles at the start of the first \code{mif} iteration will be \code{random.walk.sd*var.factor}. } \item{cooling.type, cooling.fraction, cooling.factor}{ specifications for the cooling schedule, i.e., the manner in which the intensity of the parameter perturbations is reduced with successive filtering iterations. \code{cooling.type} specifies the nature of the cooling schedule. - When \code{cooling.type="geometric"}, on the n-th MIF iteration, the relative perturbation intensity is \code{cooling.fraction^(n/50)}. - When \code{cooling.type="hyperbolic"}, on the n-th MIF iteration, the relative perturbation intensity is \code{(s+1)/(s+n)}, where \code{(s+1)/(s+50)=cooling.fraction}. - \code{cooling.fraction} is the relative magnitude of the parameter perturbations after 50 MIF iterations. + + When \code{cooling.type="geometric"}, on the n-th \code{mif} iteration, the relative perturbation intensity is \code{cooling.fraction^(n/50)}. + + When \code{cooling.type="hyperbolic"}, on the n-th \code{mif} iteration, the relative perturbation intensity is \code{(s+1)/(s+n)}, where \code{(s+1)/(s+50)=cooling.fraction}. + \code{cooling.fraction} is the relative magnitude of the parameter perturbations after 50 \code{mif} iterations. \code{cooling.factor} is now deprecated: - to achieve the old behavior, use \code{cooling.type="geometric"} and \code{cooling.fraction=(cooling.factor)^50}. + to achieve the old behavior, use \code{cooling.type="geometric"} and \preformatted{cooling.fraction=(cooling.factor)^50.} } \item{method}{ \code{method} sets the update rule used in the algorithm. \code{method="mif"} uses the iterated filtering update rule (Ionides 2006, 2011); \code{method="unweighted"} updates the parameter to the unweighted average of the filtering means of the parameters at each time; \code{method="fp"} updates the parameter to the filtering mean at the end of the time series. -% \code{method="mif2"} + \code{method="mif2"} implements an incomplete version of the iterated Bayes map method of Ionides (2015). + The latter method is, by every indication, both more efficient and more stable. } \item{tol}{ See the description under \code{\link{pfilter}}. @@ -120,25 +142,46 @@ \item{\dots}{ additional arguments that override the defaults. } + \item{pars}{names of parameters.} + \item{x}{a \code{mif} object.} } -\section{Re-running MIF Iterations}{ - To re-run a sequence of MIF iterations, one can use the \code{mif} method on a \code{mif} object. - By default, the same parameters used for the original MIF run are re-used (except for \code{weighted}, \code{tol}, \code{max.fail}, and \code{verbose}, the defaults of which are shown above). +\section{Re-running \code{mif} Iterations}{ + To re-run a sequence of \code{mif} iterations, one can use the \code{mif} method on a \code{mif} object. + By default, the same parameters used for the original \code{mif} run are re-used (except for \code{weighted}, \code{tol}, \code{max.fail}, and \code{verbose}, the defaults of which are shown above). If one does specify additional arguments, these will override the defaults. } -\section{Continuing MIF Iterations}{ - One can resume a series of MIF iterations from where one left off using the \code{continue} method. +\section{Continuing \code{mif} Iterations}{ + One can resume a series of \code{mif} iterations from where one left off using the \code{continue} method. A call to \code{mif} to perform \code{Nmif=m} iterations followed by a call to \code{continue} to perform \code{Nmif=n} iterations will produce precisely the same effect as a single call to \code{mif} to perform \code{Nmif=m+n} iterations. By default, all the algorithmic parameters are the same as used in the original call to \code{mif}. Additional arguments will override the defaults. } -\section{Using MIF to estimate initial-value parameters only}{ - One can use MIF's fixed-lag smoothing to estimate only initial value parameters (IVPs). +\section{Using \code{mif} to estimate initial-value parameters only}{ + One can use \code{mif}'s fixed-lag smoothing to estimate only initial value parameters (IVPs). In this case, \code{pars} is left empty and the IVPs to be estimated are named in \code{ivps}. - If \code{theta} is the current parameter vector, then at each MIF iteration, \code{Np} particles are drawn from a distribution centered at \code{theta} and with width proportional to \code{var.factor*rw.sd}, a particle filtering operation is performed, and \code{theta} is replaced by the filtering mean at \code{time(object)[ic.lag]}. + If \code{theta} is the current parameter vector, then at each \code{mif} iteration, \code{Np} particles are drawn from a distribution centered at \code{theta} and with width proportional to \code{var.factor*rw.sd}, a particle filtering operation is performed, and \code{theta} is replaced by the filtering mean at \code{time(object)[ic.lag]}. Note the implication that, when \code{mif} is used in this way on a time series any longer than \code{ic.lag}, unnecessary work is done. If the time series in \code{object} is longer than \code{ic.lag}, consider replacing \code{object} with \code{window(object,end=ic.lag)}. } +\section{Methods}{ + Methods that can be used to manipulate, display, or extract information from a \code{mif} object: + \describe{ + \item{conv.rec}{ + \code{conv.rec(object, pars = NULL)} returns the columns of the convergence-record matrix corresponding to the names in \code{pars}. + By default, all rows are returned. + } + \item{logLik}{ + Returns the value in the \code{loglik} slot. + NB: this is \emph{not} the same as the likelihood of the model at the MLE! + } + \item{c}{ + Concatenates \code{mif} objects into an \code{mifList}. + } + \item{plot}{ + Plots a series of diagnostic plots when applied to a \code{mif} or \code{mifList} object. + } + } +} \section{Details}{ If \code{particles} is not specified, the default behavior is to draw the particles from a multivariate normal distribution. \strong{It is the user's responsibility to ensure that, if the optional \code{particles} argument is given, that the \code{particles} function satisfies the following conditions:} @@ -166,13 +209,16 @@ Iterated filtering, Annals of Statistics, 39:1776--1802, 2011. + E. L. Ionides, D. Nguyen, Y. Atchad{\\'e}, S. Stoev, and A. A. King. + Inference for dynamic and latent variable models via iterated, perturbed Bayes maps. + Proc. Natl. Acad. Sci. U.S.A., 112:719--724, 2015. + A. A. King, E. L. Ionides, M. Pascual, and M. J. Bouma, Inapparent infections and cholera dynamics, Nature, 454:877--880, 2008. } \author{Aaron A. King \email{kingaa at umich dot edu}} \seealso{ - \code{\link{mif-methods}}, \code{\link{pomp}}, \code{\link{pfilter}}. - See the \dQuote{intro_to_pomp} vignette for examples. + \code{\link{pomp}}, \code{\link{pfilter}} } \keyword{ts} Modified: pkg/pomp/man/ou2.Rd =================================================================== --- pkg/pomp/man/ou2.Rd 2015-02-27 02:57:40 UTC (rev 1106) +++ pkg/pomp/man/ou2.Rd 2015-02-27 02:57:51 UTC (rev 1107) @@ -12,7 +12,6 @@ The observation process is \eqn{Y(t) = (y_1(t),y_2(t))}, where \eqn{y_i(t) \sim \mathrm{normal}(x_i(t),\tau)}. The functions \code{rprocess}, \code{dprocess}, \code{rmeasure}, \code{dmeasure}, and \code{skeleton} are implemented using compiled C code for computational speed: see the source code for details. - This object is demonstrated in the vignette "Advanced topics in pomp". } \examples{ pompExample(ou2) @@ -23,5 +22,5 @@ pf <- pfilter(ou2,Np=1000) logLik(pf) } -\seealso{\code{\link{pomp}} and the vignettes} -\keyword{datasets} +\seealso{\code{\link{pomp}}} +\keyword{ts} Deleted: pkg/pomp/man/pfilter-methods.Rd =================================================================== --- pkg/pomp/man/pfilter-methods.Rd 2015-02-27 02:57:40 UTC (rev 1106) +++ pkg/pomp/man/pfilter-methods.Rd 2015-02-27 02:57:51 UTC (rev 1107) @@ -1,62 +0,0 @@ -\name{pfilter-methods} -\alias{logLik,pfilterd.pomp-method} -\alias{logLik-pfilterd.pomp} -\alias{$,pfilterd.pomp-method} -\alias{$-pfilterd.pomp} -\alias{pred.mean} -\alias{pred.mean,pfilterd.pomp-method} -\alias{pred.mean-pfilterd.pomp} -\alias{pred.var} -\alias{pred.var,pfilterd.pomp-method} -\alias{pred.var-pfilterd.pomp} -\alias{filter.mean} -\alias{filter.mean,pfilterd.pomp-method} -\alias{filter.mean-pfilterd.pomp} -\alias{eff.sample.size} -\alias{eff.sample.size,pfilterd.pomp-method} -\alias{eff.sample.size-pfilterd.pomp} -\alias{cond.logLik} -\alias{cond.logLik,pfilterd.pomp-method} -\alias{cond.logLik-pfilterd.pomp} -\alias{as,pfilterd.pomp-method} -\alias{as.data.frame.pfilterd.pomp} -\alias{coerce,pfilterd.pomp,data.frame-method} -\title{Methods of the "pfilterd.pomp" class} -\description{Methods of the "pfilterd.pomp" class.} -\usage{ -\S4method{logLik}{pfilterd.pomp}(object, \dots) -\S4method{pred.mean}{pfilterd.pomp}(object, pars, \dots) -\S4method{pred.var}{pfilterd.pomp}(object, pars, \dots) -\S4method{filter.mean}{pfilterd.pomp}(object, pars, \dots) -\S4method{eff.sample.size}{pfilterd.pomp}(object, \dots) -\S4method{cond.logLik}{pfilterd.pomp}(object, \dots) -\S4method{as}{pfilterd.pomp}(object, class) -\S4method{coerce}{pfilterd.pomp,data.frame}(from, to = "data.frame", strict = TRUE) -\S3method{as.data.frame}{pfilterd.pomp}(x, row.names, optional, \dots) -} -\arguments{ - \item{object, x}{ - An object of class \code{pfilterd.pomp} or inheriting class \code{pfilterd.pomp}. - } - \item{pars}{Names of parameters.} - \item{class}{ - character; - name of the class to which \code{object} should be coerced. - } - \item{from, to}{ - the classes between which coercion should be performed. - } - \item{strict}{ - ignored. - } - \item{row.names, optional}{ - ignored. - } - \item{\dots}{ - Additional arguments unused at present. - } -} -\author{Aaron A. King \email{kingaa at umich dot edu}} -\seealso{\code{\link{pfilter}}, \link{pomp-class}} [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/pomp -r 1107 From noreply at r-forge.r-project.org Fri Feb 27 03:58:00 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 27 Feb 2015 03:58:00 +0100 (CET) Subject: [Pomp-commits] r1108 - pkg/pomp pkg/pomp/R pkg/pomp/inst pkg/pomp/man pkg/pomp/tests www/content www/vignettes Message-ID: <20150227025800.AAAE01876B8@r-forge.r-project.org> Author: kingaa Date: 2015-02-27 03:58:00 +0100 (Fri, 27 Feb 2015) New Revision: 1108 Modified: pkg/pomp/DESCRIPTION pkg/pomp/R/mif.R pkg/pomp/inst/NEWS pkg/pomp/inst/NEWS.Rd pkg/pomp/man/mif.Rd pkg/pomp/man/pfilter.Rd pkg/pomp/tests/bbs-trajmatch.Rout.save pkg/pomp/tests/bbs.Rout.save pkg/pomp/tests/blowflies.Rout.save pkg/pomp/tests/dacca.Rout.save pkg/pomp/tests/dimchecks.Rout.save pkg/pomp/tests/fhn.Rout.save pkg/pomp/tests/filtfail.Rout.save pkg/pomp/tests/gillespie.Rout.save pkg/pomp/tests/gompertz.Rout.save pkg/pomp/tests/logistic.Rout.save pkg/pomp/tests/ou2-abc.Rout.save pkg/pomp/tests/ou2-bsmc.Rout.save pkg/pomp/tests/ou2-bsmc2.Rout.save pkg/pomp/tests/ou2-forecast.Rout.save pkg/pomp/tests/ou2-kalman.Rout.save pkg/pomp/tests/ou2-mif-fp.Rout.save pkg/pomp/tests/ou2-mif.R pkg/pomp/tests/ou2-mif.Rout.save pkg/pomp/tests/ou2-mif2.R pkg/pomp/tests/ou2-mif2.Rout.save pkg/pomp/tests/ou2-nlf.Rout.save pkg/pomp/tests/ou2-pmcmc.Rout.save pkg/pomp/tests/ou2-probe.Rout.save pkg/pomp/tests/ou2-procmeas.Rout.save pkg/pomp/tests/ou2-simulate.Rout.save pkg/pomp/tests/ou2-spect.Rout.save pkg/pomp/tests/ou2-trajmatch.Rout.save pkg/pomp/tests/partrans.Rout.save pkg/pomp/tests/pfilter.Rout.save pkg/pomp/tests/pomppomp.Rout.save pkg/pomp/tests/prior.Rout.save pkg/pomp/tests/ricker-bsmc.Rout.save pkg/pomp/tests/ricker-probe.Rout.save pkg/pomp/tests/ricker-spect.Rout.save pkg/pomp/tests/ricker.Rout.save pkg/pomp/tests/rw2.Rout.save pkg/pomp/tests/sir.Rout.save pkg/pomp/tests/skeleton.Rout.save pkg/pomp/tests/steps.Rout.save pkg/pomp/tests/synlik.Rout.save pkg/pomp/tests/verhulst.Rout.save www/content/NEWS.html www/vignettes/pomp.pdf Log: - mif's 'pars' argument is now ignored, with a warning - update all tests, NEWS, and the manual - fix some problems in the help pages Modified: pkg/pomp/DESCRIPTION =================================================================== --- pkg/pomp/DESCRIPTION 2015-02-27 02:57:51 UTC (rev 1107) +++ pkg/pomp/DESCRIPTION 2015-02-27 02:58:00 UTC (rev 1108) @@ -1,7 +1,7 @@ Package: pomp Type: Package Title: Statistical Inference for Partially Observed Markov Processes -Version: 0.61-3 +Version: 0.62-1 Date: 2015-02-26 Authors at R: c(person(given=c("Aaron","A."),family="King", role=c("aut","cre"),email="kingaa at umich.edu"), @@ -24,10 +24,10 @@ LazyData: true MailingList: Subscribe to pomp-announce at r-forge.r-project.org for announcements by going to http://lists.r-forge.r-project.org/mailman/listinfo/pomp-announce. Collate: aaa.R authors.R generics.R eulermultinom.R - csnippet.R pomp-fun.R plugins.R builder.R load.R + csnippet.R pomp-fun.R plugins.R builder.R parmat.R logmeanexp.R slice-design.R profile-design.R sobol.R bsplines.R sannbox.R - pomp-class.R pomp.R pomp-methods.R + pomp-class.R load.R pomp.R pomp-methods.R rmeasure-pomp.R rprocess-pomp.R init-state-pomp.R dmeasure-pomp.R dprocess-pomp.R skeleton-pomp.R dprior-pomp.R rprior-pomp.R Modified: pkg/pomp/R/mif.R =================================================================== --- pkg/pomp/R/mif.R 2015-02-27 02:57:51 UTC (rev 1107) +++ pkg/pomp/R/mif.R 2015-02-27 02:58:00 UTC (rev 1108) @@ -81,32 +81,8 @@ ) } -mif.cooling <- function (factor, n) { # default geometric cooling schedule - alpha <- factor^(n-1) - list(alpha=alpha,gamma=alpha^2) -} - -mif2.cooling <- function (frac, nt, m, n) { # cooling schedule for mif2 - ## frac is the fraction of cooling after 50 iterations - scal <- (50*n*frac-1)/(1-frac) - alpha <- (1+scal)/(scal+nt+n*(m-1)) - list(alpha=alpha) -} - -powerlaw.cooling <- function (init = 1, delta = 0.1, eps = (1-delta)/2, n) { - m <- init - if (n <= m) { # linear cooling regime - alpha <- (m-n+1)/m - gamma <- alpha - } else { # power-law cooling regime - alpha <- ((n/m)^(delta+eps))/n - gamma <- ((n/m)^(delta+1))/n/n - } - list(alpha=alpha,gamma=gamma) -} - mif.internal <- function (object, Nmif, - start, pars, ivps, + start, pars = NULL, ivps, particles, rw.sd, Np, var.factor, ic.lag, @@ -138,52 +114,27 @@ if (is.null(start.names)) stop("mif error: ",sQuote("start")," must be a named vector",call.=FALSE) + if (!is.null(pars)) { + warning("mif warning: the ",sQuote("pars")," argument to ",sQuote("mif")," is unnecessary and deprecated and will be ignored.\n", + "This behavior differs from that previous to ",sQuote("pomp")," version 0.62",call.=FALSE) + } + rw.names <- names(rw.sd) if (is.null(rw.names) || any(rw.sd<0)) stop("mif error: ",sQuote("rw.sd")," must be a named non-negative numerical vector",call.=FALSE) if (!all(rw.names%in%start.names)) stop("mif error: all the names of ",sQuote("rw.sd")," must be names of ",sQuote("start"),call.=FALSE) - rw.names <- names(rw.sd[rw.sd>0]) + rw.names <- rw.names[rw.sd>0] if (length(rw.names) == 0) stop("mif error: ",sQuote("rw.sd")," must have one positive entry for each parameter to be estimated",call.=FALSE) + pars <- rw.names[!(rw.names%in%ivps)] - if ( - !is.character(pars) || - !is.character(ivps) || - !all(pars%in%start.names) || - !all(ivps%in%start.names) || - any(pars%in%ivps) || - any(ivps%in%pars) || - !all(pars%in%rw.names) || - !all(ivps%in%rw.names) - ) - stop( - "mif error: ", - sQuote("pars")," and ",sQuote("ivps"), - " must be mutually disjoint subsets of ", - sQuote("names(start)"), - " and must have a positive random-walk SDs specified in ", - sQuote("rw.sd"), - call.=FALSE - ) + if (!is.character(ivps) || !all(ivps%in%start.names)) + stop("mif error: ",sQuote("ivps")," must name model parameters",call.=FALSE) + +## rw.sd <- rw.sd[c(pars,ivps)] +## rw.names <- names(rw.sd) - if (!all(rw.names%in%c(pars,ivps))) { - extra.rws <- rw.names[!(rw.names%in%c(pars,ivps))] - warning( - ngettext(length(extra.rws),"mif warning: the variable ", - "mif warning: the variables "), - paste(sQuote(extra.rws),collapse=", "), - ngettext(length(extra.rws)," has positive random-walk SD specified, but is included in neither ", - " have positive random-walk SDs specified, but are included in neither "), - sQuote("pars")," nor ",sQuote("ivps"), - ngettext(length(extra.rws),". This random walk SD will be ignored.", - ". These random walk SDs will be ignored."), - call.=FALSE - ) - } - rw.sd <- rw.sd[c(pars,ivps)] - rw.names <- names(rw.sd) - ntimes <- length(time(object)) if (is.null(Np)) stop("mif error: ",sQuote("Np")," must be specified",call.=FALSE) if (is.function(Np)) { @@ -416,7 +367,7 @@ signature=signature(object="pomp"), function (object, Nmif = 1, start, - pars, ivps = character(0), + ivps = character(0), particles, rw.sd, Np, ic.lag, var.factor, cooling.type = c("geometric","hyperbolic"), @@ -441,10 +392,7 @@ ic.lag <- length(time(object)) } } - if (missing(pars)) { - rw.names <- names(rw.sd)[rw.sd>0] - pars <- rw.names[!(rw.names%in%ivps)] - } + if (missing(Np)) stop("mif error: ",sQuote("Np")," must be specified",call.=FALSE) if (missing(var.factor)) @@ -470,7 +418,6 @@ object=object, Nmif=Nmif, start=start, - pars=pars, ivps=ivps, particles=particles, rw.sd=rw.sd, @@ -586,48 +533,3 @@ obj } ) - -mif.profileDesign <- function (object, profile, lower, upper, nprof, ivps, - rw.sd, Np, ic.lag, var.factor, cooling.factor,option, cooling.fraction, paramMatrix, ...) -{ - if (missing(profile)) profile <- list() - if (missing(lower)) lower <- numeric(0) - if (missing(upper)) upper <- lower - if (length(lower)!=length(upper)) - stop(sQuote("lower")," and ",sQuote("upper")," must be of the same length") - pars <- names(lower) - if (missing(ivps)) ivps <- character(0) - Np <- as.integer(Np) - - pd <- do.call(profileDesign,c(profile,list(lower=lower,upper=upper,nprof=nprof))) - - object <- as(object,"pomp") - - pp <- coef(object) - idx <- !(names(pp)%in%names(pd)) - if (any(idx)) pd <- cbind(pd,as.list(pp[idx])) - - ans <- vector(mode="list",length=nrow(pd)) - for (k in seq_len(nrow(pd))) { - ans[[k]] <- list( - mf=mif( - object, - Nmif=0, - start=unlist(pd[k,]), - pars=pars, - ivps=ivps, - rw.sd=rw.sd, - Np=Np, - ic.lag=ic.lag, - var.factor=var.factor, - cooling.factor=cooling.factor, - option=option, - cooling.fraction=cooling.fraction, - paramMatrix=paramMatrix, - ... - ) - ) - } - - ans -} Modified: pkg/pomp/inst/NEWS =================================================================== --- pkg/pomp/inst/NEWS 2015-02-27 02:57:51 UTC (rev 1107) +++ pkg/pomp/inst/NEWS 2015-02-27 02:58:00 UTC (rev 1108) @@ -1,5 +1,11 @@ _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 _0._6_2-_1: + + ? ?mif?'s ?pars? argument, which is redundant, is now ignored + with a warning. In a future release, this argument will be + removed. + _C_h_a_n_g_e_s _i_n '_p_o_m_p' _v_e_r_s_i_o_n _0._6_1-_1: ? When using ?Csnippet?s or ?pompBuilder?, it is no longer Modified: pkg/pomp/inst/NEWS.Rd =================================================================== --- pkg/pomp/inst/NEWS.Rd 2015-02-27 02:57:51 UTC (rev 1107) +++ pkg/pomp/inst/NEWS.Rd 2015-02-27 02:58:00 UTC (rev 1108) @@ -1,5 +1,11 @@ \name{NEWS} \title{News for package `pomp'} +\section{Changes in \pkg{pomp} version 0.62-1}{ + \itemize{ + \item \code{mif}'s \code{pars} argument, which is redundant, is now ignored with a warning. + In a future release, this argument will be removed. + } +} \section{Changes in \pkg{pomp} version 0.61-1}{ \itemize{ \item When using \code{Csnippet}s or \code{pompBuilder}, it is no longer necessary to manually load and unload the dynamically loadable library. Modified: pkg/pomp/man/mif.Rd =================================================================== --- pkg/pomp/man/mif.Rd 2015-02-27 02:57:51 UTC (rev 1107) +++ pkg/pomp/man/mif.Rd 2015-02-27 02:58:00 UTC (rev 1108) @@ -126,24 +126,20 @@ \code{method="mif2"} implements an incomplete version of the iterated Bayes map method of Ionides (2015). The latter method is, by every indication, both more efficient and more stable. } - \item{tol}{ + \item{tol, max.fail}{ See the description under \code{\link{pfilter}}. } - \item{max.fail}{ - See the description under \code{\link{pfilter}}. - } \item{verbose}{ logical; if TRUE, print progress reports. } \item{transform}{ logical; - if \code{TRUE}, optimization is performed on the transformed scale. + if \code{TRUE}, optimization is performed on the transformed scale, as defined by the user-supplied parameter transformations (see \code{\link{pomp}}). } \item{\dots}{ additional arguments that override the defaults. } \item{pars}{names of parameters.} - \item{x}{a \code{mif} object.} } \section{Re-running \code{mif} Iterations}{ To re-run a sequence of \code{mif} iterations, one can use the \code{mif} method on a \code{mif} object. Modified: pkg/pomp/man/pfilter.Rd =================================================================== --- pkg/pomp/man/pfilter.Rd 2015-02-27 02:57:51 UTC (rev 1107) +++ pkg/pomp/man/pfilter.Rd 2015-02-27 02:58:00 UTC (rev 1108) @@ -103,8 +103,7 @@ } \item{pars}{Names of parameters.} \item{\dots}{ - By default, when \code{pfilter} pfilter is run on a \code{pfilterd.pomp} object, the settings in the original call are re-used. - This default behavior can be overridden by changing the settings (see Examples below). + additional arguments that override the defaults. } } \value{ @@ -170,9 +169,9 @@ logLik(pf) cond.logLik(pf) ## conditional log-likelihoods eff.sample.size(pf) ## effective sample size -logLik(pfilter(gompertz)) ## run it again with 1000 particles -## run it with 2000 particles -pf <- pfilter(gompertz,Np=2000,filter.mean=TRUE) +logLik(pfilter(pf)) ## run it again with 1000 particles +## run it again with 2000 particles +pf <- pfilter(pf,Np=2000,filter.mean=TRUE) fm <- filter.mean(pf) ## extract the filtering means } \references{ Modified: pkg/pomp/tests/bbs-trajmatch.Rout.save =================================================================== --- pkg/pomp/tests/bbs-trajmatch.Rout.save 2015-02-27 02:57:51 UTC (rev 1107) +++ pkg/pomp/tests/bbs-trajmatch.Rout.save 2015-02-27 02:58:00 UTC (rev 1108) @@ -80,4 +80,4 @@ > > proc.time() user system elapsed - 2.480 0.052 2.555 + 2.448 0.052 2.525 Modified: pkg/pomp/tests/bbs.Rout.save =================================================================== --- pkg/pomp/tests/bbs.Rout.save 2015-02-27 02:57:51 UTC (rev 1107) +++ pkg/pomp/tests/bbs.Rout.save 2015-02-27 02:58:00 UTC (rev 1108) @@ -73,4 +73,4 @@ > > proc.time() user system elapsed - 7.153 0.049 7.193 + 6.916 0.056 7.013 Modified: pkg/pomp/tests/blowflies.Rout.save =================================================================== --- pkg/pomp/tests/blowflies.Rout.save 2015-02-27 02:57:51 UTC (rev 1107) +++ pkg/pomp/tests/blowflies.Rout.save 2015-02-27 02:58:00 UTC (rev 1108) @@ -72,4 +72,4 @@ > > proc.time() user system elapsed - 1.304 0.044 1.380 + 1.320 0.060 1.411 Modified: pkg/pomp/tests/dacca.Rout.save =================================================================== --- pkg/pomp/tests/dacca.Rout.save 2015-02-27 02:57:51 UTC (rev 1107) +++ pkg/pomp/tests/dacca.Rout.save 2015-02-27 02:58:00 UTC (rev 1108) @@ -107,4 +107,4 @@ > > proc.time() user system elapsed - 10.852 0.064 10.968 + 11.408 0.084 11.550 Modified: pkg/pomp/tests/dimchecks.Rout.save =================================================================== --- pkg/pomp/tests/dimchecks.Rout.save 2015-02-27 02:57:51 UTC (rev 1107) +++ pkg/pomp/tests/dimchecks.Rout.save 2015-02-27 02:58:00 UTC (rev 1108) @@ -179,4 +179,4 @@ > > proc.time() user system elapsed - 0.560 0.092 0.677 + 0.592 0.072 0.689 Modified: pkg/pomp/tests/fhn.Rout.save =================================================================== --- pkg/pomp/tests/fhn.Rout.save 2015-02-27 02:57:51 UTC (rev 1107) +++ pkg/pomp/tests/fhn.Rout.save 2015-02-27 02:58:00 UTC (rev 1108) @@ -93,4 +93,4 @@ > > proc.time() user system elapsed - 1.084 0.064 1.285 + 1.064 0.032 1.243 Modified: pkg/pomp/tests/filtfail.Rout.save =================================================================== --- pkg/pomp/tests/filtfail.Rout.save 2015-02-27 02:57:51 UTC (rev 1107) +++ pkg/pomp/tests/filtfail.Rout.save 2015-02-27 02:58:00 UTC (rev 1108) @@ -116,4 +116,4 @@ > > proc.time() user system elapsed - 0.576 0.068 0.660 + 0.624 0.048 0.693 Modified: pkg/pomp/tests/gillespie.Rout.save =================================================================== --- pkg/pomp/tests/gillespie.Rout.save 2015-02-27 02:57:51 UTC (rev 1107) +++ pkg/pomp/tests/gillespie.Rout.save 2015-02-27 02:58:00 UTC (rev 1108) @@ -131,4 +131,4 @@ > > proc.time() user system elapsed - 2.564 0.048 2.635 + 2.488 0.056 2.574 Modified: pkg/pomp/tests/gompertz.Rout.save =================================================================== --- pkg/pomp/tests/gompertz.Rout.save 2015-02-27 02:57:51 UTC (rev 1107) +++ pkg/pomp/tests/gompertz.Rout.save 2015-02-27 02:58:00 UTC (rev 1108) @@ -133,4 +133,4 @@ > > proc.time() user system elapsed - 1.576 0.052 1.652 + 1.616 0.052 1.820 Modified: pkg/pomp/tests/logistic.Rout.save =================================================================== --- pkg/pomp/tests/logistic.Rout.save 2015-02-27 02:57:51 UTC (rev 1107) +++ pkg/pomp/tests/logistic.Rout.save 2015-02-27 02:58:00 UTC (rev 1108) @@ -124,4 +124,4 @@ > > proc.time() user system elapsed - 0.976 0.052 1.175 + 0.944 0.072 1.143 Modified: pkg/pomp/tests/ou2-abc.Rout.save =================================================================== --- pkg/pomp/tests/ou2-abc.Rout.save 2015-02-27 02:57:51 UTC (rev 1107) +++ pkg/pomp/tests/ou2-abc.Rout.save 2015-02-27 02:58:00 UTC (rev 1108) @@ -139,4 +139,4 @@ > > proc.time() user system elapsed - 11.422 0.073 11.497 + 11.092 0.068 11.369 Modified: pkg/pomp/tests/ou2-bsmc.Rout.save =================================================================== --- pkg/pomp/tests/ou2-bsmc.Rout.save 2015-02-27 02:57:51 UTC (rev 1107) +++ pkg/pomp/tests/ou2-bsmc.Rout.save 2015-02-27 02:58:00 UTC (rev 1108) @@ -59,7 +59,7 @@ > post <- smc$post > > print(etime <- toc-tic) -Time difference of 2.789886 secs +Time difference of 2.748923 secs > > print( + cbind( @@ -101,4 +101,4 @@ > > proc.time() user system elapsed - 4.688 0.064 4.785 + 4.712 0.032 4.777 Modified: pkg/pomp/tests/ou2-bsmc2.Rout.save =================================================================== --- pkg/pomp/tests/ou2-bsmc2.Rout.save 2015-02-27 02:57:51 UTC (rev 1107) +++ pkg/pomp/tests/ou2-bsmc2.Rout.save 2015-02-27 02:58:00 UTC (rev 1108) @@ -56,7 +56,7 @@ > post <- smc$post > > print(etime <- toc-tic) -Time difference of 2.022153 secs +Time difference of 1.971769 secs > > print( + cbind( @@ -98,4 +98,4 @@ > > proc.time() user system elapsed - 3.588 0.084 3.697 + 3.540 0.060 3.626 Modified: pkg/pomp/tests/ou2-forecast.Rout.save =================================================================== --- pkg/pomp/tests/ou2-forecast.Rout.save 2015-02-27 02:57:51 UTC (rev 1107) +++ pkg/pomp/tests/ou2-forecast.Rout.save 2015-02-27 02:58:00 UTC (rev 1108) @@ -61,4 +61,4 @@ > > proc.time() user system elapsed - 1.420 0.036 1.559 + 1.596 0.072 1.793 Modified: pkg/pomp/tests/ou2-kalman.Rout.save =================================================================== --- pkg/pomp/tests/ou2-kalman.Rout.save 2015-02-27 02:57:51 UTC (rev 1107) +++ pkg/pomp/tests/ou2-kalman.Rout.save 2015-02-27 02:58:00 UTC (rev 1108) @@ -164,7 +164,7 @@ 117 function evaluations used > toc <- Sys.time() > print(toc-tic) -Time difference of 3.41739 secs +Time difference of 3.520454 secs > tic <- Sys.time() > print(loglik.mle <- -kalm.fit1$value,digits=4) [1] -477.2 @@ -188,4 +188,4 @@ > > proc.time() user system elapsed - 3.933 0.035 3.954 + 4.172 0.068 4.270 Modified: pkg/pomp/tests/ou2-mif-fp.Rout.save =================================================================== --- pkg/pomp/tests/ou2-mif-fp.Rout.save 2015-02-27 02:57:51 UTC (rev 1107) +++ pkg/pomp/tests/ou2-mif-fp.Rout.save 2015-02-27 02:58:00 UTC (rev 1108) @@ -46,6 +46,9 @@ + max.fail=100, + method="fp" + ) +Warning message: +mif warning: the 'pars' argument to 'mif' is unnecessary and deprecated and will be ignored. +This behavior differs from that previous to 'pomp' version 0.62 > > mif2 <- mif(ou2,Nmif=100,start=guess2, + pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), @@ -61,6 +64,9 @@ + max.fail=100, + method="fp" + ) +Warning message: +mif warning: the 'pars' argument to 'mif' is unnecessary and deprecated and will be ignored. +This behavior differs from that previous to 'pomp' version 0.62 > > plot(c(mif1,mif2)) > @@ -70,4 +76,4 @@ > > proc.time() user system elapsed - 19.413 0.056 19.690 + 20.933 0.064 21.259 Modified: pkg/pomp/tests/ou2-mif.R =================================================================== --- pkg/pomp/tests/ou2-mif.R 2015-02-27 02:57:51 UTC (rev 1107) +++ pkg/pomp/tests/ou2-mif.R 2015-02-27 02:58:00 UTC (rev 1108) @@ -19,7 +19,7 @@ guess2[c('x1.0','x2.0','alpha.2','alpha.3')] <- 1.5*guess1[c('x1.0','x2.0','alpha.2','alpha.3')] mif1 <- mif(ou2,Nmif=30,start=guess1, - pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), + ivps=c('x1.0','x2.0'), rw.sd=c( x1.0=5,x2.0=5, alpha.2=0.1,alpha.3=0.1 @@ -33,7 +33,7 @@ ) mif2 <- mif(ou2,Nmif=30,start=guess2, - pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), + ivps=c('x1.0','x2.0'), transform=TRUE, rw.sd=c( x1.0=5,x2.0=5, @@ -60,9 +60,8 @@ mif( ou2, Nmif=1, - pars=c("alpha.1","alpha.4","x1.0"), ivps=c("x1.0","x2.0"), - rw.sd=c(x1.0=5,x2.0=5,alpha.1=0.1,alpha.4=0.2,alpha.3=0), + rw.sd=c(x1.0=5,x2.0=5,alpha.1=0.1,alpha.4=0.2,alpha.3=-1), Np=100,cooling.type="geometric",cooling.fraction=0.95^50, ic.lag=10,var.factor=1 ) @@ -71,62 +70,6 @@ try( mif( ou2, - Nmif=1, - pars=c("alpha.1","alpha.4"), - ivps=c("x1.0","x2.0"), - rw.sd=c(x1.0=5,x2.0=5,alpha.1=0,alpha.4=0.2,alpha.3=0), - Np=100, - cooling.type="geometric",cooling.fraction=0.95^50, - ic.lag=10,var.factor=1 - ) - ) - -try( - mif( - ou2, - Nmif=1, - ivps=c("x1.0","x2.0"), - rw.sd=c(alpha.1=0.1,alpha.4=0.2,alpha.3=0), - Np=100,cooling.type="geometric",cooling.fraction=0.95^50, - cooling.factor=0.95,ic.lag=10,var.factor=1 - ) - ) - -try( - mif( - ou2, - Nmif=1, - ivps=c("x1.0","x2.0"), - rw.sd=c(x1.0=5,x2.0=5,alpha.1=0.1,alpha.4=0.2,alpha.3=0), - Np=100,ic.lag=10,var.factor=1 - ) - ) - -try( - mif( - ou2, - Nmif=1, - ivps=c("x1.0","x2.0"), - rw.sd=c(x1.0=5,x2.0=5,alpha.1=0,alpha.4=0.2,alpha.3=0), - Np=-10,cooling.type="geometric",cooling.fraction=0.95^50, - ic.lag=10,var.factor=1 - ) - ) - -try( - mif( - ou2, - Nmif=-3, - ivps=c("x1.0","x2.0"), - rw.sd=c(x1.0=5,x2.0=5,alpha.1=0,alpha.4=0.2,alpha.3=0), - Np=11.6,cooling.type="geometric",cooling.fraction=0.95^50, - ic.lag=10,var.factor=1 - ) - ) - -try( - mif( - ou2, Nmif=2, start=c(alpha.1=0.9,alpha.2=0,alpha.3=0,alpha.4=-Inf,sigma.1=1,sigma.2=0,sigma.3=2,tau=1,x1.0=50,x2.0=-50), ivps=c("x1.0","x2.0"), @@ -151,7 +94,6 @@ fit <- mif( ou2, Nmif=0, - pars=c("alpha.2","alpha.3"), ivps=c("x1.0","x2.0"), rw.sd=c(x1.0=5,x2.0=5,alpha.2=0.1,alpha.3=0.2,alpha.3=0), Np=100,cooling.type="geometric",cooling.fraction=0.95^50, @@ -171,7 +113,7 @@ ff <- pfilter(fit,pred.mean=T,filter.mean=T,pred.var=T,max.fail=100,verbose=T) ff <- pfilter(ff) fit <- mif(fit,rw.sd=c(x1.0=5,x2.0=5,alpha.2=0.1,alpha.3=0.1)) -fit <- continue(fit,Nmif=2,ivps=c("x1.0"),pars=c("alpha.2")) +fit <- continue(fit,Nmif=2,ivps=c("x1.0"),rw.sd=c(x1.0=5,alpha.2=0.1)) s <- coef(fit) s[2] <- 0.01 fit <- mif(fit,Nmif=3,start=s) Modified: pkg/pomp/tests/ou2-mif.Rout.save =================================================================== --- pkg/pomp/tests/ou2-mif.Rout.save 2015-02-27 02:57:51 UTC (rev 1107) +++ pkg/pomp/tests/ou2-mif.Rout.save 2015-02-27 02:58:00 UTC (rev 1108) @@ -52,7 +52,7 @@ > guess2[c('x1.0','x2.0','alpha.2','alpha.3')] <- 1.5*guess1[c('x1.0','x2.0','alpha.2','alpha.3')] > > mif1 <- mif(ou2,Nmif=30,start=guess1, -+ pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), ++ ivps=c('x1.0','x2.0'), + rw.sd=c( + x1.0=5,x2.0=5, + alpha.2=0.1,alpha.3=0.1 @@ -69,7 +69,7 @@ See '?mif' for instructions on specifying the cooling schedule. > > mif2 <- mif(ou2,Nmif=30,start=guess2, -+ pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), ++ ivps=c('x1.0','x2.0'), + transform=TRUE, + rw.sd=c( + x1.0=5,x2.0=5, @@ -100,80 +100,17 @@ + mif( + ou2, + Nmif=1, -+ pars=c("alpha.1","alpha.4","x1.0"), + ivps=c("x1.0","x2.0"), -+ rw.sd=c(x1.0=5,x2.0=5,alpha.1=0.1,alpha.4=0.2,alpha.3=0), ++ rw.sd=c(x1.0=5,x2.0=5,alpha.1=0.1,alpha.4=0.2,alpha.3=-1), + Np=100,cooling.type="geometric",cooling.fraction=0.95^50, + ic.lag=10,var.factor=1 + ) + ) -Error : mif error: 'pars' and 'ivps' must be mutually disjoint subsets of 'names(start)' and must have a positive random-walk SDs specified in 'rw.sd' +Error : mif error: 'rw.sd' must be a named non-negative numerical vector > > try( + mif( + ou2, -+ Nmif=1, -+ pars=c("alpha.1","alpha.4"), -+ ivps=c("x1.0","x2.0"), -+ rw.sd=c(x1.0=5,x2.0=5,alpha.1=0,alpha.4=0.2,alpha.3=0), -+ Np=100, -+ cooling.type="geometric",cooling.fraction=0.95^50, -+ ic.lag=10,var.factor=1 -+ ) -+ ) -Error : mif error: 'pars' and 'ivps' must be mutually disjoint subsets of 'names(start)' and must have a positive random-walk SDs specified in 'rw.sd' -> -> try( -+ mif( -+ ou2, -+ Nmif=1, -+ ivps=c("x1.0","x2.0"), -+ rw.sd=c(alpha.1=0.1,alpha.4=0.2,alpha.3=0), -+ Np=100,cooling.type="geometric",cooling.fraction=0.95^50, -+ cooling.factor=0.95,ic.lag=10,var.factor=1 -+ ) -+ ) -Error : mif error: 'pars' and 'ivps' must be mutually disjoint subsets of 'names(start)' and must have a positive random-walk SDs specified in 'rw.sd' -> -> try( -+ mif( -+ ou2, -+ Nmif=1, -+ ivps=c("x1.0","x2.0"), -+ rw.sd=c(x1.0=5,x2.0=5,alpha.1=0.1,alpha.4=0.2,alpha.3=0), -+ Np=100,ic.lag=10,var.factor=1 -+ ) -+ ) -Error : mif error: 'cooling.fraction' must be specified -> -> try( -+ mif( -+ ou2, -+ Nmif=1, -+ ivps=c("x1.0","x2.0"), -+ rw.sd=c(x1.0=5,x2.0=5,alpha.1=0,alpha.4=0.2,alpha.3=0), -+ Np=-10,cooling.type="geometric",cooling.fraction=0.95^50, -+ ic.lag=10,var.factor=1 -+ ) -+ ) -Error in mif.internal(object = object, Nmif = Nmif, start = start, pars = pars, : - number of particles, 'Np', must always be positive -> -> try( -+ mif( -+ ou2, -+ Nmif=-3, -+ ivps=c("x1.0","x2.0"), -+ rw.sd=c(x1.0=5,x2.0=5,alpha.1=0,alpha.4=0.2,alpha.3=0), -+ Np=11.6,cooling.type="geometric",cooling.fraction=0.95^50, -+ ic.lag=10,var.factor=1 -+ ) -+ ) -Error : mif error: 'Nmif' must be a positive integer -> -> try( -+ mif( -+ ou2, + Nmif=2, + start=c(alpha.1=0.9,alpha.2=0,alpha.3=0,alpha.4=-Inf,sigma.1=1,sigma.2=0,sigma.3=2,tau=1,x1.0=50,x2.0=-50), + ivps=c("x1.0","x2.0"), @@ -202,7 +139,6 @@ > fit <- mif( + ou2, + Nmif=0, -+ pars=c("alpha.2","alpha.3"), + ivps=c("x1.0","x2.0"), + rw.sd=c(x1.0=5,x2.0=5,alpha.2=0.1,alpha.3=0.2,alpha.3=0), + Np=100,cooling.type="geometric",cooling.fraction=0.95^50, @@ -242,9 +178,7 @@ pfilter timestep 100 of 100 finished > ff <- pfilter(ff) > fit <- mif(fit,rw.sd=c(x1.0=5,x2.0=5,alpha.2=0.1,alpha.3=0.1)) -> fit <- continue(fit,Nmif=2,ivps=c("x1.0"),pars=c("alpha.2")) -Warning message: -mif warning: the variables 'alpha.3', 'x2.0' have positive random-walk SDs specified, but are included in neither 'pars' nor 'ivps'. These random walk SDs will be ignored. +> fit <- continue(fit,Nmif=2,ivps=c("x1.0"),rw.sd=c(x1.0=5,alpha.2=0.1)) > s <- coef(fit) > s[2] <- 0.01 > fit <- mif(fit,Nmif=3,start=s) @@ -283,4 +217,4 @@ > > proc.time() user system elapsed - 14.827 0.050 14.879 + 12.032 0.080 12.261 Modified: pkg/pomp/tests/ou2-mif2.R =================================================================== --- pkg/pomp/tests/ou2-mif2.R 2015-02-27 02:57:51 UTC (rev 1107) +++ pkg/pomp/tests/ou2-mif2.R 2015-02-27 02:58:00 UTC (rev 1108) @@ -11,7 +11,7 @@ set.seed(64857673L) mif1a <- mif(ou2,Nmif=100,start=guess1, - pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), + ivps=c('x1.0','x2.0'), rw.sd=c( x1.0=.5,x2.0=.5, alpha.2=0.1,alpha.3=0.1), @@ -26,7 +26,7 @@ ) mif2a <- mif(ou2,Nmif=100,start=guess1, - pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), + ivps=c('x1.0','x2.0'), rw.sd=c( x1.0=0.5,x2.0=.5, alpha.2=0.1,alpha.3=0.1), @@ -45,7 +45,7 @@ set.seed(64857673L) mif1b <- mif(ou2,Nmif=50,start=guess1, - pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), + ivps=c('x1.0','x2.0'), rw.sd=c( x1.0=.5,x2.0=.5, alpha.2=0.1,alpha.3=0.1), @@ -60,7 +60,7 @@ mif1b <- continue(mif1b,Nmif=50) mif2b <- mif(ou2,Nmif=50,start=guess1, - pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), + ivps=c('x1.0','x2.0'), rw.sd=c( x1.0=0.5,x2.0=.5, alpha.2=0.1,alpha.3=0.1), @@ -77,7 +77,7 @@ mif2b <- continue(mif2b,Nmif=50) mif2c <- mif(ou2,Nmif=50,start=guess1, - pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), + ivps=c('x1.0','x2.0'), rw.sd=c( x1.0=0.5,x2.0=.5, alpha.2=0.1,alpha.3=0.1), Modified: pkg/pomp/tests/ou2-mif2.Rout.save =================================================================== --- pkg/pomp/tests/ou2-mif2.Rout.save 2015-02-27 02:57:51 UTC (rev 1107) +++ pkg/pomp/tests/ou2-mif2.Rout.save 2015-02-27 02:58:00 UTC (rev 1108) @@ -32,7 +32,7 @@ > > set.seed(64857673L) > mif1a <- mif(ou2,Nmif=100,start=guess1, -+ pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), ++ ivps=c('x1.0','x2.0'), + rw.sd=c( + x1.0=.5,x2.0=.5, + alpha.2=0.1,alpha.3=0.1), @@ -47,7 +47,7 @@ + ) > > mif2a <- mif(ou2,Nmif=100,start=guess1, -+ pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), ++ ivps=c('x1.0','x2.0'), + rw.sd=c( + x1.0=0.5,x2.0=.5, + alpha.2=0.1,alpha.3=0.1), @@ -66,7 +66,7 @@ > > set.seed(64857673L) > mif1b <- mif(ou2,Nmif=50,start=guess1, -+ pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), ++ ivps=c('x1.0','x2.0'), + rw.sd=c( + x1.0=.5,x2.0=.5, + alpha.2=0.1,alpha.3=0.1), @@ -81,7 +81,7 @@ > mif1b <- continue(mif1b,Nmif=50) > > mif2b <- mif(ou2,Nmif=50,start=guess1, -+ pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), ++ ivps=c('x1.0','x2.0'), + rw.sd=c( + x1.0=0.5,x2.0=.5, + alpha.2=0.1,alpha.3=0.1), @@ -101,7 +101,7 @@ > mif2b <- continue(mif2b,Nmif=50) > > mif2c <- mif(ou2,Nmif=50,start=guess1, -+ pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), ++ ivps=c('x1.0','x2.0'), + rw.sd=c( + x1.0=0.5,x2.0=.5, + alpha.2=0.1,alpha.3=0.1), @@ -135,4 +135,4 @@ > > proc.time() user system elapsed - 49.355 0.040 49.763 + 51.303 0.148 51.806 Modified: pkg/pomp/tests/ou2-nlf.Rout.save =================================================================== --- pkg/pomp/tests/ou2-nlf.Rout.save 2015-02-27 02:57:51 UTC (rev 1107) +++ pkg/pomp/tests/ou2-nlf.Rout.save 2015-02-27 02:58:00 UTC (rev 1108) @@ -85,4 +85,4 @@ > > proc.time() user system elapsed - 4.380 0.092 6.425 + 4.416 0.048 4.523 Modified: pkg/pomp/tests/ou2-pmcmc.Rout.save =================================================================== --- pkg/pomp/tests/ou2-pmcmc.Rout.save 2015-02-27 02:57:51 UTC (rev 1107) +++ pkg/pomp/tests/ou2-pmcmc.Rout.save 2015-02-27 02:58:00 UTC (rev 1108) @@ -138,4 +138,4 @@ > > proc.time() user system elapsed - 28.662 0.057 28.743 + 32.378 0.076 32.745 Modified: pkg/pomp/tests/ou2-probe.Rout.save =================================================================== --- pkg/pomp/tests/ou2-probe.Rout.save 2015-02-27 02:57:51 UTC (rev 1107) +++ pkg/pomp/tests/ou2-probe.Rout.save 2015-02-27 02:58:00 UTC (rev 1108) @@ -340,4 +340,4 @@ > > proc.time() user system elapsed - 7.892 0.092 8.187 + 7.692 0.072 7.942 Modified: pkg/pomp/tests/ou2-procmeas.Rout.save =================================================================== --- pkg/pomp/tests/ou2-procmeas.Rout.save 2015-02-27 02:57:51 UTC (rev 1107) +++ pkg/pomp/tests/ou2-procmeas.Rout.save 2015-02-27 02:58:00 UTC (rev 1108) @@ -54,4 +54,4 @@ > > proc.time() user system elapsed - 0.408 0.048 0.479 + 0.588 0.076 0.684 Modified: pkg/pomp/tests/ou2-simulate.Rout.save =================================================================== --- pkg/pomp/tests/ou2-simulate.Rout.save 2015-02-27 02:57:51 UTC (rev 1107) +++ pkg/pomp/tests/ou2-simulate.Rout.save 2015-02-27 02:58:00 UTC (rev 1108) @@ -35,7 +35,7 @@ > ou2.sim <- simulate(ou2,params=p,nsim=100,seed=32043858) > toc <- Sys.time() > print(toc-tic) -Time difference of 0.006910086 secs +Time difference of 0.004848957 secs > > coef(ou2,c('x1.0','x2.0')) <- c(-50,50) > @@ -46,4 +46,4 @@ > > proc.time() user system elapsed - 0.508 0.040 0.572 + 0.608 0.052 0.680 Modified: pkg/pomp/tests/ou2-spect.Rout.save =================================================================== --- pkg/pomp/tests/ou2-spect.Rout.save 2015-02-27 02:57:51 UTC (rev 1107) +++ pkg/pomp/tests/ou2-spect.Rout.save 2015-02-27 02:58:00 UTC (rev 1108) @@ -38,4 +38,4 @@ > > proc.time() user system elapsed - 21.537 0.040 21.670 + 22.417 0.048 22.562 Modified: pkg/pomp/tests/ou2-trajmatch.Rout.save =================================================================== --- pkg/pomp/tests/ou2-trajmatch.Rout.save 2015-02-27 02:57:51 UTC (rev 1107) +++ pkg/pomp/tests/ou2-trajmatch.Rout.save 2015-02-27 02:58:00 UTC (rev 1108) @@ -175,4 +175,4 @@ > > proc.time() user system elapsed - 1.712 0.060 1.801 + 2.188 0.040 2.279 Modified: pkg/pomp/tests/partrans.Rout.save =================================================================== --- pkg/pomp/tests/partrans.Rout.save 2015-02-27 02:57:51 UTC (rev 1107) [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/pomp -r 1108 From noreply at r-forge.r-project.org Fri Feb 27 03:58:04 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 27 Feb 2015 03:58:04 +0100 (CET) Subject: [Pomp-commits] r1109 - pkg/pomp/man Message-ID: <20150227025804.304F11876B8@r-forge.r-project.org> Author: kingaa Date: 2015-02-27 03:58:03 +0100 (Fri, 27 Feb 2015) New Revision: 1109 Removed: pkg/pomp/man/pmcmc-methods.Rd pkg/pomp/man/probed-pomp-methods.Rd Modified: pkg/pomp/man/basic-probes.Rd pkg/pomp/man/csnippet.Rd pkg/pomp/man/eulermultinom.Rd pkg/pomp/man/pmcmc.Rd pkg/pomp/man/pomp-methods.Rd pkg/pomp/man/pomp.Rd pkg/pomp/man/probe.Rd pkg/pomp/man/spect.Rd Log: - more work on the help pages Modified: pkg/pomp/man/basic-probes.Rd =================================================================== --- pkg/pomp/man/basic-probes.Rd 2015-02-27 02:58:00 UTC (rev 1108) +++ pkg/pomp/man/basic-probes.Rd 2015-02-27 02:58:03 UTC (rev 1109) @@ -1,4 +1,6 @@ -\name{basic.probes} +\name{Probe functions} +\title{Some useful probes for partially-observed Markov processes} +\alias{Probe functions} \alias{basic.probes} \alias{probe.mean} \alias{probe.median} @@ -10,10 +12,9 @@ \alias{probe.ccf} \alias{probe.marginal} \alias{probe.nlar} -\title{Some probes for partially-observed Markov processes} \description{ - Several simple and configurable probes are provided in the package. - These can be used directly and as examples for building custom probes. + Several simple and configurable probes are provided with in the package. + These can be used directly and as templates for custom probes. } \usage{ probe.mean(var, trim = 0, transform = identity, na.rm = TRUE) Modified: pkg/pomp/man/csnippet.Rd =================================================================== --- pkg/pomp/man/csnippet.Rd 2015-02-27 02:58:00 UTC (rev 1108) +++ pkg/pomp/man/csnippet.Rd 2015-02-27 02:58:03 UTC (rev 1109) @@ -1,7 +1,7 @@ \name{Csnippet} +\title{C code snippets for accelerating computations} \alias{Csnippet} \alias{Csnippet-class} -\title{C code snippets} \description{ For including snippets of C code in \code{pomp} objects. } @@ -10,12 +10,21 @@ } \arguments{ \item{text}{ - character; a snippt of C code. + character; a snippet of C code. } } \value{ An object of class \code{Csnippet}. } +\section{Using C snippets to accelerate computations}{ + From version 0.50, \pkg{pomp} provides a facility whereby users can define their model's components using inline C code. + The \code{pomp} constructor combines these \code{Csnippet}s into a compilable C file stored in the \R session's temporary directory. + They are then compiled (via \code{\link[=SHLIB]{R CMD SHLIB}}) into dynamically loadable shared objects. + This is then dynamically loaded as needed. +} \author{Aaron A. King \email{kingaa at umich dot edu}} +\seealso{ + \code{\link{pomp}}, \code{\link{plugins}}, and the tutorials on the \href{http://pomp.r-forge.r-project.org}{package website}. +} \keyword{programming} \keyword{interface} Modified: pkg/pomp/man/eulermultinom.Rd =================================================================== --- pkg/pomp/man/eulermultinom.Rd 2015-02-27 02:58:00 UTC (rev 1108) +++ pkg/pomp/man/eulermultinom.Rd 2015-02-27 02:58:03 UTC (rev 1109) @@ -1,11 +1,11 @@ \name{eulermultinom} +\title{The Euler-multinomial distributions and Gamma white-noise processes} \alias{eulermultinom} \alias{reulermultinom} \alias{deulermultinom} \alias{rgammawn} -\title{Euler-multinomial death process} \description{ - Density and random-deviate generation for the Euler-multinomial death process with parameters \code{size}, \code{rate}, and \code{dt}. + This page documents both the Euler-multinomial family of distributions and the package's simulator of Gamma white-noise processes. } \usage{ reulermultinom(n = 1, size, rate, dt) @@ -75,6 +75,10 @@ Returns a vector of length \code{n} containing random increments of the integrated Gamma white noise process with intensity \code{sigma}. } } +\section{C interface}{ + A C API for these functions is also provided by the package. + At an \R prompt, execute \preformatted{file.show(system.file("include/pomp.h",package="pomp"))} to view the header file that defines and explains the API. +} \author{Aaron A. King \email{kingaa at umich dot edu}} \examples{ print(dn <- reulermultinom(5,size=100,rate=c(a=1,b=2,c=3),dt=0.1)) @@ -92,5 +96,5 @@ D. He, E. L. Ionides, & A. A. King, Plug-and-play inference for disease dynamics: measles in large and small populations as a case study. J. R. Soc. Interface, 7:271--283, 2010. - } +} \keyword{distribution} Deleted: pkg/pomp/man/pmcmc-methods.Rd =================================================================== --- pkg/pomp/man/pmcmc-methods.Rd 2015-02-27 02:58:00 UTC (rev 1108) +++ pkg/pomp/man/pmcmc-methods.Rd 2015-02-27 02:58:03 UTC (rev 1109) @@ -1,68 +0,0 @@ -\name{pmcmc-methods} -\docType{methods} -\alias{pmcmc-methods} -\alias{logLik,pmcmc-method} -\alias{logLik-pmcmc} -\alias{conv.rec,pmcmc-method} -\alias{conv.rec-pmcmc} -\alias{conv.rec,pmcmcList-method} -\alias{conv.rec-pmcmcList} -\alias{plot-pmcmc} -\alias{plot,pmcmc-method} -\alias{plot-pmcmcList} -\alias{plot,pmcmcList-method} -\alias{pmcmcList-class} -\alias{c-pmcmc} -\alias{c,pmcmc-method} -\alias{c-pmcmcList} -\alias{c,pmcmcList-method} -\alias{[-pmcmcList} -\alias{[,pmcmcList-method} -\title{Methods of the "pmcmc" class} -\description{Methods of the "pmcmc" class.} -\usage{ -\S4method{logLik}{pmcmc}(object, \dots) -\S4method{conv.rec}{pmcmc}(object, pars, \dots) -\S4method{conv.rec}{pmcmcList}(object, \dots) -\S4method{plot}{pmcmc}(x, y, \dots) -\S4method{plot}{pmcmcList}(x, y, \dots) -\S4method{c}{pmcmc}(x, \dots, recursive = FALSE) -\S4method{c}{pmcmcList}(x, \dots, recursive = FALSE) -} -\arguments{ - \item{object, x}{The \code{pmcmc} or \code{pmcmcList} object.} - \item{pars}{Names of parameters.} - \item{y, recursive}{Ignored.} - \item{\dots}{ - Further arguments (either ignored or passed to underlying functions). - } -} -\section{Methods}{ - \describe{ - \item{conv.rec}{ - \code{conv.rec(object, pars)} returns the columns of the convergence-record matrix corresponding to the names in \code{pars} as an object of class \code{\link[coda]{mcmc}} or \code{\link[coda]{mcmc.list}}. - } - \item{plot}{ - Diagnostic plots. - } - \item{logLik}{ - Returns the value in the \code{loglik} slot. - } - \item{c}{ - Concatenates \code{pmcmc} objects into a \code{pmcmcList}. - } - } -} -\references{ - C. Andrieu, A. Doucet and R. Holenstein, - Particle Markov chain Monte Carlo methods, - J. Roy. Stat. Soc B, to appear, 2010. - - C. Andrieu and G.O. Roberts, - The pseudo-marginal approach for efficient computation, - Ann Stat 37:697-725, 2009. -} -\author{Edward L. Ionides \email{ionides at umich dot edu}, Aaron A. King \email{kingaa at umich dot edu}} -\seealso{\code{\link{pmcmc}}, \code{\link{pomp}}, \code{\link{pomp-class}}, \code{\link{pfilter}}} -\keyword{models} -\keyword{ts} Modified: pkg/pomp/man/pmcmc.Rd =================================================================== --- pkg/pomp/man/pmcmc.Rd 2015-02-27 02:58:00 UTC (rev 1108) +++ pkg/pomp/man/pmcmc.Rd 2015-02-27 02:58:03 UTC (rev 1109) @@ -1,4 +1,5 @@ -\name{pmcmc} +\name{Particle Markov Chain Monte Carlo} +\title{The particle Markov chain Metropolis-Hastings algorithm} \docType{methods} \alias{pmcmc} \alias{pmcmc,pmcmc-method} @@ -10,7 +11,24 @@ \alias{continue,pmcmc-method} \alias{continue-pmcmc} \alias{pmcmc-class} -\title{The PMCMC algorithm} +\alias{pmcmc-methods} +\alias{logLik,pmcmc-method} +\alias{logLik-pmcmc} +\alias{conv.rec,pmcmc-method} +\alias{conv.rec-pmcmc} +\alias{conv.rec,pmcmcList-method} +\alias{conv.rec-pmcmcList} +\alias{plot-pmcmc} +\alias{plot,pmcmc-method} +\alias{plot-pmcmcList} +\alias{plot,pmcmcList-method} +\alias{pmcmcList-class} +\alias{c-pmcmc} +\alias{c,pmcmc-method} +\alias{c-pmcmcList} +\alias{c,pmcmcList-method} +\alias{[-pmcmcList} +\alias{[,pmcmcList-method} \description{ The Particle MCMC algorithm for estimating the parameters of a partially-observed Markov process. } @@ -80,6 +98,22 @@ This gives an asymptotically correct Bayesian procedure for parameter estimation (Andrieu and Roberts, 2009). An extension to give a correct Bayesian posterior distribution of unobserved state variables (as in Andrieu et al, 2010) has not yet been implemented. } +\section{Methods}{ + \describe{ + \item{conv.rec}{ + \code{conv.rec(object, pars)} returns the columns of the convergence-record matrix corresponding to the names in \code{pars} as an object of class \code{\link[coda]{mcmc}} or \code{\link[coda]{mcmc.list}}. + } + \item{plot}{ + Diagnostic plots. + } + \item{logLik}{ + Returns the value in the \code{loglik} slot. + } + \item{c}{ + Concatenates \code{pmcmc} objects into a \code{pmcmcList}. + } + } +} \references{ C. Andrieu, A. Doucet and R. Holenstein, Particle Markov chain Monte Carlo methods, @@ -91,6 +125,7 @@ } \author{Edward L. Ionides \email{ionides at umich dot edu}, Aaron A. King \email{kingaa at umich dot edu}} \seealso{ - \code{\link{pmcmc-class}}, \code{\link{pmcmc-methods}}, \code{\link{pomp}}, \code{\link{pomp-class}}, \code{\link{pfilter}}. + \code{\link{pomp}}, \code{\link{pfilter}}, + and the tutorials on the \href{http://pomp.r-forge.r-project.org}{package website}. } \keyword{ts} Modified: pkg/pomp/man/pomp-methods.Rd =================================================================== --- pkg/pomp/man/pomp-methods.Rd 2015-02-27 02:58:00 UTC (rev 1108) +++ pkg/pomp/man/pomp-methods.Rd 2015-02-27 02:58:03 UTC (rev 1109) @@ -1,4 +1,4 @@ -\name{pomp-methods} +\name{pomp methods} \docType{methods} \alias{pomp methods} \alias{pomp-methods} @@ -41,10 +41,9 @@ \alias{coef<-} \alias{coef<-,pomp-method} \alias{coef<--pomp} -\title{Methods of the "pomp" class} -\description{Methods of the \code{pomp} class.} +\title{Functions for manipulating, displaying, and extracting information from objects of the \code{pomp} class} +\description{This page documents the various methods that allow one to extract information from, display, plot, and modify \code{pomp} objects.} \usage{ -\S3method{as.data.frame}{pomp}(x, row.names, optional, \dots) \S4method{coef}{pomp}(object, pars, transform = FALSE, \dots) \S4method{coef}{pomp}(object, pars, transform = FALSE, \dots) <- value \S4method{obs}{pomp}(object, vars, \dots) @@ -62,7 +61,6 @@ \S4method{timezero}{pomp}(object, \dots) <- value \S4method{window}{pomp}(x, start, end, \dots) \S4method{as}{pomp}(object, class) -\S4method{coerce}{pomp,data.frame}(from, to = "data.frame", strict = TRUE) } \arguments{ \item{object, x}{The \code{pomp} object.} @@ -104,12 +102,6 @@ character; name of the class to which \code{object} should be coerced. } - \item{from, to}{ - the classes between which coercion should be performed. - } - \item{strict}{ - ignored. - } \item{y}{ignored.} \item{variables}{ optional character; @@ -134,9 +126,6 @@ logical; indicates if x- and y- axes should be drawn. } - \item{row.names, optional}{ - ignored. - } \item{\dots}{ Further arguments (either ignored or passed to underlying functions). } Modified: pkg/pomp/man/pomp.Rd =================================================================== --- pkg/pomp/man/pomp.Rd 2015-02-27 02:58:00 UTC (rev 1108) +++ pkg/pomp/man/pomp.Rd 2015-02-27 02:58:03 UTC (rev 1109) @@ -344,5 +344,6 @@ \link{process model plugins} } \keyword{models} +\keyword{interface} +\keyword{programming} \keyword{ts} - Modified: pkg/pomp/man/probe.Rd =================================================================== --- pkg/pomp/man/probe.Rd 2015-02-27 02:58:00 UTC (rev 1108) +++ pkg/pomp/man/probe.Rd 2015-02-27 02:58:03 UTC (rev 1109) @@ -1,4 +1,5 @@ \name{probe} +\title{Probe a partially-observed Markov process by computing summary statistics and the synthetic likelihood.} \alias{probe} \alias{probe,pomp-method} \alias{probe,probed.pomp-method} @@ -18,7 +19,39 @@ \alias{probe.match.objfun,probed.pomp-method} \alias{probe.match.objfun-pomp} \alias{probe.match.objfun-probed.pomp} -\title{Probe a partially-observed Markov process.} +\alias{probed.pomp-methods} +\alias{probe.matched.pomp-methods} +\alias{spect.pomp-methods} +\alias{spect.matched.pomp-methods} +\alias{summary,probed.pomp-method} +\alias{summary,probe.matched.pomp-method} +\alias{summary-probed.pomp} +\alias{summary-probe.matched.pomp} +\alias{values} +\alias{values,probed.pomp-method} +\alias{values,probe.matched.pomp-method} +\alias{values-probed.pomp} +\alias{values-probe.matched.pomp} +\alias{plot,probed.pomp-method} +\alias{plot,probe.matched.pomp-method} +\alias{plot-probed.pomp} +\alias{plot-probe.matched.pomp} +\alias{summary,spect.pomp-method} +\alias{summary,spect.matched.pomp-method} +\alias{summary-spect.pomp} +\alias{summary-spect.matched.pomp} +\alias{plot,spect.pomp-method} +\alias{plot,spect.matched.pomp-method} +\alias{plot,spect.pomp-method} +\alias{plot-spect.pomp} +\alias{as,probed.pomp-method} +\alias{logLik,probed.pomp-method} +\alias{logLik-probed.pomp} +\alias{$,probed.pomp-method} +\alias{$-probed.pomp} +\alias{$,probe.matched.pomp-method} +\alias{$-probe.matched.pomp} +\alias{coerce,probed.pomp,data.frame-method} \description{ \code{probe} applies one or more \dQuote{probes} to time series data and model simulations and compares the results. It can be used to diagnose goodness of fit and/or as the basis for \dQuote{probe-matching}, a generalized method-of-moments approach to parameter estimation. @@ -43,6 +76,8 @@ \S4method{probe.match}{probe.matched.pomp}(object, est, probes, nsim, seed, transform, fail.value, \dots, verbose = getOption("verbose")) +\S4method{logLik}{probed.pomp}(object, \dots) +\S4method{values}{probed.pomp}(object, \dots) } \arguments{ \item{object}{ @@ -52,7 +87,7 @@ 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 \code{pomp}. A vector-valued probe must always return a vector of the same size. - A number of basic examples are provided with the package (see \link{basic.probes}). + A number of useful examples are provided with the package: see \link{Probe functions}). } \item{params}{ optional named numeric vector of model parameters. @@ -141,6 +176,29 @@ \code{probe.match.objfun} returns a function suitable for use as an objective function in an \code{\link{optim}}-like optimizer. } +\section{Methods}{ + \describe{ + \item{plot}{ + displays diagnostic plots. + } + \item{summary}{ + displays summary information. + } + \item{values}{ + extracts the realized values of the probes on the data and on the simulations as a data frame in long format. + The variable \code{.id} indicates whether the probes are from the data or simulations. + } + \item{logLik}{ + returns the synthetic likelihood for the probes. + NB: in general, this is not the same as the likelihood. + } + \item{as, as.data.frame}{ + when a \sQuote{probed.pomp} is coerced to a \sQuote{data.frame}, the first row gives the probes applied to the data; the rest of the rows give the probes evaluated on simulated data. + The rownames of the result can be used to distinguish these. + } + } + In addition, slots of this object can be accessed via the \code{$} operator. +} \references{ B. E. Kendall, C. J. Briggs, W. M. Murdoch, P. Turchin, S. P. Ellner, E. McCauley, R. M. Nisbet, S. N. Wood Why do populations cycle? A synthesis of statistical and mechanistic modeling approaches, @@ -188,14 +246,8 @@ plot(bad) } \seealso{ - \link{pomp-class}, - \link{pomp-methods}, - \link{basic.probes}, - \code{\link{probe.match}} + \link{pomp}, \link{Probe functions}, \link{spect}, + and the tutorials on the \href{http://pomp.r-forge.r-project.org}{package website}. } \keyword{models} \keyword{ts} - - - - Deleted: pkg/pomp/man/probed-pomp-methods.Rd =================================================================== --- pkg/pomp/man/probed-pomp-methods.Rd 2015-02-27 02:58:00 UTC (rev 1108) +++ pkg/pomp/man/probed-pomp-methods.Rd 2015-02-27 02:58:03 UTC (rev 1109) @@ -1,106 +0,0 @@ -\name{probed.pomp-methods} -\docType{methods} -\alias{probed.pomp-methods} -\alias{probe.matched.pomp-methods} -\alias{spect.pomp-methods} -\alias{spect.matched.pomp-methods} -\alias{summary,probed.pomp-method} -\alias{summary,probe.matched.pomp-method} -\alias{summary-probed.pomp} -\alias{summary-probe.matched.pomp} -\alias{values} -\alias{values,probed.pomp-method} -\alias{values,probe.matched.pomp-method} -\alias{values-probed.pomp} -\alias{values-probe.matched.pomp} -\alias{plot,probed.pomp-method} -\alias{plot,probe.matched.pomp-method} -\alias{plot-probed.pomp} -\alias{plot-probe.matched.pomp} -\alias{summary,spect.pomp-method} -\alias{summary,spect.matched.pomp-method} -\alias{summary-spect.pomp} -\alias{summary-spect.matched.pomp} -\alias{plot,spect.pomp-method} -\alias{plot,spect.matched.pomp-method} -\alias{plot,spect.pomp-method} -\alias{plot-spect.pomp} -\alias{as,probed.pomp-method} -\alias{logLik,probed.pomp-method} -\alias{logLik-probed.pomp} -\alias{$,probed.pomp-method} -\alias{$-probed.pomp} -\alias{$,probe.matched.pomp-method} -\alias{$-probe.matched.pomp} -\alias{coerce,probed.pomp,data.frame-method} -\title{Methods of the "probed.pomp", "probe.matched.pomp", "spect.pomp", and "spect.matched.pomp" classes} -\description{Methods of the \code{probed.pomp}, \code{probe.matched.pomp}, \code{spect.pomp}, and \code{spect.matched.pomp} classes} -\usage{ -\S4method{summary}{probed.pomp}(object, \dots) -\S4method{plot}{probed.pomp}(x, y, \dots) -\S4method{summary}{probe.matched.pomp}(object, \dots) -\S4method{plot}{probe.matched.pomp}(x, y, \dots) -\S4method{summary}{spect.pomp}(object, \dots) -\S4method{logLik}{probed.pomp}(object, \dots) -\S4method{values}{probed.pomp}(object, \dots) -\S4method{plot}{spect.pomp}(x, y, max.plots.per.page = 4, - plot.data = TRUE, - quantiles = c(.025, .25, .5, .75, .975), - quantile.styles = list(lwd=1, lty=1, col="gray70"), - data.styles = list(lwd=2, lty=2, col="black")) -\S4method{summary}{spect.matched.pomp}(object, \dots) -\S4method{plot}{spect.matched.pomp}(x, y, \dots) -\S4method{as}{probed.pomp}(object, class) -} -\arguments{ - \item{object, x}{the object to be summarized or plotted.} - \item{y}{ignored.} - \item{max.plots.per.page}{maximum number of plots per page} - \item{plot.data}{plot the data spectrum?} - \item{quantiles}{quantiles to plot} - \item{quantile.styles}{plot style parameters for the quantiles} - \item{data.styles}{plot style parameters for the data spectrum} - \item{class}{ - character; - name of the class to which \code{object} should be coerced. - } - \item{\dots}{ - Further arguments (either ignored or passed to underlying functions). - } -} -\section{Methods}{ - \describe{ - \item{plot}{ - displays diagnostic plots. - } - \item{summary}{ - displays summary information. - } - \item{values}{ - extracts the realized values of the probes on the data and on the simulations as a data frame in long format. - The variable \code{.id} indicates whether the probes are from the data or simulations. - } - \item{logLik}{ - returns the synthetic likelihood for the probes. - NB: in general, this is not the same as the likelihood. - } - \item{as}{ - when a \sQuote{probed.pomp} is coerced to a \sQuote{data.frame}, the first row gives the probes applied to the data; the rest of the rows give the probes evaluated on simulated data. - The rownames of the result can be used to distinguish these. - } - } - - In addition, slots of this object can be accessed via the \code{$} operator. - -} -\author{ - Daniel C. Reuman, Aaron A. King -} -\seealso{ - \code{\link{probe}}, - \code{\link[=probed.pomp-class]{probed.pomp}}, - \code{\link[=probe.matched.pomp-class]{probe.matched.pomp}}, - \code{\link{probe.match}} -} -\keyword{models} -\keyword{ts} Modified: pkg/pomp/man/spect.Rd =================================================================== --- pkg/pomp/man/spect.Rd 2015-02-27 02:58:00 UTC (rev 1108) +++ pkg/pomp/man/spect.Rd 2015-02-27 02:58:03 UTC (rev 1109) @@ -174,10 +174,7 @@ plot(bad) } \seealso{ - \link{pomp-class}, - \link{pomp-methods}, - \code{\link{probe}}, - \code{\link{probe.match}} + \link{pomp}, \code{\link{probe}} } \keyword{models} \keyword{ts} From noreply at r-forge.r-project.org Fri Feb 27 03:58:13 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 27 Feb 2015 03:58:13 +0100 (CET) Subject: [Pomp-commits] r1110 - in pkg/pomp: inst/examples man Message-ID: <20150227025813.0D5871876B8@r-forge.r-project.org> Author: kingaa Date: 2015-02-27 03:58:10 +0100 (Fri, 27 Feb 2015) New Revision: 1110 Removed: pkg/pomp/inst/examples/ou2.c Modified: pkg/pomp/man/basic-probes.Rd pkg/pomp/man/blowflies.Rd pkg/pomp/man/bsmc.Rd pkg/pomp/man/bsplines.Rd pkg/pomp/man/dacca.Rd pkg/pomp/man/eulermultinom.Rd pkg/pomp/man/example.Rd pkg/pomp/man/gompertz.Rd pkg/pomp/man/mif.Rd pkg/pomp/man/nlf.Rd pkg/pomp/man/ou2.Rd pkg/pomp/man/particles-mif.Rd pkg/pomp/man/pfilter.Rd pkg/pomp/man/plugins.Rd pkg/pomp/man/pomp-fun.Rd pkg/pomp/man/pomp-methods.Rd pkg/pomp/man/pomp-package.Rd pkg/pomp/man/pomp.Rd pkg/pomp/man/probe.Rd pkg/pomp/man/proposals.Rd pkg/pomp/man/ricker.Rd pkg/pomp/man/rw2.Rd pkg/pomp/man/sannbox.Rd pkg/pomp/man/simulate-pomp.Rd pkg/pomp/man/sir.Rd pkg/pomp/man/spect.Rd pkg/pomp/man/traj-match.Rd pkg/pomp/man/verhulst.Rd Log: - get rid of 'ou2.c' in inst/examples - edit help files Deleted: pkg/pomp/inst/examples/ou2.c =================================================================== --- pkg/pomp/inst/examples/ou2.c 2015-02-27 02:58:03 UTC (rev 1109) +++ pkg/pomp/inst/examples/ou2.c 2015-02-27 02:58:10 UTC (rev 1110) @@ -1,291 +0,0 @@ -// -*- C++ -*- - -// 2-D Ornstein-Uhlenbeck examples as discussed in the "Advanced Topics in pomp" vignette. - -#include -#include -#include - -// prototypes -void ou2_normal_rmeasure (double *y, double *x, double *p, - int *obsindex, int *stateindex, int *parindex, int *covindex, - int ncovar, double *covar, double t); -void ou2_normal_dmeasure (double *lik, double *y, double *x, double *p, int give_log, - int *obsindex, int *stateindex, int *parindex, int *covindex, - int covdim, double *covar, double t); -void ou2_adv (double *x, double *xstart, double *par, double *times, int *n); -void _ou2_adv (double *x, double *xstart, double *par, double *times, int *n, int *parindex); -void ou2_step (double *x, const double *p, - const int *stateindex, const int *parindex, const int *covindex, - int ncovars, const double *covars, - double t, double dt); -void ou2_pdf (double *d, double *X, double *par, double *times, int *n, int *parindex, int *give_log); -static void sim_ou2 (double *x, - double alpha1, double alpha2, double alpha3, double alpha4, - double sigma1, double sigma2, double sigma3); -static double dens_ou2 (double *x1, double *x2, - double alpha1, double alpha2, double alpha3, double alpha4, - double sigma1, double sigma2, double sigma3, int give_log); - -#define ALPHA1 (pp[0]) -#define ALPHA2 (pp[1]) -#define ALPHA3 (pp[2]) -#define ALPHA4 (pp[3]) -#define SIGMA1 (pp[4]) -#define SIGMA2 (pp[5]) -#define SIGMA3 (pp[6]) - -// advance the matrix of particles from times[0] to the other times given -// note that you cannot assume that you can only assume that times[k]-times[k-1]>=0 -// i.e., you cannot assume that successive times are consecutive, nor can you assume that -// they are distinct. -void ou2_adv (double *x, double *xstart, double *par, double *times, int *n) -{ - int nvar = n[0], npar = n[1], nrep = n[2], ntimes = n[3], incr; - double tnow, tgoal, dt = 1.0; - double *xp0, *xp1, *pp; - int i, j, k; - - incr = nrep*nvar; - - GetRNGstate(); // initialize R's pseudorandom number generator - - for (j = 0; j < nrep; j++) { - - R_CheckUserInterrupt(); // check for an interrupt signal - - xp0 = &xstart[nvar*j]; // pointer to j-th starting state - xp1 = &x[nvar*j]; // pointer to j-th state vector - pp = &par[npar*j]; // pointer to j-th parameter vector - - for (i = 0; i < nvar; i++) xp1[i] = xp0[i]; // copy xstart into the first slice of x - - tnow = times[0]; // initial time - - for (k = 1; k < ntimes; k++) { // loop over times - - xp0 = xp1; - xp1 += incr; - - for (i = 0; i < nvar; i++) xp1[i] = xp0[i]; // copy state vector - - tgoal = times[k]; - - while (tnow < tgoal) { - sim_ou2(xp1,ALPHA1,ALPHA2,ALPHA3,ALPHA4,SIGMA1,SIGMA2,SIGMA3); // advance state - tnow += dt; // advance time - } - - } - - } - - PutRNGstate(); // finished with R's random number generator -} - -#undef ALPHA1 -#undef ALPHA2 -#undef ALPHA3 -#undef ALPHA4 -#undef SIGMA1 -#undef SIGMA2 -#undef SIGMA3 - -#define ALPHA1 (pp[parindex[0]]) -#define ALPHA2 (pp[parindex[1]]) -#define ALPHA3 (pp[parindex[2]]) -#define ALPHA4 (pp[parindex[3]]) -#define SIGMA1 (pp[parindex[4]]) -#define SIGMA2 (pp[parindex[5]]) -#define SIGMA3 (pp[parindex[6]]) - -// just like the above, but with parindex -void _ou2_adv (double *x, double *xstart, double *par, double *times, int *n, int *parindex) -{ - int nvar = n[0], npar = n[1], nrep = n[2], ntimes = n[3], incr; - double tnow, tgoal, dt = 1.0; - double *xp0, *xp1, *pp; - int i, j, k; - - incr = nrep*nvar; - - GetRNGstate(); // initialize R's pseudorandom number generator - - for (j = 0; j < nrep; j++) { - - R_CheckUserInterrupt(); // check for an interrupt signal - - xp0 = &xstart[nvar*j]; // pointer to j-th starting state - xp1 = &x[nvar*j]; // pointer to j-th state vector - pp = &par[npar*j]; // pointer to j-th parameter vector - - for (i = 0; i < nvar; i++) xp1[i] = xp0[i]; // copy xstart into the first slice of x - - tnow = times[0]; // initial time - - for (k = 1; k < ntimes; k++) { // loop over times - - xp0 = xp1; - xp1 += incr; - - for (i = 0; i < nvar; i++) xp1[i] = xp0[i]; // copy state vector - - tgoal = times[k]; - - while (tnow < tgoal) { - sim_ou2(xp1,ALPHA1,ALPHA2,ALPHA3,ALPHA4,SIGMA1,SIGMA2,SIGMA3); // advance state - tnow += dt; // advance time - } - - } - - } - - PutRNGstate(); // finished with R's random number generator -} - -// pdf of a single 2D OU transition -void ou2_pdf (double *d, double *X, double *par, double *times, int *n, int *parindex, int *give_log) -{ - int nvar = n[0], npar = n[1], nrep = n[2], ntimes = n[3]; - double *x1, *x2, *pp; - int j, k; - for (k = 0; k < nrep; k++) { - pp = &par[npar*k]; // get address of k-th parameter vector - x1 = &X[nvar*k]; // get address of (0,0)-th state vector - for (j = 1; j < ntimes; j++) { - R_CheckUserInterrupt(); - x2 = &X[nvar*(k+nrep*j)]; // get address of (k,j)-th state vector - d[k+nrep*(j-1)] = dens_ou2(x1,x2,ALPHA1,ALPHA2,ALPHA3,ALPHA4,SIGMA1,SIGMA2,SIGMA3,*give_log); - x1 = x2; - } - } -} - -#undef ALPHA1 -#undef ALPHA2 -#undef ALPHA3 -#undef ALPHA4 -#undef SIGMA1 -#undef SIGMA2 -#undef SIGMA3 - -#define ALPHA1 (p[parindex[0]]) -#define ALPHA2 (p[parindex[1]]) -#define ALPHA3 (p[parindex[2]]) -#define ALPHA4 (p[parindex[3]]) -#define SIGMA1 (p[parindex[4]]) -#define SIGMA2 (p[parindex[5]]) -#define SIGMA3 (p[parindex[6]]) -#define TAU (p[parindex[7]]) - -#define X1 (x[stateindex[0]]) -#define X2 (x[stateindex[1]]) -#define Y1 (y[obsindex[0]]) -#define Y2 (y[obsindex[1]]) - -// onestep simulator for use in 'discrete.time.sim' plug-in -void ou2_step (double *x, const double *p, - const int *stateindex, const int *parindex, const int *covindex, - int ncovars, const double *covars, - double t, double dt) -{ - sim_ou2(x,ALPHA1,ALPHA2,ALPHA3,ALPHA4,SIGMA1,SIGMA2,SIGMA3); -} - - -// bivariate normal measurement error density -void ou2_normal_dmeasure (double *lik, double *y, double *x, double *p, int give_log, - int *obsindex, int *stateindex, int *parindex, int *covindex, - int covdim, double *covar, double t) -{ - double sd = fabs(TAU); - double f = 0.0; - f += (ISNA(Y1)) ? 0.0 : dnorm(Y1,X1,sd,1); - f += (ISNA(Y2)) ? 0.0 : dnorm(Y2,X2,sd,1); - *lik = (give_log) ? f : exp(f); -} - -// bivariate normal measurement error simulator -void ou2_normal_rmeasure (double *y, double *x, double *p, - int *obsindex, int *stateindex, int *parindex, int *covindex, - int ncovar, double *covar, - double t) -{ - double sd = fabs(TAU); - Y1 = rnorm(X1,sd); - Y2 = rnorm(X2,sd); -} - -#undef ALPHA1 -#undef ALPHA2 -#undef ALPHA3 -#undef ALPHA4 -#undef SIGMA1 -#undef SIGMA2 -#undef SIGMA3 -#undef TAU - -#undef X1 -#undef X2 -#undef Y1 -#undef Y2 - -// simple 2D Ornstein-Uhlenbeck process simulation -static void sim_ou2 (double *x, - double alpha1, double alpha2, double alpha3, double alpha4, - double sigma1, double sigma2, double sigma3) -{ - double eps[2], xnew[2]; - - if (!(R_FINITE(x[0]))) return; - if (!(R_FINITE(x[1]))) return; - if (!(R_FINITE(alpha1))) return; - if (!(R_FINITE(alpha2))) return; - if (!(R_FINITE(alpha3))) return; - if (!(R_FINITE(alpha4))) return; - if (!(R_FINITE(sigma1))) return; - if (!(R_FINITE(sigma2))) return; - if (!(R_FINITE(sigma3))) return; - - eps[0] = rnorm(0,1); - eps[1] = rnorm(0,1); - - xnew[0] = alpha1*x[0]+alpha3*x[1]+sigma1*eps[0]; - xnew[1] = alpha2*x[0]+alpha4*x[1]+sigma2*eps[0]+sigma3*eps[1]; - - x[0] = xnew[0]; - x[1] = xnew[1]; -} - -// simple 2D Ornstein-Uhlenbeck process density -static double dens_ou2 (double *x1, double *x2, - double alpha1, double alpha2, double alpha3, double alpha4, - double sigma1, double sigma2, double sigma3, int give_log) -{ - double eps[2], val; - - if (!(R_FINITE(x1[0]))) return R_NaReal; - if (!(R_FINITE(x1[1]))) return R_NaReal; - if (!(R_FINITE(x2[0]))) return R_NaReal; - if (!(R_FINITE(x2[1]))) return R_NaReal; - if (!(R_FINITE(alpha1))) return R_NaReal; - if (!(R_FINITE(alpha2))) return R_NaReal; - if (!(R_FINITE(alpha3))) return R_NaReal; - if (!(R_FINITE(alpha4))) return R_NaReal; - if (!(R_FINITE(sigma1))) return R_NaReal; - if (!(R_FINITE(sigma2))) return R_NaReal; - if (!(R_FINITE(sigma3))) return R_NaReal; - - // compute residuals - eps[0] = x2[0]-alpha1*x1[0]-alpha3*x1[1]; - eps[1] = x2[1]-alpha2*x1[0]-alpha4*x1[1]; - - // backsolve - eps[0] /= sigma1; - eps[1] -= sigma2*eps[0]; - eps[1] /= sigma3; - - val = dnorm(eps[0],0.0,1.0,1)+dnorm(eps[1],0.0,1.0,1)-log(sigma1)-log(sigma3); - return ((give_log) ? val : exp(val)); -} Modified: pkg/pomp/man/basic-probes.Rd =================================================================== --- pkg/pomp/man/basic-probes.Rd 2015-02-27 02:58:03 UTC (rev 1109) +++ pkg/pomp/man/basic-probes.Rd 2015-02-27 02:58:10 UTC (rev 1110) @@ -141,5 +141,4 @@ \seealso{ \link{pomp} } -\keyword{models} \keyword{ts} Modified: pkg/pomp/man/blowflies.Rd =================================================================== --- pkg/pomp/man/blowflies.Rd 2015-02-27 02:58:03 UTC (rev 1109) +++ pkg/pomp/man/blowflies.Rd 2015-02-27 02:58:10 UTC (rev 1110) @@ -64,4 +64,5 @@ in G. Oster (ed.), Some Questions in Mathematical Biology, vol. 13, pp. 65--90. American Mathematical Society, Providence. } +\keyword{models} \keyword{datasets} Modified: pkg/pomp/man/bsmc.Rd =================================================================== --- pkg/pomp/man/bsmc.Rd 2015-02-27 02:58:03 UTC (rev 1109) +++ pkg/pomp/man/bsmc.Rd 2015-02-27 02:58:10 UTC (rev 1110) @@ -1,5 +1,6 @@ -\name{bsmc2} -\title{Liu and West Bayesian Particle Filter} +\name{Bayesian sequential Monte Carlo} +\title{The Liu and West Bayesian particle filter} +\alias{Bayesian sequential Monte Carlo} \alias{bsmc} \alias{bsmc-pomp} \alias{bsmc,pomp-method} @@ -14,14 +15,14 @@ Modified versions of the Liu and West (2001) algorithm. } \usage{ +\S4method{bsmc2}{pomp}(object, params, Np, est, smooth = 0.1, + tol = 1e-17, seed = NULL, + verbose = getOption("verbose"), max.fail = 0, + transform = FALSE, \dots) \S4method{bsmc}{pomp}(object, params, Np, est, smooth = 0.1, ntries = 1, tol = 1e-17, lower = -Inf, upper = Inf, seed = NULL, verbose = getOption("verbose"), max.fail = 0, transform = FALSE, \dots) -\S4method{bsmc2}{pomp}(object, params, Np, est, smooth = 0.1, - tol = 1e-17, seed = NULL, - verbose = getOption("verbose"), max.fail = 0, - transform = FALSE, \dots) } \arguments{ \item{object}{ @@ -120,8 +121,8 @@ \author{ Michael Lavine (lavine at math dot umass dot edu), Matthew Ferrari (mferrari at psu dot edu), - Aaron A. King - Edward L. Ionides + Aaron A. King (kingaa at umich dot edu) + Edward L. Ionides (ionides at umich dot edu) } \references{ Liu, J. and M. West. @@ -130,8 +131,7 @@ Sequential Monte Carlo Methods in Practice, pages 197-224. Springer, New York, 2001. } -\examples{ -## See the "Introducton to pomp" document for examples. +\seealso{ + \code{\link{pomp}}, \code{\link{pfilter}} } -\seealso{\link{pomp-class}} \keyword{ts} Modified: pkg/pomp/man/bsplines.Rd =================================================================== --- pkg/pomp/man/bsplines.Rd 2015-02-27 02:58:03 UTC (rev 1109) +++ pkg/pomp/man/bsplines.Rd 2015-02-27 02:58:10 UTC (rev 1110) @@ -35,9 +35,10 @@ The basis functions returned are periodic with period \code{period}. } } -\details{ - Direct access to the underlying C routines is available. - See the header file \dQuote{pomp.h} for details. +\section{C API}{ + Access to the underlying C routines is available: + See the header file \file{pomp.h} for the details. + Do \preformatted{file.show(system.file("include/pomp.h",package="pomp"))} to view this file. } \author{Aaron A. King \email{kingaa at umich dot edu}} \examples{ Modified: pkg/pomp/man/dacca.Rd =================================================================== --- pkg/pomp/man/dacca.Rd 2015-02-27 02:58:03 UTC (rev 1109) +++ pkg/pomp/man/dacca.Rd 2015-02-27 02:58:10 UTC (rev 1110) @@ -36,4 +36,5 @@ \code{\link{euler.sir}}, \code{\link{pomp}} } +\keyword{models} \keyword{datasets} Modified: pkg/pomp/man/eulermultinom.Rd =================================================================== --- pkg/pomp/man/eulermultinom.Rd 2015-02-27 02:58:03 UTC (rev 1109) +++ pkg/pomp/man/eulermultinom.Rd 2015-02-27 02:58:10 UTC (rev 1110) @@ -59,8 +59,8 @@ } He et al. use such overdispersed death processes in modeling measles. - For all of the functions described here, direct access to the underlying C routines is available: - see the header file \dQuote{pomp.h}, included with the package. + For all of the functions described here, access to the underlying C routines is available: + see below. } \value{ \item{reulermultinom}{ Modified: pkg/pomp/man/example.Rd =================================================================== --- pkg/pomp/man/example.Rd 2015-02-27 02:58:03 UTC (rev 1109) +++ pkg/pomp/man/example.Rd 2015-02-27 02:58:10 UTC (rev 1110) @@ -1,6 +1,8 @@ -\name{pompExample} +\name{Example pomp models} \alias{pompExample} -\title{Pre-built examples of pomp objects.} +\title{Examples of the construction of POMP models.} +\alias{Example pomp models} +\alias{pompExample} \description{ \code{pompExample} loads pre-built example \code{pomp} objects. } @@ -43,3 +45,5 @@ \code{\link{euler.sir}}, \code{\link{gillespie.sir}}, \code{\link{bbs}}, \code{\link{verhulst}} } +\keyword{models} +\keyword{datasets} Modified: pkg/pomp/man/gompertz.Rd =================================================================== --- pkg/pomp/man/gompertz.Rd 2015-02-27 02:58:03 UTC (rev 1109) +++ pkg/pomp/man/gompertz.Rd 2015-02-27 02:58:10 UTC (rev 1110) @@ -20,4 +20,5 @@ \seealso{ \code{pomp}, \code{ricker}, and the tutorials at \url{http://pomp.r-forge.r-project.org}. } +\keyword{models} \keyword{datasets} Modified: pkg/pomp/man/mif.Rd =================================================================== --- pkg/pomp/man/mif.Rd 2015-02-27 02:58:03 UTC (rev 1109) +++ pkg/pomp/man/mif.Rd 2015-02-27 02:58:10 UTC (rev 1110) @@ -217,4 +217,5 @@ \seealso{ \code{\link{pomp}}, \code{\link{pfilter}} } +\keyword{optimize} \keyword{ts} Modified: pkg/pomp/man/nlf.Rd =================================================================== --- pkg/pomp/man/nlf.Rd 2015-02-27 02:58:03 UTC (rev 1109) +++ pkg/pomp/man/nlf.Rd 2015-02-27 02:58:10 UTC (rev 1110) @@ -1,4 +1,6 @@ -\name{nlf} +\name{Nonlinear forecasting} +\title{Parameter estimation my maximum simulated quasi-likelihood (nonlinear forecasting)} +\alias{Nonlinear forecasting} \alias{nlf} \alias{nlf,pomp-method} \alias{nlf-pomp} @@ -9,9 +11,9 @@ \alias{logLik-nlfd.pomp} \alias{$,nlfd.pomp-method} \alias{$-nlfd.pomp} -\title{Fit Model to Data Using Nonlinear Forecasting (NLF)} \description{ - Calls an optimizer to maximize the nonlinear forecasting (NLF) goodness of fit, by simulating data from a model, fitting a nonlinear autoregressive model to the simulated time series (which may be multivariate) and using the fitted model to predict some or all variables in the data time series. + \code{nlf} calls an optimizer to maximize the nonlinear forecasting (NLF) goodness of fit. + The latter is computed by simulating data from a model, fitting a nonlinear autoregressive model to the simulated time series, and quantifying the ability of the resulting fitted model to predict the data time series. NLF is an \sQuote{indirect inference} method using a quasi-likelihood as the objective function. } \usage{ @@ -138,4 +140,5 @@ Bruce E. Kendall \email{kendall at bren dot ucsb dot edu}, Aaron A. King \email{kingaa at umich dot edu} } +\keyword{optimize} \keyword{ts} Modified: pkg/pomp/man/ou2.Rd =================================================================== --- pkg/pomp/man/ou2.Rd 2015-02-27 02:58:03 UTC (rev 1109) +++ pkg/pomp/man/ou2.Rd 2015-02-27 02:58:10 UTC (rev 1110) @@ -23,4 +23,5 @@ logLik(pf) } \seealso{\code{\link{pomp}}} -\keyword{ts} +\keyword{models} +\keyword{datasets} Modified: pkg/pomp/man/particles-mif.Rd =================================================================== --- pkg/pomp/man/particles-mif.Rd 2015-02-27 02:58:03 UTC (rev 1109) +++ pkg/pomp/man/particles-mif.Rd 2015-02-27 02:58:10 UTC (rev 1110) @@ -34,5 +34,4 @@ } \author{Aaron A. King \email{kingaa at umich dot edu}} \seealso{\code{\link{mif}}, \link{mif-methods}, \code{\link{pomp}}, \link{pomp-class}} -\keyword{models} \keyword{ts} Modified: pkg/pomp/man/pfilter.Rd =================================================================== --- pkg/pomp/man/pfilter.Rd 2015-02-27 02:58:03 UTC (rev 1109) +++ pkg/pomp/man/pfilter.Rd 2015-02-27 02:58:10 UTC (rev 1110) @@ -184,5 +184,4 @@ \code{\link{pomp}}, \code{\link{mif}}, \code{\link{pmcmc}}, \code{\link{bsmc2}}, and the tutorials on the \href{http://pomp.r-forge.r-project.org}{package website}. } -\keyword{models} \keyword{ts} Modified: pkg/pomp/man/plugins.Rd =================================================================== --- pkg/pomp/man/plugins.Rd 2015-02-27 02:58:03 UTC (rev 1109) +++ pkg/pomp/man/plugins.Rd 2015-02-27 02:58:10 UTC (rev 1110) @@ -1,15 +1,15 @@ -\name{plugins} +\name{Process model plugins} +\title{Plug-ins for state-process models} +\alias{process model plugins} \alias{plugins} -\alias{process model plugins} \alias{onestep.sim} \alias{euler.sim} \alias{discrete.time.sim} \alias{onestep.dens} \alias{gillespie.sim} -\title{Plug-ins for state-process models} \description{ - Plug-in facilities for implementing discrete-time Markov processes and continuous-time Markov processes using the Euler algorithm. - These can be used in the \code{rprocess} and \code{dprocess} slots of \code{pomp}. + The functions documented here can be used to specify the \code{rprocess} and \code{dprocess} slots for a \code{pomp} model. + There are options for discrete- and continuous-time Markov processes. } \usage{ onestep.sim(step.fun, PACKAGE) @@ -20,17 +20,19 @@ } \arguments{ \item{step.fun}{ - This can be either an \R function, a \code{\link{Csnippet}}, or the name of a compiled, dynamically loaded native function containing the model simulator. + This can be either an \R function, the name of a compiled, dynamically loaded native function containing the model simulator, or a \code{\link{Csnippet}}. + The latter is the preferred option. It should be written to take a single Euler step from a single point in state space. - If it is an \R function, it should have prototype \code{step.fun(x,t,params,delta.t,...)}. + For an explanation and examples on the use of \code{\link{Csnippet}} to write fast simulators, see the tutorials on the \href{http://pomp.r-forge.r-project.org}{package website}. + + If it is an \R function, it should have prototype \preformatted{step.fun(x,t,params,delta.t,...).} Here, \code{x} is a named numeric vector containing the value of the state process at time \code{t}, \code{params} is a named numeric vector containing parameters, and \code{delta.t} is the length of the Euler time-step. - For examples on the use of \code{\link{Csnippet}} to write fast simulators easily, see the tutorials on the \href{http://pomp.r-forge.r-project.org}{package website}. - - If \code{step.fun} is the name of a native function, it must be of type \dQuote{pomp_onestep_sim} as defined in the header \dQuote{pomp.h}, which is included with the \pkg{pomp} package. + If \code{step.fun} is the name of a native function, it must be of type \code{pomp_onestep_sim} as defined in the header file \file{pomp.h}, which is included with the \pkg{pomp} package. + Do \preformatted{file.show(system.file("include/pomp.h",package="pomp"))} to view this header file. For details on how to write such codes, see Details. } \item{rate.fun}{ @@ -42,7 +44,7 @@ For examples on the use of \code{\link{Csnippet}} to write fast simulators easily, see tutorials on the \href{http://pomp.r-forge.r-project.org}{package website}. - If \code{rate.fun} is a native function, it must be of type \dQuote{pomp_ssa_rate_fn} as defined in the header \dQuote{pomp.h}, which is included with the package. + If \code{rate.fun} is a native function, it must be of type \code{pomp_ssa_rate_fn} as defined in the header \file{pomp.h}, which is included with the package. For details on how to write such codes, see Details. } \item{v, d}{ @@ -60,7 +62,7 @@ Here, \code{x1} and \code{x2} are named numeric vectors containing the values of the state process at times \code{t1} and \code{t2}, \code{params} is a named numeric vector containing parameters. - If \code{dens.fun} is the name of a native function, it should be of type \dQuote{pomp_onestep_pdf} as defined in the header \dQuote{pomp.h}, which is included with the \pkg{pomp} package. + If \code{dens.fun} is the name of a native function, it should be of type \code{pomp_onestep_pdf} as defined in the header \file{pomp.h}, which is included with the \pkg{pomp} package. This function should return the log likelihood of a transition from \code{x1} at time \code{t1} to \code{x2} at time \code{t2}, assuming that no intervening transitions have occurred. For details on how to write such codes, see Details. } @@ -79,35 +81,36 @@ \code{euler.sim} is appropriate when one cannot do this but can compute the change in state via a sequence of smaller steps. This is desirable, for example, if one is simulating a continuous time process but is willing to approximate it using an Euler approach. \code{discrete.time.sim} is appropriate when the process evolves in discrete time. - In this case, by default, the intervals between observations are integers. To use \code{euler.sim} or \code{discrete.time.sim}, you must write a function \code{step.fun} that will take a single Euler step, of size at most \code{delta.t}. - \code{euler.sim} and \code{discrete.time.sim} will create simulators that take as many steps as needed to get from one time to another. + The functions \code{euler.sim} and \code{discrete.time.sim} will create simulators that take as many steps as needed to get from one time to another. See below for information on how \code{euler.sim} chooses the actual step size it uses. \code{gillespie.sim} allows exact simulation of a continuous-time, discrete-state Markov process using Gillespie's algorithm. - This is an \dQuote{event-driven} approach: correspondingly, to use \code{gillespie.sim}, you must write a function \code{rate.fun} that computes the rates of each elementary event and specify two matrices (\code{d,v}) that describe, respectively, the dependencies of each rate and the consequences of each event. + This is an \dQuote{event-driven} approach: correspondingly, to use \code{gillespie.sim}, you must write a function \code{rate.fun} that computes the rates of each elementary kind of event and specify two matrices (\code{d,v}) that describe, respectively, the dependencies of each rate and the consequences of each event. \code{onestep.dens} will generate a suitable \code{dprocess} function when one can compute the likelihood of a given state transition simply by knowing the states at two times under the assumption that the state has not changed between the times. This is typically possible, for instance, when the \code{rprocess} function is implemented using \code{onestep.sim}, \code{euler.sim}, or \code{discrete.time.sim}. [NB: currently, there are no high-level algorithms in \pkg{pomp} that use \code{dprocess}. - This function is provided for completeness only, and with an eye toward future development.] + This function is provided for completeness only, with an eye toward future development.] If \code{step.fun} is written as an \R function, it must have at least the arguments \code{x}, \code{t}, \code{params}, \code{delta.t}, and \code{\dots}. On a call to this function, \code{x} will be a named vector of state variables, \code{t} a scalar time, and \code{params} a named vector of parameters. The length of the Euler step will be \code{delta.t}. If the argument \code{covars} is included and a covariate table has been included in the \code{pomp} object, then on a call to this function, \code{covars} will be filled with the values, at time \code{t}, of the covariates. - This is accomplished via interpolation of the covariate table. + This is accomplished via interpolation of the user-supplied covariate table. Additional arguments may be given: these will be filled by the correspondingly-named elements in the \code{userdata} slot of the \code{pomp} object (see \code{\link{pomp}}). - If \code{step.fun} is written in a native language, it must be a function of type \dQuote{pomp_onestep_sim} as specified in the header \dQuote{pomp.h} included with the package (see the directory \dQuote{include} in the installed package directory). + If \code{step.fun} is written in a native language, it must be a function of type \code{pomp_onestep_sim} as specified in the header \file{pomp.h} included with the package. + Execute \preformatted{file.show(system.file("include/pomp.h",package="pomp.h"))} to view this file. + If \code{rate.fun} is written as an \R function, it must have at least the arguments \code{j}, \code{x}, \code{t}, \code{params}, and \code{\dots}. - Here, \code{j} is the an integer that indicates which specific elementary event we desire the rate of. + Here, \code{j} is the an integer that indicates for which of the elementary events the current rate is desired. \code{x} is a named vector containing the value of the state process at time \code{t}, and \code{params} is a named vector containing parameters. If the argument \code{covars} is included and a covariate table has been included in the \code{pomp} object, then on a call to this function, \code{covars} will be filled with the values, at time \code{t}, of the covariates. This is accomplished via interpolation of the covariate table. - If \code{rate.fun} is a native function, it must be of type \dQuote{pomp_ssa_rate_fn} as defined in the header \dQuote{pomp.h}, which is included with the package. + If \code{rate.fun} is a native function, it must be of type \code{pomp_ssa_rate_fn} as defined in the header \file{pomp.h}; see above for instructions on how to view this file. In writing \code{dens.fun}, you must assume that no state transitions have occurred between \code{t1} and \code{t2}. If \code{dens.fun} is written as an \R function, it must have at least the arguments \code{x1}, \code{x2}, \code{t1}, \code{t2}, \code{params}, and \code{\dots}. @@ -117,7 +120,7 @@ If the argument \code{covars} is included and a covariate table has been included in the \code{pomp} object, then on a call to this function, \code{covars} will be filled with the values, at time \code{t1}, of the covariates. This is accomplished via interpolation of the covariate table. As above, any additional arguments will be filled by the correspondingly-named elements in the \code{userdata} slot of the \code{pomp} object (see \code{\link{pomp}}). - If \code{dens.fun} is written in a native language, it must be a function of type \dQuote{pomp_onestep_pdf} as defined in the header \dQuote{pomp.h} included with the package (see the directory \dQuote{include} in the installed package directory). + If \code{dens.fun} is written in a native language, it must be a function of type \code{pomp_onestep_pdf} as defined in the header \file{pomp.h} included with the package; see above for instructions on how to view this file. } \value{ \code{onestep.sim}, \code{euler.sim}, \code{discrete.time.sim}, and \code{gillespie.sim} each return functions suitable for use as the argument \code{rprocess} argument in \code{\link{pomp}}. @@ -125,5 +128,7 @@ \code{onestep.dens} returns a function suitable for use as the argument \code{dprocess} in \code{\link{pomp}}. } \author{Aaron A. King \email{kingaa at umich dot edu}} -\seealso{\code{\link{eulermultinom}}, \code{\link{pomp}}} +\seealso{ + \code{\link{pomp}} and the tutorials on the \href{http://pomp.r-forge.r-project.org}{package website}. +} \keyword{models} Modified: pkg/pomp/man/pomp-fun.Rd =================================================================== --- pkg/pomp/man/pomp-fun.Rd 2015-02-27 02:58:03 UTC (rev 1109) +++ pkg/pomp/man/pomp-fun.Rd 2015-02-27 02:58:10 UTC (rev 1110) @@ -12,7 +12,6 @@ \alias{pomp.fun,missing-method} \alias{pomp.fun,pomp.fun-method} \alias{pomp.fun,Csnippet-method} -\keyword{internal} \title{Definition and methods of the "pomp.fun" class} \description{Definition and methods of the \code{pomp.fun} class} \usage{ @@ -40,10 +39,12 @@ \item{object, x}{The \code{pomp.fun} object.} } \details{ - The sQuote{pomp.fun} class helps to settle common issues associated with user-defined functions which can be defined either via R code or by a native, compiled routine. + The \code{pomp.fun} class helps to settle common issues associated with user-defined functions which can be defined either via R code or by a native, compiled routine. It is not exported to userland. } \author{Aaron A. King \email{kingaa at umich dot edu}} \seealso{ \code{\link{pomp}} } +\keyword{programming} +\keyword{internal} Modified: pkg/pomp/man/pomp-methods.Rd =================================================================== --- pkg/pomp/man/pomp-methods.Rd 2015-02-27 02:58:03 UTC (rev 1109) +++ pkg/pomp/man/pomp-methods.Rd 2015-02-27 02:58:10 UTC (rev 1110) @@ -200,5 +200,5 @@ \link{pomp low-level interface}, \link[=simulate-pomp]{simulate} } -\keyword{models} +\keyword{programming} \keyword{ts} Modified: pkg/pomp/man/pomp-package.Rd =================================================================== --- pkg/pomp/man/pomp-package.Rd 2015-02-27 02:58:03 UTC (rev 1109) +++ pkg/pomp/man/pomp-package.Rd 2015-02-27 02:58:10 UTC (rev 1110) @@ -1,8 +1,9 @@ \name{pomp-package} +\title{Inference for partially observed Markov processes} \docType{package} +\alias{The pomp package} \alias{pomp-package} \alias{pomp package} -\title{Inference for partially observed Markov processes} \description{ The \pkg{pomp} package provides facilities for inference on time series data using partially-observed Markov process (\acronym{POMP}) models. These models are also known as state-space models or nonlinear stochastic dynamical systems. @@ -70,4 +71,5 @@ \code{\link{pmcmc}} } \keyword{models} +\keyword{datasets} \keyword{ts} Modified: pkg/pomp/man/pomp.Rd =================================================================== --- pkg/pomp/man/pomp.Rd 2015-02-27 02:58:03 UTC (rev 1109) +++ pkg/pomp/man/pomp.Rd 2015-02-27 02:58:10 UTC (rev 1110) @@ -1,4 +1,6 @@ -\name{pomp} +\name{pomp constructor} +\title{Constructor of the basic POMP object} +\alias{pomp constructor} \alias{pomp} \alias{pomp,data.frame-method} \alias{data.frame-pomp} @@ -9,7 +11,6 @@ \alias{pomp,pomp-method} \alias{pomp-pomp} \alias{pomp-class} -\title{Partially-observed Markov process object constructor.} \description{ This function constructs a \code{pomp} object, encoding a partially-observed Markov process model together with a uni- or multivariate time series. @@ -128,7 +129,7 @@ optional; function drawing a sample from a prior distribution on parameters. This can be specified in one of three ways: (1) as an \R function of prototype \preformatted{rprior(params,\dots)} that makes a draw from the prior distribution given \code{params}, - (2) as the name of a native (compiled) routine with prototype \dQuote{pomp_rprior} as defined in the header file \file{pomp.h}, or + (2) as the name of a native (compiled) routine with prototype \code{pomp_rprior} as defined in the header file \file{pomp.h}, or (To view the header file, execute \preformatted{file.show(system.file("include/pomp.h",package="pomp"))} in an \R session.) (3) as a snippet of C code (via \code{\link{Csnippet}}). As above, the latter is typically preferable. @@ -137,7 +138,7 @@ optional; function evaluating the prior distribution. This can be specified in one of three ways: (1) as an \R function of prototype \preformatted{dprior(params,log=FALSE,\dots)} that evaluates the prior probability density, - (2) as the name of a native (compiled) routine with prototype \dQuote{pomp_dprior} as defined in the header file \file{pomp.h}, or + (2) as the name of a native (compiled) routine with prototype \code{pomp_dprior} as defined in the header file \file{pomp.h}, or [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/pomp -r 1110 From noreply at r-forge.r-project.org Fri Feb 27 03:58:17 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 27 Feb 2015 03:58:17 +0100 (CET) Subject: [Pomp-commits] r1111 - in pkg/pomp: . R inst tests Message-ID: <20150227025817.B1A1C1876B8@r-forge.r-project.org> Author: kingaa Date: 2015-02-27 03:58:17 +0100 (Fri, 27 Feb 2015) New Revision: 1111 Modified: pkg/pomp/DESCRIPTION pkg/pomp/R/mif.R pkg/pomp/inst/NEWS pkg/pomp/inst/NEWS.Rd pkg/pomp/tests/bbs-trajmatch.Rout.save pkg/pomp/tests/bbs.Rout.save pkg/pomp/tests/blowflies.Rout.save pkg/pomp/tests/dacca.Rout.save pkg/pomp/tests/dimchecks.Rout.save pkg/pomp/tests/fhn.Rout.save pkg/pomp/tests/filtfail.Rout.save pkg/pomp/tests/gillespie.Rout.save pkg/pomp/tests/gompertz.Rout.save pkg/pomp/tests/logistic.Rout.save pkg/pomp/tests/ou2-abc.Rout.save pkg/pomp/tests/ou2-bsmc.Rout.save pkg/pomp/tests/ou2-bsmc2.Rout.save pkg/pomp/tests/ou2-forecast.Rout.save pkg/pomp/tests/ou2-kalman.Rout.save pkg/pomp/tests/ou2-mif-fp.Rout.save pkg/pomp/tests/ou2-mif.R pkg/pomp/tests/ou2-mif.Rout.save pkg/pomp/tests/ou2-mif2.R pkg/pomp/tests/ou2-mif2.Rout.save pkg/pomp/tests/ou2-nlf.Rout.save pkg/pomp/tests/ou2-pmcmc.Rout.save pkg/pomp/tests/ou2-probe.Rout.save pkg/pomp/tests/ou2-procmeas.Rout.save pkg/pomp/tests/ou2-simulate.Rout.save pkg/pomp/tests/ou2-spect.Rout.save pkg/pomp/tests/ou2-trajmatch.Rout.save pkg/pomp/tests/partrans.Rout.save pkg/pomp/tests/pfilter.Rout.save pkg/pomp/tests/pomppomp.Rout.save pkg/pomp/tests/prior.Rout.save pkg/pomp/tests/ricker-bsmc.Rout.save pkg/pomp/tests/ricker-probe.Rout.save pkg/pomp/tests/ricker-spect.Rout.save pkg/pomp/tests/ricker.Rout.save pkg/pomp/tests/rw2.Rout.save pkg/pomp/tests/sir.Rout.save pkg/pomp/tests/skeleton.Rout.save pkg/pomp/tests/steps.Rout.save pkg/pomp/tests/synlik.Rout.save pkg/pomp/tests/verhulst.Rout.save Log: - deprecate, but do not ignore, the 'pars' argument to 'mif'. It will be removed later. Modified: pkg/pomp/DESCRIPTION =================================================================== --- pkg/pomp/DESCRIPTION 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/DESCRIPTION 2015-02-27 02:58:17 UTC (rev 1111) @@ -1,7 +1,7 @@ Package: pomp Type: Package Title: Statistical Inference for Partially Observed Markov Processes -Version: 0.62-1 +Version: 0.61-3 Date: 2015-02-26 Authors at R: c(person(given=c("Aaron","A."),family="King", role=c("aut","cre"),email="kingaa at umich.edu"), Modified: pkg/pomp/R/mif.R =================================================================== --- pkg/pomp/R/mif.R 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/R/mif.R 2015-02-27 02:58:17 UTC (rev 1111) @@ -114,27 +114,57 @@ if (is.null(start.names)) stop("mif error: ",sQuote("start")," must be a named vector",call.=FALSE) - if (!is.null(pars)) { - warning("mif warning: the ",sQuote("pars")," argument to ",sQuote("mif")," is unnecessary and deprecated and will be ignored.\n", - "This behavior differs from that previous to ",sQuote("pomp")," version 0.62",call.=FALSE) - } - rw.names <- names(rw.sd) if (is.null(rw.names) || any(rw.sd<0)) stop("mif error: ",sQuote("rw.sd")," must be a named non-negative numerical vector",call.=FALSE) if (!all(rw.names%in%start.names)) stop("mif error: all the names of ",sQuote("rw.sd")," must be names of ",sQuote("start"),call.=FALSE) - rw.names <- rw.names[rw.sd>0] + rw.names <- names(rw.sd[rw.sd>0]) if (length(rw.names) == 0) stop("mif error: ",sQuote("rw.sd")," must have one positive entry for each parameter to be estimated",call.=FALSE) - pars <- rw.names[!(rw.names%in%ivps)] - if (!is.character(ivps) || !all(ivps%in%start.names)) - stop("mif error: ",sQuote("ivps")," must name model parameters",call.=FALSE) - -## rw.sd <- rw.sd[c(pars,ivps)] -## rw.names <- names(rw.sd) + if (is.null(pars)) + pars <- rw.names[!(rw.names%in%ivps)] + else + warning("mif warning: argument ",sQuote("pars")," is redundant and deprecated. It will be removed in a future release.",call.=FALSE) + if ( + !is.character(pars) || + !is.character(ivps) || + !all(pars%in%start.names) || + !all(ivps%in%start.names) || + any(pars%in%ivps) || + any(ivps%in%pars) || + !all(pars%in%rw.names) || + !all(ivps%in%rw.names) + ) + stop( + "mif error: ", + sQuote("pars")," and ",sQuote("ivps"), + " must be mutually disjoint subsets of ", + sQuote("names(start)"), + " and must have a positive random-walk SDs specified in ", + sQuote("rw.sd"), + call.=FALSE + ) + + if (!all(rw.names%in%c(pars,ivps))) { + extra.rws <- rw.names[!(rw.names%in%c(pars,ivps))] + warning( + ngettext(length(extra.rws),"mif warning: the variable ", + "mif warning: the variables "), + paste(sQuote(extra.rws),collapse=", "), + ngettext(length(extra.rws)," has positive random-walk SD specified, but is included in neither ", + " have positive random-walk SDs specified, but are included in neither "), + sQuote("pars")," nor ",sQuote("ivps"), + ngettext(length(extra.rws),". This random walk SD will be ignored.", + ". These random walk SDs will be ignored."), + call.=FALSE + ) + } + rw.sd <- rw.sd[c(pars,ivps)] + rw.names <- names(rw.sd) + ntimes <- length(time(object)) if (is.null(Np)) stop("mif error: ",sQuote("Np")," must be specified",call.=FALSE) if (is.function(Np)) { Modified: pkg/pomp/inst/NEWS =================================================================== --- pkg/pomp/inst/NEWS 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/inst/NEWS 2015-02-27 02:58:17 UTC (rev 1111) @@ -1,9 +1,9 @@ _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 _0._6_2-_1: +_C_h_a_n_g_e_s _i_n '_p_o_m_p' _v_e_r_s_i_o_n _0._6_1-_3: - ? ?mif?'s ?pars? argument, which is redundant, is now ignored - with a warning. In a future release, this argument will be + ? ?mif?'s ?pars? argument, which is redundant, is now + deprecated. In a future release, this argument will be removed. _C_h_a_n_g_e_s _i_n '_p_o_m_p' _v_e_r_s_i_o_n _0._6_1-_1: Modified: pkg/pomp/inst/NEWS.Rd =================================================================== --- pkg/pomp/inst/NEWS.Rd 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/inst/NEWS.Rd 2015-02-27 02:58:17 UTC (rev 1111) @@ -1,8 +1,8 @@ \name{NEWS} \title{News for package `pomp'} -\section{Changes in \pkg{pomp} version 0.62-1}{ +\section{Changes in \pkg{pomp} version 0.61-3}{ \itemize{ - \item \code{mif}'s \code{pars} argument, which is redundant, is now ignored with a warning. + \item \code{mif}'s \code{pars} argument, which is redundant, is now deprecated. In a future release, this argument will be removed. } } Modified: pkg/pomp/tests/bbs-trajmatch.Rout.save =================================================================== --- pkg/pomp/tests/bbs-trajmatch.Rout.save 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/tests/bbs-trajmatch.Rout.save 2015-02-27 02:58:17 UTC (rev 1111) @@ -80,4 +80,4 @@ > > proc.time() user system elapsed - 2.448 0.052 2.525 + 2.480 0.052 2.555 Modified: pkg/pomp/tests/bbs.Rout.save =================================================================== --- pkg/pomp/tests/bbs.Rout.save 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/tests/bbs.Rout.save 2015-02-27 02:58:17 UTC (rev 1111) @@ -73,4 +73,4 @@ > > proc.time() user system elapsed - 6.916 0.056 7.013 + 7.153 0.049 7.193 Modified: pkg/pomp/tests/blowflies.Rout.save =================================================================== --- pkg/pomp/tests/blowflies.Rout.save 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/tests/blowflies.Rout.save 2015-02-27 02:58:17 UTC (rev 1111) @@ -72,4 +72,4 @@ > > proc.time() user system elapsed - 1.320 0.060 1.411 + 1.304 0.044 1.380 Modified: pkg/pomp/tests/dacca.Rout.save =================================================================== --- pkg/pomp/tests/dacca.Rout.save 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/tests/dacca.Rout.save 2015-02-27 02:58:17 UTC (rev 1111) @@ -107,4 +107,4 @@ > > proc.time() user system elapsed - 11.408 0.084 11.550 + 10.852 0.064 10.968 Modified: pkg/pomp/tests/dimchecks.Rout.save =================================================================== --- pkg/pomp/tests/dimchecks.Rout.save 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/tests/dimchecks.Rout.save 2015-02-27 02:58:17 UTC (rev 1111) @@ -179,4 +179,4 @@ > > proc.time() user system elapsed - 0.592 0.072 0.689 + 0.560 0.092 0.677 Modified: pkg/pomp/tests/fhn.Rout.save =================================================================== --- pkg/pomp/tests/fhn.Rout.save 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/tests/fhn.Rout.save 2015-02-27 02:58:17 UTC (rev 1111) @@ -93,4 +93,4 @@ > > proc.time() user system elapsed - 1.064 0.032 1.243 + 1.084 0.064 1.285 Modified: pkg/pomp/tests/filtfail.Rout.save =================================================================== --- pkg/pomp/tests/filtfail.Rout.save 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/tests/filtfail.Rout.save 2015-02-27 02:58:17 UTC (rev 1111) @@ -116,4 +116,4 @@ > > proc.time() user system elapsed - 0.624 0.048 0.693 + 0.576 0.068 0.660 Modified: pkg/pomp/tests/gillespie.Rout.save =================================================================== --- pkg/pomp/tests/gillespie.Rout.save 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/tests/gillespie.Rout.save 2015-02-27 02:58:17 UTC (rev 1111) @@ -131,4 +131,4 @@ > > proc.time() user system elapsed - 2.488 0.056 2.574 + 2.564 0.048 2.635 Modified: pkg/pomp/tests/gompertz.Rout.save =================================================================== --- pkg/pomp/tests/gompertz.Rout.save 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/tests/gompertz.Rout.save 2015-02-27 02:58:17 UTC (rev 1111) @@ -133,4 +133,4 @@ > > proc.time() user system elapsed - 1.616 0.052 1.820 + 1.576 0.052 1.652 Modified: pkg/pomp/tests/logistic.Rout.save =================================================================== --- pkg/pomp/tests/logistic.Rout.save 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/tests/logistic.Rout.save 2015-02-27 02:58:17 UTC (rev 1111) @@ -124,4 +124,4 @@ > > proc.time() user system elapsed - 0.944 0.072 1.143 + 0.976 0.052 1.175 Modified: pkg/pomp/tests/ou2-abc.Rout.save =================================================================== --- pkg/pomp/tests/ou2-abc.Rout.save 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/tests/ou2-abc.Rout.save 2015-02-27 02:58:17 UTC (rev 1111) @@ -139,4 +139,4 @@ > > proc.time() user system elapsed - 11.092 0.068 11.369 + 11.422 0.073 11.497 Modified: pkg/pomp/tests/ou2-bsmc.Rout.save =================================================================== --- pkg/pomp/tests/ou2-bsmc.Rout.save 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/tests/ou2-bsmc.Rout.save 2015-02-27 02:58:17 UTC (rev 1111) @@ -59,7 +59,7 @@ > post <- smc$post > > print(etime <- toc-tic) -Time difference of 2.748923 secs +Time difference of 2.789886 secs > > print( + cbind( @@ -101,4 +101,4 @@ > > proc.time() user system elapsed - 4.712 0.032 4.777 + 4.688 0.064 4.785 Modified: pkg/pomp/tests/ou2-bsmc2.Rout.save =================================================================== --- pkg/pomp/tests/ou2-bsmc2.Rout.save 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/tests/ou2-bsmc2.Rout.save 2015-02-27 02:58:17 UTC (rev 1111) @@ -56,7 +56,7 @@ > post <- smc$post > > print(etime <- toc-tic) -Time difference of 1.971769 secs +Time difference of 2.022153 secs > > print( + cbind( @@ -98,4 +98,4 @@ > > proc.time() user system elapsed - 3.540 0.060 3.626 + 3.588 0.084 3.697 Modified: pkg/pomp/tests/ou2-forecast.Rout.save =================================================================== --- pkg/pomp/tests/ou2-forecast.Rout.save 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/tests/ou2-forecast.Rout.save 2015-02-27 02:58:17 UTC (rev 1111) @@ -61,4 +61,4 @@ > > proc.time() user system elapsed - 1.596 0.072 1.793 + 1.420 0.036 1.559 Modified: pkg/pomp/tests/ou2-kalman.Rout.save =================================================================== --- pkg/pomp/tests/ou2-kalman.Rout.save 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/tests/ou2-kalman.Rout.save 2015-02-27 02:58:17 UTC (rev 1111) @@ -164,7 +164,7 @@ 117 function evaluations used > toc <- Sys.time() > print(toc-tic) -Time difference of 3.520454 secs +Time difference of 3.41739 secs > tic <- Sys.time() > print(loglik.mle <- -kalm.fit1$value,digits=4) [1] -477.2 @@ -188,4 +188,4 @@ > > proc.time() user system elapsed - 4.172 0.068 4.270 + 3.933 0.035 3.954 Modified: pkg/pomp/tests/ou2-mif-fp.Rout.save =================================================================== --- pkg/pomp/tests/ou2-mif-fp.Rout.save 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/tests/ou2-mif-fp.Rout.save 2015-02-27 02:58:17 UTC (rev 1111) @@ -47,8 +47,7 @@ + method="fp" + ) Warning message: -mif warning: the 'pars' argument to 'mif' is unnecessary and deprecated and will be ignored. -This behavior differs from that previous to 'pomp' version 0.62 +mif warning: argument 'pars' is redundant and deprecated. It will be removed in a future release. > > mif2 <- mif(ou2,Nmif=100,start=guess2, + pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), @@ -65,8 +64,7 @@ + method="fp" + ) Warning message: -mif warning: the 'pars' argument to 'mif' is unnecessary and deprecated and will be ignored. -This behavior differs from that previous to 'pomp' version 0.62 +mif warning: argument 'pars' is redundant and deprecated. It will be removed in a future release. > > plot(c(mif1,mif2)) > @@ -76,4 +74,4 @@ > > proc.time() user system elapsed - 20.933 0.064 21.259 + 25.136 0.029 25.180 Modified: pkg/pomp/tests/ou2-mif.R =================================================================== --- pkg/pomp/tests/ou2-mif.R 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/tests/ou2-mif.R 2015-02-27 02:58:17 UTC (rev 1111) @@ -19,7 +19,7 @@ guess2[c('x1.0','x2.0','alpha.2','alpha.3')] <- 1.5*guess1[c('x1.0','x2.0','alpha.2','alpha.3')] mif1 <- mif(ou2,Nmif=30,start=guess1, - ivps=c('x1.0','x2.0'), + pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), rw.sd=c( x1.0=5,x2.0=5, alpha.2=0.1,alpha.3=0.1 @@ -33,7 +33,7 @@ ) mif2 <- mif(ou2,Nmif=30,start=guess2, - ivps=c('x1.0','x2.0'), + pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), transform=TRUE, rw.sd=c( x1.0=5,x2.0=5, @@ -60,8 +60,9 @@ mif( ou2, Nmif=1, + pars=c("alpha.1","alpha.4","x1.0"), ivps=c("x1.0","x2.0"), - rw.sd=c(x1.0=5,x2.0=5,alpha.1=0.1,alpha.4=0.2,alpha.3=-1), + rw.sd=c(x1.0=5,x2.0=5,alpha.1=0.1,alpha.4=0.2,alpha.3=0), Np=100,cooling.type="geometric",cooling.fraction=0.95^50, ic.lag=10,var.factor=1 ) @@ -70,6 +71,62 @@ try( mif( ou2, + Nmif=1, + pars=c("alpha.1","alpha.4"), + ivps=c("x1.0","x2.0"), + rw.sd=c(x1.0=5,x2.0=5,alpha.1=0,alpha.4=0.2,alpha.3=0), + Np=100, + cooling.type="geometric",cooling.fraction=0.95^50, + ic.lag=10,var.factor=1 + ) + ) + +try( + mif( + ou2, + Nmif=1, + ivps=c("x1.0","x2.0"), + rw.sd=c(alpha.1=0.1,alpha.4=0.2,alpha.3=0), + Np=100,cooling.type="geometric",cooling.fraction=0.95^50, + cooling.factor=0.95,ic.lag=10,var.factor=1 + ) + ) + +try( + mif( + ou2, + Nmif=1, + ivps=c("x1.0","x2.0"), + rw.sd=c(x1.0=5,x2.0=5,alpha.1=0.1,alpha.4=0.2,alpha.3=0), + Np=100,ic.lag=10,var.factor=1 + ) + ) + +try( + mif( + ou2, + Nmif=1, + ivps=c("x1.0","x2.0"), + rw.sd=c(x1.0=5,x2.0=5,alpha.1=0,alpha.4=0.2,alpha.3=0), + Np=-10,cooling.type="geometric",cooling.fraction=0.95^50, + ic.lag=10,var.factor=1 + ) + ) + +try( + mif( + ou2, + Nmif=-3, + ivps=c("x1.0","x2.0"), + rw.sd=c(x1.0=5,x2.0=5,alpha.1=0,alpha.4=0.2,alpha.3=0), + Np=11.6,cooling.type="geometric",cooling.fraction=0.95^50, + ic.lag=10,var.factor=1 + ) + ) + +try( + mif( + ou2, Nmif=2, start=c(alpha.1=0.9,alpha.2=0,alpha.3=0,alpha.4=-Inf,sigma.1=1,sigma.2=0,sigma.3=2,tau=1,x1.0=50,x2.0=-50), ivps=c("x1.0","x2.0"), @@ -94,6 +151,7 @@ fit <- mif( ou2, Nmif=0, + pars=c("alpha.2","alpha.3"), ivps=c("x1.0","x2.0"), rw.sd=c(x1.0=5,x2.0=5,alpha.2=0.1,alpha.3=0.2,alpha.3=0), Np=100,cooling.type="geometric",cooling.fraction=0.95^50, @@ -113,7 +171,7 @@ ff <- pfilter(fit,pred.mean=T,filter.mean=T,pred.var=T,max.fail=100,verbose=T) ff <- pfilter(ff) fit <- mif(fit,rw.sd=c(x1.0=5,x2.0=5,alpha.2=0.1,alpha.3=0.1)) -fit <- continue(fit,Nmif=2,ivps=c("x1.0"),rw.sd=c(x1.0=5,alpha.2=0.1)) +fit <- continue(fit,Nmif=2,ivps=c("x1.0"),pars=c("alpha.2")) s <- coef(fit) s[2] <- 0.01 fit <- mif(fit,Nmif=3,start=s) Modified: pkg/pomp/tests/ou2-mif.Rout.save =================================================================== --- pkg/pomp/tests/ou2-mif.Rout.save 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/tests/ou2-mif.Rout.save 2015-02-27 02:58:17 UTC (rev 1111) @@ -52,7 +52,7 @@ > guess2[c('x1.0','x2.0','alpha.2','alpha.3')] <- 1.5*guess1[c('x1.0','x2.0','alpha.2','alpha.3')] > > mif1 <- mif(ou2,Nmif=30,start=guess1, -+ ivps=c('x1.0','x2.0'), ++ pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), + rw.sd=c( + x1.0=5,x2.0=5, + alpha.2=0.1,alpha.3=0.1 @@ -64,12 +64,13 @@ + cooling.factor=0.95, + max.fail=100 + ) -Warning message: -'cooling.factor' is deprecated. +Warning messages: +1: mif warning: argument 'pars' is redundant and deprecated. It will be removed in a future release. +2: 'cooling.factor' is deprecated. See '?mif' for instructions on specifying the cooling schedule. > > mif2 <- mif(ou2,Nmif=30,start=guess2, -+ ivps=c('x1.0','x2.0'), ++ pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), + transform=TRUE, + rw.sd=c( + x1.0=5,x2.0=5, @@ -82,6 +83,8 @@ + cooling.fraction=0.95^50, + max.fail=100 + ) +Warning message: +mif warning: argument 'pars' is redundant and deprecated. It will be removed in a future release. > > pdf(file="ou2-mif.pdf") > plot(mif1) @@ -100,17 +103,84 @@ + mif( + ou2, + Nmif=1, ++ pars=c("alpha.1","alpha.4","x1.0"), + ivps=c("x1.0","x2.0"), -+ rw.sd=c(x1.0=5,x2.0=5,alpha.1=0.1,alpha.4=0.2,alpha.3=-1), ++ rw.sd=c(x1.0=5,x2.0=5,alpha.1=0.1,alpha.4=0.2,alpha.3=0), + Np=100,cooling.type="geometric",cooling.fraction=0.95^50, + ic.lag=10,var.factor=1 + ) + ) -Error : mif error: 'rw.sd' must be a named non-negative numerical vector +Error : mif error: 'pars' and 'ivps' must be mutually disjoint subsets of 'names(start)' and must have a positive random-walk SDs specified in 'rw.sd' +In addition: Warning message: +mif warning: argument 'pars' is redundant and deprecated. It will be removed in a future release. > > try( + mif( + ou2, ++ Nmif=1, ++ pars=c("alpha.1","alpha.4"), ++ ivps=c("x1.0","x2.0"), ++ rw.sd=c(x1.0=5,x2.0=5,alpha.1=0,alpha.4=0.2,alpha.3=0), ++ Np=100, ++ cooling.type="geometric",cooling.fraction=0.95^50, ++ ic.lag=10,var.factor=1 ++ ) ++ ) +Error : mif error: 'pars' and 'ivps' must be mutually disjoint subsets of 'names(start)' and must have a positive random-walk SDs specified in 'rw.sd' +In addition: Warning message: +mif warning: argument 'pars' is redundant and deprecated. It will be removed in a future release. +> +> try( ++ mif( ++ ou2, ++ Nmif=1, ++ ivps=c("x1.0","x2.0"), ++ rw.sd=c(alpha.1=0.1,alpha.4=0.2,alpha.3=0), ++ Np=100,cooling.type="geometric",cooling.fraction=0.95^50, ++ cooling.factor=0.95,ic.lag=10,var.factor=1 ++ ) ++ ) +Error : mif error: 'pars' and 'ivps' must be mutually disjoint subsets of 'names(start)' and must have a positive random-walk SDs specified in 'rw.sd' +> +> try( ++ mif( ++ ou2, ++ Nmif=1, ++ ivps=c("x1.0","x2.0"), ++ rw.sd=c(x1.0=5,x2.0=5,alpha.1=0.1,alpha.4=0.2,alpha.3=0), ++ Np=100,ic.lag=10,var.factor=1 ++ ) ++ ) +Error : mif error: 'cooling.fraction' must be specified +> +> try( ++ mif( ++ ou2, ++ Nmif=1, ++ ivps=c("x1.0","x2.0"), ++ rw.sd=c(x1.0=5,x2.0=5,alpha.1=0,alpha.4=0.2,alpha.3=0), ++ Np=-10,cooling.type="geometric",cooling.fraction=0.95^50, ++ ic.lag=10,var.factor=1 ++ ) ++ ) +Error in mif.internal(object = object, Nmif = Nmif, start = start, ivps = ivps, : + number of particles, 'Np', must always be positive +> +> try( ++ mif( ++ ou2, ++ Nmif=-3, ++ ivps=c("x1.0","x2.0"), ++ rw.sd=c(x1.0=5,x2.0=5,alpha.1=0,alpha.4=0.2,alpha.3=0), ++ Np=11.6,cooling.type="geometric",cooling.fraction=0.95^50, ++ ic.lag=10,var.factor=1 ++ ) ++ ) +Error : mif error: 'Nmif' must be a positive integer +> +> try( ++ mif( ++ ou2, + Nmif=2, + start=c(alpha.1=0.9,alpha.2=0,alpha.3=0,alpha.4=-Inf,sigma.1=1,sigma.2=0,sigma.3=2,tau=1,x1.0=50,x2.0=-50), + ivps=c("x1.0","x2.0"), @@ -139,11 +209,14 @@ > fit <- mif( + ou2, + Nmif=0, ++ pars=c("alpha.2","alpha.3"), + ivps=c("x1.0","x2.0"), + rw.sd=c(x1.0=5,x2.0=5,alpha.2=0.1,alpha.3=0.2,alpha.3=0), + Np=100,cooling.type="geometric",cooling.fraction=0.95^50, + ic.lag=10,var.factor=1 + ) +Warning message: +mif warning: argument 'pars' is redundant and deprecated. It will be removed in a future release. > fit <- mif( + fit, + Nmif=2, @@ -178,7 +251,10 @@ pfilter timestep 100 of 100 finished > ff <- pfilter(ff) > fit <- mif(fit,rw.sd=c(x1.0=5,x2.0=5,alpha.2=0.1,alpha.3=0.1)) -> fit <- continue(fit,Nmif=2,ivps=c("x1.0"),rw.sd=c(x1.0=5,alpha.2=0.1)) +> fit <- continue(fit,Nmif=2,ivps=c("x1.0"),pars=c("alpha.2")) +Warning messages: +1: mif warning: argument 'pars' is redundant and deprecated. It will be removed in a future release. +2: mif warning: the variables 'alpha.3', 'x2.0' have positive random-walk SDs specified, but are included in neither 'pars' nor 'ivps'. These random walk SDs will be ignored. > s <- coef(fit) > s[2] <- 0.01 > fit <- mif(fit,Nmif=3,start=s) @@ -217,4 +293,4 @@ > > proc.time() user system elapsed - 12.032 0.080 12.261 + 15.048 0.037 15.088 Modified: pkg/pomp/tests/ou2-mif2.R =================================================================== --- pkg/pomp/tests/ou2-mif2.R 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/tests/ou2-mif2.R 2015-02-27 02:58:17 UTC (rev 1111) @@ -11,7 +11,7 @@ set.seed(64857673L) mif1a <- mif(ou2,Nmif=100,start=guess1, - ivps=c('x1.0','x2.0'), + pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), rw.sd=c( x1.0=.5,x2.0=.5, alpha.2=0.1,alpha.3=0.1), @@ -26,7 +26,7 @@ ) mif2a <- mif(ou2,Nmif=100,start=guess1, - ivps=c('x1.0','x2.0'), + pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), rw.sd=c( x1.0=0.5,x2.0=.5, alpha.2=0.1,alpha.3=0.1), @@ -45,7 +45,7 @@ set.seed(64857673L) mif1b <- mif(ou2,Nmif=50,start=guess1, - ivps=c('x1.0','x2.0'), + pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), rw.sd=c( x1.0=.5,x2.0=.5, alpha.2=0.1,alpha.3=0.1), @@ -60,7 +60,7 @@ mif1b <- continue(mif1b,Nmif=50) mif2b <- mif(ou2,Nmif=50,start=guess1, - ivps=c('x1.0','x2.0'), + pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), rw.sd=c( x1.0=0.5,x2.0=.5, alpha.2=0.1,alpha.3=0.1), @@ -77,7 +77,7 @@ mif2b <- continue(mif2b,Nmif=50) mif2c <- mif(ou2,Nmif=50,start=guess1, - ivps=c('x1.0','x2.0'), + pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), rw.sd=c( x1.0=0.5,x2.0=.5, alpha.2=0.1,alpha.3=0.1), Modified: pkg/pomp/tests/ou2-mif2.Rout.save =================================================================== --- pkg/pomp/tests/ou2-mif2.Rout.save 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/tests/ou2-mif2.Rout.save 2015-02-27 02:58:17 UTC (rev 1111) @@ -32,7 +32,7 @@ > > set.seed(64857673L) > mif1a <- mif(ou2,Nmif=100,start=guess1, -+ ivps=c('x1.0','x2.0'), ++ pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), + rw.sd=c( + x1.0=.5,x2.0=.5, + alpha.2=0.1,alpha.3=0.1), @@ -45,9 +45,11 @@ + method="mif2", + tol=1e-8 + ) +Warning message: +mif warning: argument 'pars' is redundant and deprecated. It will be removed in a future release. > > mif2a <- mif(ou2,Nmif=100,start=guess1, -+ ivps=c('x1.0','x2.0'), ++ pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), + rw.sd=c( + x1.0=0.5,x2.0=.5, + alpha.2=0.1,alpha.3=0.1), @@ -61,12 +63,14 @@ + method="mif", + tol=1e-8 + ) +Warning message: +mif warning: argument 'pars' is redundant and deprecated. It will be removed in a future release. > > plot(c(mif1a,mif2a)) > > set.seed(64857673L) > mif1b <- mif(ou2,Nmif=50,start=guess1, -+ ivps=c('x1.0','x2.0'), ++ pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), + rw.sd=c( + x1.0=.5,x2.0=.5, + alpha.2=0.1,alpha.3=0.1), @@ -78,10 +82,12 @@ + cooling.fraction=0.05, + method="mif2" + ) +Warning message: +mif warning: argument 'pars' is redundant and deprecated. It will be removed in a future release. > mif1b <- continue(mif1b,Nmif=50) > > mif2b <- mif(ou2,Nmif=50,start=guess1, -+ ivps=c('x1.0','x2.0'), ++ pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), + rw.sd=c( + x1.0=0.5,x2.0=.5, + alpha.2=0.1,alpha.3=0.1), @@ -95,13 +101,14 @@ + max.fail=100, + method="mif" + ) -Warning message: -'cooling.factor' is deprecated. +Warning messages: +1: mif warning: argument 'pars' is redundant and deprecated. It will be removed in a future release. +2: 'cooling.factor' is deprecated. See '?mif' for instructions on specifying the cooling schedule. > mif2b <- continue(mif2b,Nmif=50) > > mif2c <- mif(ou2,Nmif=50,start=guess1, -+ ivps=c('x1.0','x2.0'), ++ pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), + rw.sd=c( + x1.0=0.5,x2.0=.5, + alpha.2=0.1,alpha.3=0.1), @@ -113,6 +120,8 @@ + max.fail=100, + method="mif2" + ) +Warning message: +mif warning: argument 'pars' is redundant and deprecated. It will be removed in a future release. > mif2c <- continue(mif2c,Nmif=50) > > plot(c(mif1b,mif2b)) @@ -135,4 +144,4 @@ > > proc.time() user system elapsed - 51.303 0.148 51.806 + 66.333 0.037 66.430 Modified: pkg/pomp/tests/ou2-nlf.Rout.save =================================================================== --- pkg/pomp/tests/ou2-nlf.Rout.save 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/tests/ou2-nlf.Rout.save 2015-02-27 02:58:17 UTC (rev 1111) @@ -85,4 +85,4 @@ > > proc.time() user system elapsed - 4.416 0.048 4.523 + 4.380 0.092 6.425 Modified: pkg/pomp/tests/ou2-pmcmc.Rout.save =================================================================== --- pkg/pomp/tests/ou2-pmcmc.Rout.save 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/tests/ou2-pmcmc.Rout.save 2015-02-27 02:58:17 UTC (rev 1111) @@ -138,4 +138,4 @@ > > proc.time() user system elapsed - 32.378 0.076 32.745 + 28.662 0.057 28.743 Modified: pkg/pomp/tests/ou2-probe.Rout.save =================================================================== --- pkg/pomp/tests/ou2-probe.Rout.save 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/tests/ou2-probe.Rout.save 2015-02-27 02:58:17 UTC (rev 1111) @@ -340,4 +340,4 @@ > > proc.time() user system elapsed - 7.692 0.072 7.942 + 7.892 0.092 8.187 Modified: pkg/pomp/tests/ou2-procmeas.Rout.save =================================================================== --- pkg/pomp/tests/ou2-procmeas.Rout.save 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/tests/ou2-procmeas.Rout.save 2015-02-27 02:58:17 UTC (rev 1111) @@ -54,4 +54,4 @@ > > proc.time() user system elapsed - 0.588 0.076 0.684 + 0.408 0.048 0.479 Modified: pkg/pomp/tests/ou2-simulate.Rout.save =================================================================== --- pkg/pomp/tests/ou2-simulate.Rout.save 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/tests/ou2-simulate.Rout.save 2015-02-27 02:58:17 UTC (rev 1111) @@ -35,7 +35,7 @@ > ou2.sim <- simulate(ou2,params=p,nsim=100,seed=32043858) > toc <- Sys.time() > print(toc-tic) -Time difference of 0.004848957 secs +Time difference of 0.006910086 secs > > coef(ou2,c('x1.0','x2.0')) <- c(-50,50) > @@ -46,4 +46,4 @@ > > proc.time() user system elapsed - 0.608 0.052 0.680 + 0.508 0.040 0.572 Modified: pkg/pomp/tests/ou2-spect.Rout.save =================================================================== --- pkg/pomp/tests/ou2-spect.Rout.save 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/tests/ou2-spect.Rout.save 2015-02-27 02:58:17 UTC (rev 1111) @@ -38,4 +38,4 @@ > > proc.time() user system elapsed - 22.417 0.048 22.562 + 21.537 0.040 21.670 Modified: pkg/pomp/tests/ou2-trajmatch.Rout.save =================================================================== --- pkg/pomp/tests/ou2-trajmatch.Rout.save 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/tests/ou2-trajmatch.Rout.save 2015-02-27 02:58:17 UTC (rev 1111) @@ -175,4 +175,4 @@ > > proc.time() user system elapsed - 2.188 0.040 2.279 + 1.712 0.060 1.801 Modified: pkg/pomp/tests/partrans.Rout.save =================================================================== --- pkg/pomp/tests/partrans.Rout.save 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/tests/partrans.Rout.save 2015-02-27 02:58:17 UTC (rev 1111) @@ -52,4 +52,4 @@ > > proc.time() user system elapsed - 0.600 0.052 0.668 + 0.600 0.060 0.678 Modified: pkg/pomp/tests/pfilter.Rout.save =================================================================== --- pkg/pomp/tests/pfilter.Rout.save 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/tests/pfilter.Rout.save 2015-02-27 02:58:17 UTC (rev 1111) @@ -77,4 +77,4 @@ > > proc.time() user system elapsed - 8.604 0.040 8.824 + 8.448 0.080 8.699 Modified: pkg/pomp/tests/pomppomp.Rout.save =================================================================== --- pkg/pomp/tests/pomppomp.Rout.save 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/tests/pomppomp.Rout.save 2015-02-27 02:58:17 UTC (rev 1111) @@ -55,4 +55,4 @@ > > proc.time() user system elapsed - 0.556 0.088 0.667 + 0.580 0.064 0.663 Modified: pkg/pomp/tests/prior.Rout.save =================================================================== --- pkg/pomp/tests/prior.Rout.save 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/tests/prior.Rout.save 2015-02-27 02:58:17 UTC (rev 1111) @@ -73,4 +73,4 @@ > > proc.time() user system elapsed - 0.796 0.040 0.857 + 0.736 0.056 0.809 Modified: pkg/pomp/tests/ricker-bsmc.Rout.save =================================================================== --- pkg/pomp/tests/ricker-bsmc.Rout.save 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/tests/ricker-bsmc.Rout.save 2015-02-27 02:58:17 UTC (rev 1111) @@ -54,4 +54,4 @@ > > proc.time() user system elapsed - 2.608 0.076 2.850 + 2.604 0.072 2.860 Modified: pkg/pomp/tests/ricker-probe.Rout.save =================================================================== --- pkg/pomp/tests/ricker-probe.Rout.save 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/tests/ricker-probe.Rout.save 2015-02-27 02:58:17 UTC (rev 1111) @@ -297,4 +297,4 @@ > > proc.time() user system elapsed - 12.064 0.080 12.363 + 11.976 0.072 12.278 Modified: pkg/pomp/tests/ricker-spect.Rout.save =================================================================== --- pkg/pomp/tests/ricker-spect.Rout.save 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/tests/ricker-spect.Rout.save 2015-02-27 02:58:17 UTC (rev 1111) @@ -70,4 +70,4 @@ > > proc.time() user system elapsed - 2.320 0.064 2.577 + 2.284 0.084 3.241 Modified: pkg/pomp/tests/ricker.Rout.save =================================================================== --- pkg/pomp/tests/ricker.Rout.save 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/tests/ricker.Rout.save 2015-02-27 02:58:17 UTC (rev 1111) @@ -83,4 +83,4 @@ > > proc.time() user system elapsed - 0.708 0.056 0.884 + 0.704 0.048 0.884 Modified: pkg/pomp/tests/rw2.Rout.save =================================================================== --- pkg/pomp/tests/rw2.Rout.save 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/tests/rw2.Rout.save 2015-02-27 02:58:17 UTC (rev 1111) @@ -164,7 +164,7 @@ } y } - + measurement model density, dmeasure = function (y, x, t, params, log, covars, ...) { @@ -177,7 +177,7 @@ f else exp(f) } - + prior simulator, rprior = function not specified prior density, dprior = @@ -342,4 +342,4 @@ > > proc.time() user system elapsed - 0.996 0.040 1.062 + 0.870 0.033 0.889 Modified: pkg/pomp/tests/sir.Rout.save =================================================================== --- pkg/pomp/tests/sir.Rout.save 2015-02-27 02:58:10 UTC (rev 1110) +++ pkg/pomp/tests/sir.Rout.save 2015-02-27 02:58:17 UTC (rev 1111) @@ -192,7 +192,7 @@ method = 0L, zeronames = zeronames, tcovar = tcovar, covar = covar, args = pairlist(...), gnsi = .getnativesymbolinfo) } - [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/pomp -r 1111 From noreply at r-forge.r-project.org Fri Feb 27 13:10:09 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 27 Feb 2015 13:10:09 +0100 (CET) Subject: [Pomp-commits] r1112 - in www: content vignettes Message-ID: <20150227121009.542CD186F24@r-forge.r-project.org> Author: kingaa Date: 2015-02-27 13:10:08 +0100 (Fri, 27 Feb 2015) New Revision: 1112 Modified: www/content/NEWS.html www/vignettes/advanced_topics_in_pomp.pdf www/vignettes/bsmc-ricker-flat-prior.rda www/vignettes/bsmc-ricker-normal-prior.rda www/vignettes/gompertz-multi-mif.rda www/vignettes/gompertz-performance.rda www/vignettes/gompertz-trajmatch.rda www/vignettes/intro_to_pomp.pdf www/vignettes/plugin-C-code.rda www/vignettes/plugin-R-code.rda www/vignettes/pomp.pdf www/vignettes/ricker-comparison.rda www/vignettes/ricker-mif.rda www/vignettes/vectorized-C-code.rda www/vignettes/vectorized-R-code.rda Log: - update vignettes Modified: www/content/NEWS.html =================================================================== --- www/content/NEWS.html 2015-02-27 02:58:17 UTC (rev 1111) +++ www/content/NEWS.html 2015-02-27 12:10:08 UTC (rev 1112) @@ -8,11 +8,11 @@

News for package ‘pomp’

-

Changes in pomp version 0.62-1

+

Changes in pomp version 0.61-3

    -
  • mif's pars argument, which is redundant, is now ignored with a warning. +

  • mif's pars argument, which is redundant, is now deprecated. In a future release, this argument will be removed.

Modified: www/vignettes/advanced_topics_in_pomp.pdf =================================================================== (Binary files differ) Modified: www/vignettes/bsmc-ricker-flat-prior.rda =================================================================== (Binary files differ) Modified: www/vignettes/bsmc-ricker-normal-prior.rda =================================================================== (Binary files differ) Modified: www/vignettes/gompertz-multi-mif.rda =================================================================== (Binary files differ) Modified: www/vignettes/gompertz-performance.rda =================================================================== (Binary files differ) Modified: www/vignettes/gompertz-trajmatch.rda =================================================================== (Binary files differ) Modified: www/vignettes/intro_to_pomp.pdf =================================================================== (Binary files differ) Modified: www/vignettes/plugin-C-code.rda =================================================================== (Binary files differ) Modified: www/vignettes/plugin-R-code.rda =================================================================== (Binary files differ) Modified: www/vignettes/pomp.pdf =================================================================== (Binary files differ) Modified: www/vignettes/ricker-comparison.rda =================================================================== (Binary files differ) Modified: www/vignettes/ricker-mif.rda =================================================================== (Binary files differ) Modified: www/vignettes/vectorized-C-code.rda =================================================================== (Binary files differ) Modified: www/vignettes/vectorized-R-code.rda =================================================================== (Binary files differ) From noreply at r-forge.r-project.org Fri Feb 27 14:59:44 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 27 Feb 2015 14:59:44 +0100 (CET) Subject: [Pomp-commits] r1113 - www/vignettes Message-ID: <20150227135944.DAEBC186933@r-forge.r-project.org> Author: kingaa Date: 2015-02-27 14:59:44 +0100 (Fri, 27 Feb 2015) New Revision: 1113 Modified: www/vignettes/pomp.pdf Log: - update lots more help pages Modified: www/vignettes/pomp.pdf =================================================================== (Binary files differ) From noreply at r-forge.r-project.org Fri Feb 27 15:13:25 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 27 Feb 2015 15:13:25 +0100 (CET) Subject: [Pomp-commits] r1114 - in pkg/pomp: . man Message-ID: <20150227141325.C9F6E184306@r-forge.r-project.org> Author: kingaa Date: 2015-02-27 15:13:25 +0100 (Fri, 27 Feb 2015) New Revision: 1114 Modified: pkg/pomp/DESCRIPTION pkg/pomp/man/basic-probes.Rd pkg/pomp/man/bsmc.Rd pkg/pomp/man/bsplines.Rd pkg/pomp/man/csnippet.Rd pkg/pomp/man/dacca.Rd pkg/pomp/man/design.Rd pkg/pomp/man/eulermultinom.Rd pkg/pomp/man/example.Rd pkg/pomp/man/logmeanexp.Rd pkg/pomp/man/mif.Rd pkg/pomp/man/pfilter.Rd pkg/pomp/man/plugins.Rd pkg/pomp/man/pomp-methods.Rd pkg/pomp/man/pomp.Rd pkg/pomp/man/probe.Rd pkg/pomp/man/sir.Rd pkg/pomp/man/spect.Rd pkg/pomp/man/traj-match.Rd pkg/pomp/man/verhulst.Rd Log: - edits to help pages Modified: pkg/pomp/DESCRIPTION =================================================================== --- pkg/pomp/DESCRIPTION 2015-02-27 13:59:44 UTC (rev 1113) +++ pkg/pomp/DESCRIPTION 2015-02-27 14:13:25 UTC (rev 1114) @@ -1,8 +1,8 @@ Package: pomp Type: Package Title: Statistical Inference for Partially Observed Markov Processes -Version: 0.61-3 -Date: 2015-02-26 +Version: 0.61-4 +Date: 2015-02-27 Authors at R: c(person(given=c("Aaron","A."),family="King", role=c("aut","cre"),email="kingaa at umich.edu"), person(given=c("Edward","L."),family="Ionides",role=c("aut")), Modified: pkg/pomp/man/basic-probes.Rd =================================================================== --- pkg/pomp/man/basic-probes.Rd 2015-02-27 13:59:44 UTC (rev 1113) +++ pkg/pomp/man/basic-probes.Rd 2015-02-27 14:13:25 UTC (rev 1114) @@ -1,6 +1,7 @@ \name{Probe functions} \title{Some useful probes for partially-observed Markov processes} \alias{Probe functions} +\alias{probe functions} \alias{basic.probes} \alias{probe.mean} \alias{probe.median} Modified: pkg/pomp/man/bsmc.Rd =================================================================== --- pkg/pomp/man/bsmc.Rd 2015-02-27 13:59:44 UTC (rev 1113) +++ pkg/pomp/man/bsmc.Rd 2015-02-27 14:13:25 UTC (rev 1114) @@ -121,7 +121,7 @@ \author{ Michael Lavine (lavine at math dot umass dot edu), Matthew Ferrari (mferrari at psu dot edu), - Aaron A. King (kingaa at umich dot edu) + Aaron A. King (kingaa at umich dot edu), Edward L. Ionides (ionides at umich dot edu) } \references{ Modified: pkg/pomp/man/bsplines.Rd =================================================================== --- pkg/pomp/man/bsplines.Rd 2015-02-27 13:59:44 UTC (rev 1113) +++ pkg/pomp/man/bsplines.Rd 2015-02-27 14:13:25 UTC (rev 1114) @@ -37,8 +37,8 @@ } \section{C API}{ Access to the underlying C routines is available: - See the header file \file{pomp.h} for the details. - Do \preformatted{file.show(system.file("include/pomp.h",package="pomp"))} to view this file. + see the header file \file{pomp.h} for definition and documentation of the C API. + At an \R prompt, execute \preformatted{file.show(system.file("include/pomp.h",package="pomp"))} to view this file. } \author{Aaron A. King \email{kingaa at umich dot edu}} \examples{ Modified: pkg/pomp/man/csnippet.Rd =================================================================== --- pkg/pomp/man/csnippet.Rd 2015-02-27 13:59:44 UTC (rev 1113) +++ pkg/pomp/man/csnippet.Rd 2015-02-27 14:13:25 UTC (rev 1114) @@ -21,6 +21,8 @@ The \code{pomp} constructor combines these \code{Csnippet}s into a compilable C file stored in the \R session's temporary directory. They are then compiled (via \code{\link[=SHLIB]{R CMD SHLIB}}) into dynamically loadable shared objects. This is then dynamically loaded as needed. + + Instructions for writing models using \code{Csnippet}s, along with examples, are given in the tutorials on the \href{http://pomp.r-forge.r-project.org}{package website}. } \author{Aaron A. King \email{kingaa at umich dot edu}} \seealso{ Modified: pkg/pomp/man/dacca.Rd =================================================================== --- pkg/pomp/man/dacca.Rd 2015-02-27 13:59:44 UTC (rev 1113) +++ pkg/pomp/man/dacca.Rd 2015-02-27 14:13:25 UTC (rev 1114) @@ -28,9 +28,9 @@ plot(simulate(dacca)) } \references{ - King, A. A., Ionides, E. L., Pascual, M., and Bouma, M. J. - Inapparent infections and cholera dynamics. - Nature 454:877-880 (2008) + A. A. King, E. L. Ionides, M. Pascual, and M. J. Bouma, + Inapparent infections and cholera dynamics, + Nature, 454:877-880, 2008 } \seealso{ \code{\link{euler.sir}}, Modified: pkg/pomp/man/design.Rd =================================================================== --- pkg/pomp/man/design.Rd 2015-02-27 13:59:44 UTC (rev 1113) +++ pkg/pomp/man/design.Rd 2015-02-27 14:13:25 UTC (rev 1114) @@ -69,7 +69,7 @@ plot(x) } \references{ - W. H. Press, S. A. Teukolsky, W. T. Vetterling, \& B. P. Flannery, + W. H. Press, S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, Numerical Recipes in C, Cambridge University Press, 1992 } Modified: pkg/pomp/man/eulermultinom.Rd =================================================================== --- pkg/pomp/man/eulermultinom.Rd 2015-02-27 13:59:44 UTC (rev 1113) +++ pkg/pomp/man/eulermultinom.Rd 2015-02-27 14:13:25 UTC (rev 1114) @@ -26,41 +26,24 @@ \deqn{(N-\sum_{i=1}^k \Delta n_i, \Delta n_1, \dots, \Delta n_k) \sim \mathrm{multinomial}(N;p_0,p_1,\dots,p_k),}{(N-\sum(dni), dn1, \dots, dnk) ~ multinomial(N;p0,p1,\dots,pk),} where \eqn{\Delta n_i}{dni} is the number of individuals dying in way \eqn{i} over the interval, the probability of remaining alive is \eqn{p_0=\exp(-\sum_i r_i \Delta t)}{p0=exp(-\sum(ri dt))}, and the probability of dying in way \eqn{j} is \deqn{p_j=\frac{r_j}{\sum_i r_i} (1-\exp(-\sum_i r_i \Delta t)).}{pj=(1-exp(-sum(ri dt))) rj/(\sum(ri)).} - In this case, we can say that + In this case, we say that \deqn{(\Delta n_1, \dots, \Delta n_k) \sim \mathrm{eulermultinom}(N,r,\Delta t),}{(dn1,\dots,dnk)~eulermultinom(N,r,dt),} where \eqn{r=(r_1,\dots,r_k)}{r=(r1,\dots,rk)}. - Draw \eqn{m} random samples from this distribution by doing - - \code{dn <- reulermultinom(n=m,size=N,rate=r,dt=dt)}, - + Draw \eqn{m} random samples from this distribution by doing \preformatted{dn <- reulermultinom(n=m,size=N,rate=r,dt=dt),} where \code{r} is the vector of rates. - Evaluate the probability that \eqn{x=(x_1,\dots,x_k)}{x=(x1,\dots,xk)} are the numbers of individuals who have died in each of the \eqn{k} ways over the interval \eqn{\Delta t=}{}\code{dt}, by doing - - \code{deulermultinom(x=x,size=N,rate=r,dt=dt)}. + Evaluate the probability that \eqn{x=(x_1,\dots,x_k)}{x=(x1,\dots,xk)} are the numbers of individuals who have died in each of the \eqn{k} ways over the interval \eqn{\Delta t=}{}\code{dt}, by doing \preformatted{deulermultinom(x=x,size=N,rate=r,dt=dt).} - Bret\'o & Ionides discuss how an infinitesimally overdispersed death process can be constructed by compounding a binomial process with a Gamma white noise process. + Breto & Ionides (2011) discuss how an infinitesimally overdispersed death process can be constructed by compounding a binomial process with a Gamma white noise process. The Euler approximation of the resulting process can be obtained as follows. - Let the increments of the equidispersed process be given by - - \code{reulermultinom(size=N,rate=r,dt=dt)}. - + Let the increments of the equidispersed process be given by \preformatted{reulermultinom(size=N,rate=r,dt=dt).} In this expression, replace the rate \eqn{r} with \eqn{r {\Delta W}/{\Delta t}}, - where \eqn{\Delta W ~ Gamma(dt/\sigma^2,\sigma^2)} is the increment of an integrated Gamma white noise process with intensity \eqn{\sigma}. - That is, \eqn{\Delta W} has mean \eqn{\Delta t} and variance \eqn{\sigma^2 \Delta t}. + where \eqn{\Delta\!W \sim \mathrm{Gamma}(\Delta\!t/\sigma^2,\sigma^2)} is the increment of an integrated Gamma white noise process with intensity \eqn{\sigma}. + That is, \eqn{\Delta\!W} has mean \eqn{\Delta\!t} and variance \eqn{\sigma^2 \Delta\!t}. The resulting process is overdispersed and converges (as \eqn{\Delta t} goes to zero) to a well-defined process. - The following lines of \R code accomplish this: - \preformatted{ - dW <- rgammawn(sigma=sigma,dt=dt) - dn <- reulermultinom(size=N,rate=r,dt=dW) - } - or - \preformatted{ - dn <- reulermultinom(size=N,rate=r*dW/dt,dt=dt). - } + The following lines of \R code accomplish this: \preformatted{dW <- rgammawn(sigma=sigma,dt=dt)} \preformatted{dn <- reulermultinom(size=N,rate=r,dt=dW)} or \preformatted{dn <- reulermultinom(size=N,rate=r*dW/dt,dt=dt).} He et al. use such overdispersed death processes in modeling measles. - For all of the functions described here, access to the underlying C routines is available: - see below. + For all of the functions described here, access to the underlying C routines is available: see below. } \value{ \item{reulermultinom}{ @@ -75,8 +58,8 @@ Returns a vector of length \code{n} containing random increments of the integrated Gamma white noise process with intensity \code{sigma}. } } -\section{C interface}{ - A C API for these functions is also provided by the package. +\section{C API}{ + An interface for C codes using these functions is provided by the package. At an \R prompt, execute \preformatted{file.show(system.file("include/pomp.h",package="pomp"))} to view the header file that defines and explains the API. } \author{Aaron A. King \email{kingaa at umich dot edu}} @@ -89,7 +72,7 @@ print(dn <- reulermultinom(5,size=100,rate=c(a=1,b=2,c=3),dt=dW)) } \references{ - C. Bret\'o & E. L. Ionides, + C. Breto & E. L. Ionides, Compound Markov counting processes and their applications to modeling infinitesimally over-dispersed systems. Stoch. Proc. Appl., 121:2571--2591, 2011. Modified: pkg/pomp/man/example.Rd =================================================================== --- pkg/pomp/man/example.Rd 2015-02-27 13:59:44 UTC (rev 1113) +++ pkg/pomp/man/example.Rd 2015-02-27 14:13:25 UTC (rev 1114) @@ -1,6 +1,6 @@ \name{Example pomp models} +\title{Examples of the construction of POMP models} \alias{pompExample} -\title{Examples of the construction of POMP models.} \alias{Example pomp models} \alias{pompExample} \description{ @@ -23,13 +23,16 @@ } } \details{ - Directories in the the global option \code{pomp.examples} (set using \code{options()}) are searched for files named \file{example.R}. + Directories listed in the global option \code{pomp.examples} (which can be changed using \code{options()}) are searched for file named \file{.R}. If found, this file will be \code{source}d in a temporary environment. - Additional arguments to \code{pompExample} define variables within this environment and will therefore be available when the code in \file{example.R} is \code{source}d. + Additional arguments to \code{pompExample} define variables within this environment and will therefore be available when the code in \file{.R} is \code{source}d. + + The codes that construct these \code{pomp} objects can be found in the \file{examples} directory in the installed package. + Do \code{system.file("examples",package="pomp"))} to find this directory. } \value{ - By default, \code{pompExample} has the side effect of creating one or more \code{pomp} objects in the global workspace. - If \code{envir=NULL}, there are no side effects; rather, the \code{pomp} objects are returned as a list. + By default, \code{pompExample} has the side effect of creating one or more objects in the global workspace. + If \code{envir=NULL}, there are no side effects; rather, the objects are returned as a list. } \author{Aaron A. King \email{kingaa at umich dot edu}} \examples{ Modified: pkg/pomp/man/logmeanexp.Rd =================================================================== --- pkg/pomp/man/logmeanexp.Rd 2015-02-27 13:59:44 UTC (rev 1113) +++ pkg/pomp/man/logmeanexp.Rd 2015-02-27 14:13:25 UTC (rev 1114) @@ -2,7 +2,7 @@ \alias{logmeanexp} \title{The log-mean-exp trick} \description{ - \code{logmeanexp} computes the log-mean-exp of a set of numbers. + \code{logmeanexp} computes \deqn{\log\frac{1}{N}\sum_{n=1}^N\!e^x_i,}{log mean exp(x_i),} avoiding over- and under-flow in doing so. } \usage{ logmeanexp(x, se = FALSE) @@ -22,5 +22,6 @@ ll <- replicate(n=5,logLik(pfilter(ricker,Np=1000))) ## an estimate of the log likelihood: logmeanexp(ll) + ## with standard error: logmeanexp(ll,se=TRUE) } Modified: pkg/pomp/man/mif.Rd =================================================================== --- pkg/pomp/man/mif.Rd 2015-02-27 13:59:44 UTC (rev 1113) +++ pkg/pomp/man/mif.Rd 2015-02-27 14:13:25 UTC (rev 1114) @@ -197,7 +197,7 @@ In particular, when \code{sd=0}, the \code{particles} should return matrices with \code{Np} identical columns, each given by the parameters specified in \code{center}. } \references{ - E. L. Ionides, C. Bret\\'o, & A. A. King, + E. L. Ionides, C. Breto, & A. A. King, Inference for nonlinear dynamical systems, Proc. Natl. Acad. Sci. U.S.A., 103:18438--18443, 2006. Modified: pkg/pomp/man/pfilter.Rd =================================================================== --- pkg/pomp/man/pfilter.Rd 2015-02-27 13:59:44 UTC (rev 1113) +++ pkg/pomp/man/pfilter.Rd 2015-02-27 14:13:25 UTC (rev 1114) @@ -152,14 +152,21 @@ } \item{cond.logLik}{ Extracts the estimated conditional log likelihood - \deqn{\ell_t(\theta) = \mathrm{Prob}[y_t \vert y_1, \dots, y_{t-1}]} + \deqn{\ell_t(\theta) = \mathrm{Prob}[y_t \vert y_1, \dots, y_{t-1}],}{ell_t(theta)=Prob[y_t | y_1, \dots, y_(t-1)],} + where \eqn{y_t} are the data, at time \eqn{t}. } \item{eff.sample.size}{ - Extracts the (time-dependent) estimated effective sample size. + Extracts the (time-dependent) estimated effective sample size, computed as + \deqn{\left(\sum_i\!w_{it}^2\right)^{-1},}{1/(sum(w_it^2)),} + where \eqn{w_{it}}{w_it} is the normalized weight of particle \eqn{i} at time \eqn{t}. } - \item{pred.mean, pred.var, filter.mean}{ - Extract the mean and variance of the approximate prediction distribution and the mean of the filtering distribution, respectively. + \item{pred.mean, pred.var}{ + Extract the mean and variance of the approximate prediction distribution. + This prediction distribution is that of \deqn{X_t \vert y_1,\dots,y_{t-1},}{X_t | y_1,\dots,y_(t-1),} where \eqn{X_t}, \eqn{y_t} are the state vector and data, respectively, at time \eqn{t}. } + \item{filter.mean}{ + Extract the mean of the filtering distribution, which is that of \deqn{X_t \vert y_1,\dots,y_t,}{X_t | y_1,\dots,y_t,} where \eqn{X_t}, \eqn{y_t} are the state vector and data, respectively, at time \eqn{t}. + } } } \examples{ Modified: pkg/pomp/man/plugins.Rd =================================================================== --- pkg/pomp/man/plugins.Rd 2015-02-27 13:59:44 UTC (rev 1113) +++ pkg/pomp/man/plugins.Rd 2015-02-27 14:13:25 UTC (rev 1114) @@ -58,7 +58,7 @@ \item{dens.fun}{ This can be either an R function, a \code{\link{Csnippet}}, or a compiled, dynamically loaded native function containing the model transition log probability density function. - If it is an R function, it should be of the form \code{dens.fun(x1,x2,t1,t2,params,...)}. + If it is an R function, it should be of the form \preformatted{dens.fun(x1,x2,t1,t2,params,...).} Here, \code{x1} and \code{x2} are named numeric vectors containing the values of the state process at times \code{t1} and \code{t2}, \code{params} is a named numeric vector containing parameters. Modified: pkg/pomp/man/pomp-methods.Rd =================================================================== --- pkg/pomp/man/pomp-methods.Rd 2015-02-27 13:59:44 UTC (rev 1113) +++ pkg/pomp/man/pomp-methods.Rd 2015-02-27 14:13:25 UTC (rev 1114) @@ -152,7 +152,6 @@ In this case, if some of the names in \code{pars} do not already name parameters in \code{coef(object,transform=TRUE)}, then they are concatenated. } \item{obs}{ - These functions are synonymous. \code{obs(object)} returns the array of observations. \code{obs(object,vars)} gives just the observations of variables named in \code{vars}. \code{vars} may specify the variables by position or by name. @@ -186,9 +185,7 @@ Additional arguments are passed to the low-level plotting routine. } \item{print}{Prints the \code{pomp} object in a nice way.} - \item{as, coerce}{ - The \code{coerce} method should typically not be used directly. - It is defined by \code{setAs} as a method to be used by \code{as}. + \item{as}{ A \code{pomp} object can be coerced to a data frame via \preformatted{as(object,"data.frame").} The data frame contains the times, the data, and the state trajectories, if they exist. } @@ -198,7 +195,8 @@ \seealso{ \code{\link{pomp}}, \link{pomp low-level interface}, - \link[=simulate-pomp]{simulate} + \link[=simulate-pomp]{simulate}, + \code{\link{pfilter}}, \code{\link{probe}}. } \keyword{programming} \keyword{ts} Modified: pkg/pomp/man/pomp.Rd =================================================================== --- pkg/pomp/man/pomp.Rd 2015-02-27 13:59:44 UTC (rev 1113) +++ pkg/pomp/man/pomp.Rd 2015-02-27 14:13:25 UTC (rev 1114) @@ -77,21 +77,25 @@ \item{rmeasure}{ optional; the measurement model simulator. This can be specified in one of four ways: - (1) as a function of prototype \preformatted{rmeasure(x,t,params,\dots)} that makes a draw from the observation process given states \code{x}, time \code{t}, and parameters \code{params}. - (2) as the name of a native (compiled) routine with prototype \code{pomp_measure_model_simulator} as defined in the header file \file{pomp.h}. - (To view the header file, execute \preformatted{file.show(system.file("include/pomp.h",package="pomp"))} in an \R session.) - (3) using the formula-based \code{measurement.model} facility (see below). - (4) as a snippet of C code (via \code{\link{Csnippet}}) that draws from the observation process as above. - The last is typically the preferred option, as it results in much faster code execution. + \enumerate{ + \item as a function of prototype \preformatted{rmeasure(x,t,params,\dots)} that makes a draw from the observation process given states \code{x}, time \code{t}, and parameters \code{params}. + \item as the name of a native (compiled) routine with prototype \code{pomp_measure_model_simulator} as defined in the header file \file{pomp.h}. + (To view the header file, execute \preformatted{file.show(system.file("include/pomp.h",package="pomp"))} in an \R session.) + \item using the formula-based \code{measurement.model} facility (see below). + \item as a snippet of C code (via \code{\link{Csnippet}}) that draws from the observation process as above. + The last is typically the preferred option, as it results in much faster code execution. + } } \item{dmeasure}{ optional; the measurement model probability density function. This can be specified in one of four ways: - (1) as a function of prototype \preformatted{dmeasure(y,x,t,params,log,\dots)} that computes the p.d.f. of \code{y} given \code{x}, \code{t}, and \code{params}. - (2) as the name of a native (compiled) routine with prototype \code{pomp_measure_model_density} as defined in the header file \file{pomp.h}. - (To view the header file, execute \preformatted{file.show(system.file("include/pomp.h",package="pomp"))} in an \R session.) - (3) using the formula-based \code{measurement.model} facility (see below). - (4) as a snippet of C code (via \code{\link{Csnippet}}) that computes the p.d.f. as above. + \enumerate{ + \item as a function of prototype \preformatted{dmeasure(y,x,t,params,log,\dots)} that computes the p.d.f. of \code{y} given \code{x}, \code{t}, and \code{params}. + \item as the name of a native (compiled) routine with prototype \code{pomp_measure_model_density} as defined in the header file \file{pomp.h}. + (To view the header file, execute \preformatted{file.show(system.file("include/pomp.h",package="pomp"))} in an \R session.) + \item using the formula-based \code{measurement.model} facility (see below). + \item as a snippet of C code (via \code{\link{Csnippet}}) that computes the p.d.f. as above. + } The last is typically the preferred option, as it results in much faster code execution. As might be expected, if \code{log=TRUE}, this function should return the log likelihood. } @@ -112,11 +116,13 @@ indicate this by specifying \code{skeleton.type="vectorfield"}. The skeleton function can be specified in one of three ways: - (1) as an \R function of prototype \preformatted{skeleton(x,t,params,\dots)} that evaluates the deterministic skeleton at state \code{x} and time \code{t} given the parameters \code{params}, - (2) as the name of a native (compiled) routine with prototype \code{pomp_skeleton} as defined in the header file \file{pomp.h}. - (To view the header file, execute \preformatted{file.show(system.file("include/pomp.h",package="pomp"))} in an \R session.) - (3) as a snippet of C code (via \code{\link{Csnippet}}) that performs this evaluation. - The latter is typically the preferred option, for reasons of computational efficiency. + \enumerate{ + \item as an \R function of prototype \preformatted{skeleton(x,t,params,\dots)} that evaluates the deterministic skeleton at state \code{x} and time \code{t} given the parameters \code{params}, + \item as the name of a native (compiled) routine with prototype \code{pomp_skeleton} as defined in the header file \file{pomp.h}. + (To view the header file, execute \preformatted{file.show(system.file("include/pomp.h",package="pomp"))} in an \R session.) + \item as a snippet of C code (via \code{\link{Csnippet}}) that performs this evaluation. + The latter is typically the preferred option, for reasons of computational efficiency. + } } \item{initializer}{ optional function of prototype \preformatted{initializer(params,t0,\dots)} that yields initial conditions for the state process when given a vector, \code{params}, of parameters. @@ -128,19 +134,23 @@ \item{rprior}{ optional; function drawing a sample from a prior distribution on parameters. This can be specified in one of three ways: - (1) as an \R function of prototype \preformatted{rprior(params,\dots)} that makes a draw from the prior distribution given \code{params}, - (2) as the name of a native (compiled) routine with prototype \code{pomp_rprior} as defined in the header file \file{pomp.h}, or - (To view the header file, execute \preformatted{file.show(system.file("include/pomp.h",package="pomp"))} in an \R session.) - (3) as a snippet of C code (via \code{\link{Csnippet}}). + \enumerate{ + \item as an \R function of prototype \preformatted{rprior(params,\dots)} that makes a draw from the prior distribution given \code{params}, + \item as the name of a native (compiled) routine with prototype \code{pomp_rprior} as defined in the header file \file{pomp.h}, or + (To view the header file, execute \preformatted{file.show(system.file("include/pomp.h",package="pomp"))} in an \R session.) + \item as a snippet of C code (via \code{\link{Csnippet}}). + } As above, the latter is typically preferable. } \item{dprior}{ optional; function evaluating the prior distribution. This can be specified in one of three ways: - (1) as an \R function of prototype \preformatted{dprior(params,log=FALSE,\dots)} that evaluates the prior probability density, - (2) as the name of a native (compiled) routine with prototype \code{pomp_dprior} as defined in the header file \file{pomp.h}, or - (To view the header file, execute \preformatted{file.show(system.file("include/pomp.h",package="pomp"))} in an \R session.) - (3) as a snippet of C code (via \code{\link{Csnippet}}). + \enumerate{ + \item as an \R function of prototype \preformatted{dprior(params,log=FALSE,\dots)} that evaluates the prior probability density, + \item as the name of a native (compiled) routine with prototype \code{pomp_dprior} as defined in the header file \file{pomp.h}, or + (To view the header file, execute \preformatted{file.show(system.file("include/pomp.h",package="pomp"))} in an \R session.) + \item as a snippet of C code (via \code{\link{Csnippet}}). + } As above, the latter is typically preferable. } \item{params}{ @@ -184,9 +194,8 @@ coef(obj1,transform=TRUE) <- x identical(coef(obj),coef(obj1)) identical(coef(obj1,transform=TRUE),x). - } - By default, both functions are the identity transformation. - See the demos (\code{demo(package="pomp")}), \code{\link{pompExample}}, and the tutorials on the \href{http://pomp.r-forge.r-project.org}{package website} for examples. + } By default, both functions are the identity transformation. + See the demos, \preformatted{demo(package="pomp"),} \code{\link{pompExample}}, and the tutorials on the \href{http://pomp.r-forge.r-project.org}{package website} for examples. } \item{globals}{ optional character; Modified: pkg/pomp/man/probe.Rd =================================================================== --- pkg/pomp/man/probe.Rd 2015-02-27 13:59:44 UTC (rev 1113) +++ pkg/pomp/man/probe.Rd 2015-02-27 14:13:25 UTC (rev 1114) @@ -88,7 +88,7 @@ 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 \code{pomp}. A vector-valued probe must always return a vector of the same size. - A number of useful examples are provided with the package: see \link{Probe functions}). + A number of useful examples are provided with the package: see \link{probe functions}). } \item{params}{ optional named numeric vector of model parameters. @@ -247,7 +247,7 @@ plot(bad) } \seealso{ - \link{pomp}, \link{Probe functions}, \link{spect}, + \link{pomp}, \link{probe functions}, \link{spect}, and the tutorials on the \href{http://pomp.r-forge.r-project.org}{package website}. } \keyword{optimize} Modified: pkg/pomp/man/sir.Rd =================================================================== --- pkg/pomp/man/sir.Rd 2015-02-27 13:59:44 UTC (rev 1113) +++ pkg/pomp/man/sir.Rd 2015-02-27 14:13:25 UTC (rev 1114) @@ -1,9 +1,9 @@ \name{sir} +\title{Compartmental epidemiological models} \alias{euler.sir} \alias{gillespie.sir} \alias{bbs} \docType{data} -\title{SIR models.} \description{ \code{euler.sir} is a \code{pomp} object encoding a simple seasonal SIR model. Simulation is performed using an Euler multinomial approximation. @@ -11,13 +11,8 @@ \code{bbs} is a nonseasonal SIR model together with data from a 1978 outbreak of influenza in a British boarding school. } \details{ - This example is discussed tutorials available on the \href{http://pomp.r-forge.r-project.org}{package website}. + This and similar examples are discussed and constructed in tutorials available on the \href{http://pomp.r-forge.r-project.org}{package website}. - The codes that construct these \code{pomp} objects can be found in the \dQuote{examples} directory in the installed package. - Do \code{system.file("examples",package="pomp"))} to find this directory. - For the basic \code{rprocess}, \code{dmeasure}, \code{rmeasure}, and \code{skeleton} functions, these codes use compiled native routines built into the package's library. - View \dQuote{src/sir.c} in the package source or \code{file.show("examples/sir.c")} from an \R session to view these codes. - The boarding school influenza outbreak is described in Anonymous (1978). } \examples{ Modified: pkg/pomp/man/spect.Rd =================================================================== --- pkg/pomp/man/spect.Rd 2015-02-27 13:59:44 UTC (rev 1113) +++ pkg/pomp/man/spect.Rd 2015-02-27 14:13:25 UTC (rev 1114) @@ -1,6 +1,7 @@ \name{Power spectrum computation and matching} \title{Power spectrum computation and spectrum-matching for partially-observed Markov processes} \alias{Power spectrum computation and matching} +\alias{power spectrum computation and matching} \alias{spect} \alias{spect,pomp-method} \alias{spect-pomp} @@ -56,7 +57,7 @@ } \item{seed}{ optional; if non-\code{NULL}, the random number generator will be initialized with this seed for simulations. - See \link{simulate-pomp}. + See \code{\link[=simulate-pomp]{simulate}}. } \item{transform}{ function; this transformation will be applied to the observables prior to estimation of the spectrum, and prior to any detrending. Modified: pkg/pomp/man/traj-match.Rd =================================================================== --- pkg/pomp/man/traj-match.Rd 2015-02-27 13:59:44 UTC (rev 1113) +++ pkg/pomp/man/traj-match.Rd 2015-02-27 14:13:25 UTC (rev 1114) @@ -1,5 +1,5 @@ \name{Trajectory matching} -\title{Trajectory matching} +\title{Parameter estimation by fitting the trajectory of a model's deterministic skeleton to data} \alias{Trajectory matching} \alias{traj.match} \alias{traj.match-pomp} @@ -17,9 +17,10 @@ \alias{traj.match.objfun-pomp} \alias{traj.match.objfun,pomp-method} \description{ - Facilities for matching trajectories of a model's deterministic skeleton to data. + This function attempts to match trajectories of a model's deterministic skeleton to data. Trajectory matching is equivalent to maximum likelihood estimation under the assumption that process noise is entirely absent, i.e., that all stochasticity is measurement error. + Accordingly, this method uses only the \code{skeleton} and \code{dmeasure} components of a \acronym{POMP} model. } \usage{ \S4method{traj.match}{pomp}(object, start, est = character(0), Modified: pkg/pomp/man/verhulst.Rd =================================================================== --- pkg/pomp/man/verhulst.Rd 2015-02-27 13:59:44 UTC (rev 1113) +++ pkg/pomp/man/verhulst.Rd 2015-02-27 14:13:25 UTC (rev 1114) @@ -6,7 +6,7 @@ \code{verhulst} is a \code{pomp} object encoding a univariate stochastic logistic model with measurement error. } \details{ - The model is written as an Ito diffusion, \eqn{dn = r n (1-n/K) dt + \sigma n dW}, where \eqn{W} is a Wiener process. + The model is written as an Ito diffusion, \deqn{dn = r n \left(1-\frac{n}{K}\right) dt + \sigma n dW}{dn = r n (1-n/K) dt + sigma n dW}, where \eqn{W} is a Wiener process. It is implemented using the \code{\link{euler.sim}} plug-in. } \examples{ @@ -23,7 +23,7 @@ matlines(time(verhulst),t(y['n',,]),type='l',lwd=2) } \seealso{ - \code{\link{pomp}} and the tutorial documents on the \href{http://pomp.r-forge.r-project.org}{package website}. + \code{\link{pomp}} } \keyword{models} \keyword{datasets} From noreply at r-forge.r-project.org Fri Feb 27 15:13:28 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 27 Feb 2015 15:13:28 +0100 (CET) Subject: [Pomp-commits] r1115 - www/vignettes Message-ID: <20150227141328.AD4FF184306@r-forge.r-project.org> Author: kingaa Date: 2015-02-27 15:13:28 +0100 (Fri, 27 Feb 2015) New Revision: 1115 Modified: www/vignettes/pomp.pdf Log: - update manual Modified: www/vignettes/pomp.pdf =================================================================== (Binary files differ) From noreply at r-forge.r-project.org Fri Feb 27 16:21:25 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 27 Feb 2015 16:21:25 +0100 (CET) Subject: [Pomp-commits] r1116 - pkg/pomp pkg/pomp/R pkg/pomp/inst pkg/pomp/man pkg/pomp/tests www/content www/vignettes Message-ID: <20150227152125.9289418762C@r-forge.r-project.org> Author: kingaa Date: 2015-02-27 16:21:25 +0100 (Fri, 27 Feb 2015) New Revision: 1116 Modified: pkg/pomp/DESCRIPTION pkg/pomp/R/mif.R pkg/pomp/inst/NEWS pkg/pomp/inst/NEWS.Rd pkg/pomp/man/mif.Rd pkg/pomp/tests/ou2-mif.R pkg/pomp/tests/ou2-mif.Rout.save pkg/pomp/tests/ou2-mif2.R pkg/pomp/tests/ou2-mif2.Rout.save www/content/NEWS.html www/vignettes/pomp.pdf Log: - mif's 'cooling.factor' argument, long deprecated, has been removed Modified: pkg/pomp/DESCRIPTION =================================================================== --- pkg/pomp/DESCRIPTION 2015-02-27 14:13:28 UTC (rev 1115) +++ pkg/pomp/DESCRIPTION 2015-02-27 15:21:25 UTC (rev 1116) @@ -1,7 +1,7 @@ Package: pomp Type: Package Title: Statistical Inference for Partially Observed Markov Processes -Version: 0.61-4 +Version: 0.62-1 Date: 2015-02-27 Authors at R: c(person(given=c("Aaron","A."),family="King", role=c("aut","cre"),email="kingaa at umich.edu"), Modified: pkg/pomp/R/mif.R =================================================================== --- pkg/pomp/R/mif.R 2015-02-27 14:13:28 UTC (rev 1115) +++ pkg/pomp/R/mif.R 2015-02-27 15:21:25 UTC (rev 1116) @@ -86,7 +86,7 @@ particles, rw.sd, Np, var.factor, ic.lag, - cooling.type, cooling.fraction, cooling.factor, + cooling.type, cooling.fraction, method, tol, max.fail, verbose, transform, .ndone = 0L, @@ -206,23 +206,6 @@ ) } - ## the following deals with the deprecated option 'cooling.factor' - if (!missing(cooling.factor)) { - warning(sQuote("cooling.factor")," is deprecated.\n", - "See ",sQuote("?mif")," for instructions on specifying the cooling schedule.", - call.=FALSE) - cooling.factor <- as.numeric(cooling.factor) - if ((length(cooling.factor)!=1)||(cooling.factor<0)||(cooling.factor>1)) - stop("mif error: ",sQuote("cooling.factor")," must be a number between 0 and 1",call.=FALSE) - if (missing(cooling.fraction)) { - cooling.fraction <- cooling.factor^50 - } else { - warning("specification of ",sQuote("cooling.factor"), - " is overridden by that of ",sQuote("cooling.fraction"), - call.=FALSE) - } - } - if (missing(cooling.fraction)) stop("mif error: ",sQuote("cooling.fraction")," must be specified",call.=FALSE) cooling.fraction <- as.numeric(cooling.fraction) @@ -399,9 +382,9 @@ start, ivps = character(0), particles, rw.sd, - Np, ic.lag, var.factor, + Np, ic.lag, var.factor = 1, cooling.type = c("geometric","hyperbolic"), - cooling.fraction, cooling.factor, + cooling.fraction, method = c("mif","unweighted","fp","mif2"), tol = 1e-17, max.fail = Inf, verbose = getOption("verbose"), @@ -453,7 +436,6 @@ rw.sd=rw.sd, Np=Np, cooling.type=cooling.type, - cooling.factor=cooling.factor, cooling.fraction=cooling.fraction, var.factor=var.factor, ic.lag=ic.lag, Modified: pkg/pomp/inst/NEWS =================================================================== --- pkg/pomp/inst/NEWS 2015-02-27 14:13:28 UTC (rev 1115) +++ pkg/pomp/inst/NEWS 2015-02-27 15:21:25 UTC (rev 1116) @@ -1,5 +1,15 @@ _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 _0._6_2-_1: + + ? ?mif? now has the default value ?var.factor=1?. Since + ?var.factor? has long been a required parameter, this change + is backward compatible. Since ?var.factor? has long been a + required parameter, this change is backward compatible. + + ? The long-deprecated ?cooling.factor? option to ?mif? has now + been removed. + _C_h_a_n_g_e_s _i_n '_p_o_m_p' _v_e_r_s_i_o_n _0._6_1-_3: ? ?mif?'s ?pars? argument, which is redundant, is now Modified: pkg/pomp/inst/NEWS.Rd =================================================================== --- pkg/pomp/inst/NEWS.Rd 2015-02-27 14:13:28 UTC (rev 1115) +++ pkg/pomp/inst/NEWS.Rd 2015-02-27 15:21:25 UTC (rev 1116) @@ -1,5 +1,13 @@ \name{NEWS} \title{News for package `pomp'} +\section{Changes in \pkg{pomp} version 0.62-1}{ + \itemize{ + \item \code{mif} now has the default value \code{var.factor=1}. + Since \code{var.factor} has long been a required parameter, this change is backward compatible. + Since \code{var.factor} has long been a required parameter, this change is backward compatible. + \item The long-deprecated \code{cooling.factor} option to \code{mif} has now been removed. + } +} \section{Changes in \pkg{pomp} version 0.61-3}{ \itemize{ \item \code{mif}'s \code{pars} argument, which is redundant, is now deprecated. Modified: pkg/pomp/man/mif.Rd =================================================================== --- pkg/pomp/man/mif.Rd 2015-02-27 14:13:28 UTC (rev 1115) +++ pkg/pomp/man/mif.Rd 2015-02-27 15:21:25 UTC (rev 1116) @@ -37,8 +37,8 @@ } \usage{ \S4method{mif}{pomp}(object, Nmif = 1, start, ivps = character(0), - particles, rw.sd, Np, ic.lag, var.factor, - cooling.type, cooling.fraction, cooling.factor, + particles, rw.sd, Np, ic.lag, var.factor = 1, + cooling.type, cooling.fraction, method = c("mif","unweighted","fp","mif2"), tol = 1e-17, max.fail = Inf, verbose = getOption("verbose"), transform = FALSE, \dots) @@ -107,7 +107,7 @@ the scaling coefficient relating the width of the starting particle distribution to \code{rw.sd}. In particular, the width of the distribution of particles at the start of the first \code{mif} iteration will be \code{random.walk.sd*var.factor}. } - \item{cooling.type, cooling.fraction, cooling.factor}{ + \item{cooling.type, cooling.fraction}{ specifications for the cooling schedule, i.e., the manner in which the intensity of the parameter perturbations is reduced with successive filtering iterations. \code{cooling.type} specifies the nature of the cooling schedule. @@ -115,8 +115,6 @@ When \code{cooling.type="hyperbolic"}, on the n-th \code{mif} iteration, the relative perturbation intensity is \code{(s+1)/(s+n)}, where \code{(s+1)/(s+50)=cooling.fraction}. \code{cooling.fraction} is the relative magnitude of the parameter perturbations after 50 \code{mif} iterations. - \code{cooling.factor} is now deprecated: - to achieve the old behavior, use \code{cooling.type="geometric"} and \preformatted{cooling.fraction=(cooling.factor)^50.} } \item{method}{ \code{method} sets the update rule used in the algorithm. Modified: pkg/pomp/tests/ou2-mif.R =================================================================== --- pkg/pomp/tests/ou2-mif.R 2015-02-27 14:13:28 UTC (rev 1115) +++ pkg/pomp/tests/ou2-mif.R 2015-02-27 15:21:25 UTC (rev 1116) @@ -28,7 +28,7 @@ var.factor=1, ic.lag=10, cooling.type="geometric", - cooling.factor=0.95, + cooling.fraction=0.95^50, max.fail=100 ) @@ -86,17 +86,6 @@ ou2, Nmif=1, ivps=c("x1.0","x2.0"), - rw.sd=c(alpha.1=0.1,alpha.4=0.2,alpha.3=0), - Np=100,cooling.type="geometric",cooling.fraction=0.95^50, - cooling.factor=0.95,ic.lag=10,var.factor=1 - ) - ) - -try( - mif( - ou2, - Nmif=1, - ivps=c("x1.0","x2.0"), rw.sd=c(x1.0=5,x2.0=5,alpha.1=0.1,alpha.4=0.2,alpha.3=0), Np=100,ic.lag=10,var.factor=1 ) Modified: pkg/pomp/tests/ou2-mif.Rout.save =================================================================== --- pkg/pomp/tests/ou2-mif.Rout.save 2015-02-27 14:13:28 UTC (rev 1115) +++ pkg/pomp/tests/ou2-mif.Rout.save 2015-02-27 15:21:25 UTC (rev 1116) @@ -61,13 +61,11 @@ + var.factor=1, + ic.lag=10, + cooling.type="geometric", -+ cooling.factor=0.95, ++ cooling.fraction=0.95^50, + max.fail=100 + ) -Warning messages: -1: mif warning: argument 'pars' is redundant and deprecated. It will be removed in a future release. -2: 'cooling.factor' is deprecated. -See '?mif' for instructions on specifying the cooling schedule. +Warning message: +mif warning: argument 'pars' is redundant and deprecated. It will be removed in a future release. > > mif2 <- mif(ou2,Nmif=30,start=guess2, + pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), @@ -135,18 +133,6 @@ + ou2, + Nmif=1, + ivps=c("x1.0","x2.0"), -+ rw.sd=c(alpha.1=0.1,alpha.4=0.2,alpha.3=0), -+ Np=100,cooling.type="geometric",cooling.fraction=0.95^50, -+ cooling.factor=0.95,ic.lag=10,var.factor=1 -+ ) -+ ) -Error : mif error: 'pars' and 'ivps' must be mutually disjoint subsets of 'names(start)' and must have a positive random-walk SDs specified in 'rw.sd' -> -> try( -+ mif( -+ ou2, -+ Nmif=1, -+ ivps=c("x1.0","x2.0"), + rw.sd=c(x1.0=5,x2.0=5,alpha.1=0.1,alpha.4=0.2,alpha.3=0), + Np=100,ic.lag=10,var.factor=1 + ) @@ -293,4 +279,4 @@ > > proc.time() user system elapsed - 15.048 0.037 15.088 + 15.232 0.060 15.274 Modified: pkg/pomp/tests/ou2-mif2.R =================================================================== --- pkg/pomp/tests/ou2-mif2.R 2015-02-27 14:13:28 UTC (rev 1115) +++ pkg/pomp/tests/ou2-mif2.R 2015-02-27 15:21:25 UTC (rev 1116) @@ -70,7 +70,7 @@ ic.lag=10, cooling.whatsit=200, cooling.type="geometric", - cooling.factor=0.95, + cooling.fraction=0.95^50, max.fail=100, method="mif" ) Modified: pkg/pomp/tests/ou2-mif2.Rout.save =================================================================== --- pkg/pomp/tests/ou2-mif2.Rout.save 2015-02-27 14:13:28 UTC (rev 1115) +++ pkg/pomp/tests/ou2-mif2.Rout.save 2015-02-27 15:21:25 UTC (rev 1116) @@ -97,14 +97,12 @@ + ic.lag=10, + cooling.whatsit=200, + cooling.type="geometric", -+ cooling.factor=0.95, ++ cooling.fraction=0.95^50, + max.fail=100, + method="mif" + ) -Warning messages: -1: mif warning: argument 'pars' is redundant and deprecated. It will be removed in a future release. -2: 'cooling.factor' is deprecated. -See '?mif' for instructions on specifying the cooling schedule. +Warning message: +mif warning: argument 'pars' is redundant and deprecated. It will be removed in a future release. > mif2b <- continue(mif2b,Nmif=50) > > mif2c <- mif(ou2,Nmif=50,start=guess1, @@ -144,4 +142,4 @@ > > proc.time() user system elapsed - 66.333 0.037 66.430 + 66.324 0.058 66.448 Modified: www/content/NEWS.html =================================================================== --- www/content/NEWS.html 2015-02-27 14:13:28 UTC (rev 1115) +++ www/content/NEWS.html 2015-02-27 15:21:25 UTC (rev 1116) @@ -8,6 +8,21 @@

News for package ‘pomp’

+

Changes in pomp version 0.62-1

+ + +
    +
  • mif now has the default value var.factor=1. +Since var.factor has long been a required parameter, this change is backward compatible. +Since var.factor has long been a required parameter, this change is backward compatible. +

    +
  • +
  • The long-deprecated cooling.factor option to mif has now been removed. +

    +
+ + +

Changes in pomp version 0.61-3

Modified: www/vignettes/pomp.pdf =================================================================== (Binary files differ) From noreply at r-forge.r-project.org Sat Feb 28 18:56:04 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 28 Feb 2015 18:56:04 +0100 (CET) Subject: [Pomp-commits] r1117 - www/graphics Message-ID: <20150228175604.7FEB71876D5@r-forge.r-project.org> Author: kingaa Date: 2015-02-28 18:56:04 +0100 (Sat, 28 Feb 2015) New Revision: 1117 Added: www/graphics/cc-by-nc.png www/graphics/state_space_diagram1.png www/graphics/state_space_diagram2.png Log: - add some diagrams Added: www/graphics/cc-by-nc.png =================================================================== --- www/graphics/cc-by-nc.png (rev 0) +++ www/graphics/cc-by-nc.png 2015-02-28 17:56:04 UTC (rev 1117) @@ -0,0 +1,47 @@ +?PNG + + +IHDRXc? +? pHYs  ?? +OiCCPPhotoshop ICC profilex??SgTS?=???BK???KoR RB???&*! J?!??Q?EE???????Q, ? +??!?????????{?k????????>??????? ?H3Q5? ?B???????.@? +$p?d!s?#?~<<+"??x? ?M??0???B?\???t?8K?@z?B?@F???&S?`?cb?P-`'??????{[?!?? e?Dh;??V?EX0fK?9?-0IWfH???? ? 0Q??){`?##x??F?W?5?j>{?-?]c?K'Xt?????o??(?h???w????G?%?fI?q^D$.T????D??*?A??,???? ?`6?B$??BB +d?r`)??B(???*`/?@4?Qh??p.?U?=p?a??(?? A?a!??b?X#????!?H?$ ??Q"K?5H1R?T UH?=r9?\F??;?2????G1???Q=? ?C??7?F? ?dt1?????r?=?6????h??>C?0??3?l0.??B?8, ?c??"? ???V????c??w?E? 6wB aAHXLXN?H? $4? 7 ?Q?'"??K?&???b21?XH,#??/{?C?7$?C2'??I??T??F?nR#?,??4H#???dk?9?, +???????3??!?[ +?b at q??S?(R?jJ??4?e?2AU??R???T5?ZB???R?Q??4u?9??IK?????hh?i??t???N??W???G????w +????g(?gw??L????T071?????oUX*?*|?? +?J?&?*/T?????? U?U?T??^S}?FU3S?? ???U??P?SSg?;???g?oT??~Y??Y?L?OC?Q??_??? c?x,!k +??u?5?&???|v*?????=???9C3J3W?R??f???q??tN ?(???~???)?)?4L?1e\k????X?H?Q?G??6??????E?Y??A?J'\'Gg????S?S?? +?M=:??.?k???Dw?n?????^??Lo??y???}/?T?m???G X? $? ?.??????Jt?q]?z????????????6?i?????4?)?Y3s???C?Q??? ??0k??~OCO?g??#/c/?W?????w??a?>?>r??>?<7?2?Y_?7?????O?o?_??C#?d?z????%g??A?[??z|!???:?e????A???AA???????!h????!??????i?P~???a?a??~ '???W???p?X?1?5w??Cs?D?D?D??g1O9?-J5*>?.j??????(?x??o??????????d?f?f???-?[?????n +??? +?V????E?/??(????C??????UUM?f?e?I???????????m]?Nmq????#??????=TR??+?G?????w- +6 +U????#pDy??? ?? +:?v?{???vg/jB???F?S??[b[?O?>????z?G??499??r????C?d?&??????/~??????????????m|????????????x31^?V???w?w???O?| (?h???S??????????c3-?gAMA??|?Q? cHRMz%??????u0?`:?o?_?F 4IDATx??Z]l???H??R??? +r0{? +???&??-???,? +v?I?5?`???K???O+?doH?a[-?(??f???"?+0[N"i#=????X? +?+?f??{yE??-?v??9??????{?9??!?X???e???0???e??,8??r?X,?Y ??e0 0????D?????(???@QT??B?T?????e??? ???0?N.?q??r?s?????F2?a??j?h??y2E+?s?L????X#???fr9 ,?c?\?r?h?X s?9P??;v????.4??????QX0`??4L??g?9?,M???8??"??????n??"`???U??^? ??[??b??Z,?|?,?F????tY?6? +??@c?.??E?!?ZQd??B5??&/??O??/\??T2p:?p8?D"I???z??7???????????????p???*TY,tuCi??!jkk???A&??(?????m?????????e9Y?,? ???d???-7?0??#>d?Y??p8???Z?Gd2??~?????s?se??????[??*??* ?,U&ry?????????%#??~?%??^????{|m?F?r?\?jrQ????WO!?L???`pp?0?4?b??H$???6???q????(????~?????w?Y???????` ????5??p ?#,I.x<??i:?R?zC}&[?R??)??H???8R?A@???~???? H%S?;/????)lmh?v~?D??P?n??+?O`jj?"|]X`u???0"????F????R???H/??!???S ??? b86?]J?6??? =????????????????'O"????????M?58??? !J?????Z??z?????Kk?2?O?j????O&?p:??????j~[[?????N?s?'PLt???f???SSS?9??J??y:?????v?: +X?$?6?{~$)z?T?R?p8????P?~???????3??b?????9?????S?um?F????KI??? +?????`0X?????du-?????`??????{;w???"6???0U?J48??z??e?????S??N???w??a????tCCC&=????=??.6v??$!?????)????J?????????v?;}[????=??>????=?q?????6.. ??>????t: +??C???CZg\ +??Y????4????V??R????h{?|????4?a?v? -???=??????o&??P?no@???(.?J?+?"???e? +???????S]8?????&?????j??L01GEF??ks$???,????  ??&?????????^????Z??D"p????g2??n????j????H?_ +????4?[ +>]????Vc.;???I? ??o???D?^?H$???cU[?A?!?>?????{??$.????DQ?(?p8p8?y?$Qe?$???t??3? +6 x*qH?????1y4??t:?? ???:???C&????y}?^?w~??w??? +????????O?? "?z??y???MfffJ;33C??? ???????? r;1A:?_Er ??)? +tb?[??bA_?o???????g?!?2??cx???????lw3???????????])6?????k??8y3?Gb???1??F~;@???vb????7V???%???*?_??g0??*?Q/<@w!???^?????a??F??v??U? +?]?"QD??Bsb?:?F???????8???6?n?1?????????~???????? ??Z???L?R?]?u??? M?M???6|?j5?p5???lwn???k7???/Z????E?cY?? ? IDATx^????V??O??r????i?efNSH?!????Sff??M???????i???o?;?????lK?l??D?01 C?U??*??_C?HD`?u?u|f?qF??[d???s??? o????7M C?h??l? }?{???O^?w?y????^&?h?\'??o?\?O?x'?.;qNi???1jE??Z???O??T?]~???Zw.??s?5???0??b0?H?ut??????&???S?Z?????Z?$?!y?????MC?????e'??????????B????o??v?iVV?w?y???4:?N?]v??:}??Z?@km????#?????y???y????r?)?L3?????|??[y????~??wM?????c?=??s??I'??m???%?{??w?\?^}?U??{???FM??`? +?? .Xrn=?????B????????????{7????A????_?e???0???~?]v?en??gwn???????J??+?????1|?????O?q?v??=?????????|?M???O>???3?,/?P???G?9?Dz??$?B??!??l??V^??????A?(4 /?pbG/|y??????}$4 ??????w?}?4s?K,??r??j????^???I_?s??????9?o?y?R {|??p?9??8G??^,???X??X?z?#V}?????:???(s??2J? +X??f??????D{?]?~??=??^{??Zh!}+o??X#???#Q????F???5????kg??4?W?????@??e?/?? }????P.<??{??0??.??y???? ?j??s??Q????z`?(q??< ??U7j?b?0((c?????\????iG? J?K????1b ? |QXB?XJo???C|???J?AiC?? cW??????o??hg??V??QF??'????`?)?WX??+O?6??V??e?i +X??9??r??w???"W?Y?3?8C?JAv?a?? +???{U????i?5???8k?&??R? +?.4zA???3p1?i[[!?B\=Z??o????I?Hz?X?z????+:?????1$a?? Wt????5?$??AP?* m? S?~b????R1B???_? +?(W??????????m?'?N#?#oid??=???k??({??Y?G?? ????d+I ?*J???p? ?????X?p??a??Q??[q??? +\`???$??m????U@?X??? +?$Y???&??5?#???%.i?<??f?[ +?4???????%M>?????Q8{?Y??F?B?R%?4=??V??????i??9???????W???=^????? +?"???q???S?2Z3??q?@A?????`???Nt????3???Sso???k3d? +<8J.??g??YaU?_??P|JiG,9B??%d??U%?\ X}??o??Q??qz ?cSI(?$XI??=H??"?X??i?9?w??J?U?/?]??k??IcH;?Z?Y+.E?+?????|L?h?CQysX }?8?????xF!?r ??8???wsV.???|,lA?i?]q???p??t?1??I??z? +??????NqiG?? 7??}?F???@???? V?JPl?????? +a?X?~?$&=? +?c +?:?%????Hq?81(?!?????5????w?w??'?????[.???? ??*J?[ +?'I????r nD +w???c?=6?8?????X??????f???f?????5?x at u??> ?s3?s??e?Z????-^X[jI???? +?7>????ld??F?9q^????Z??b???'?|C V'?q(y#`k ?^x??A?? w????^?P??k??B????`}-?-.???)K$w? I?? +K\Mt??`iY!?*hW????????c)?7??yC????(?%?v?sH?? ?f|?N?O?(???T ?#??:???7?bI??%?S"?\(d??H)?r?l?????%Y???}???z???y???\U??LE?EYK??}K=??c?F ??(?$??Z?q|?O??Q{?`????[?}J#?#???j?KJg?k>?R_Rv(i?\C??0'? ???E???y???`*/ %%????????8?????R???k ?4X-?4(U9???X?<73j?? 2d??/U???W?? u????J,`?i?YY???a???{F?x?D?7???_?E?????W??J59?O??F?^?? +?~????B??y(l?~??f????B?{?S?(??]\?? ?@?+(????X??k??W?H???i|??C???~s????UQ]y???J+????&?0,Nv?!`?@#@???a???W^?J???_?h-????8`?o???x??:1cw?q?*?7?|?&!???? ?u?Y?????J?aRS?:tw?????o?7?|S? ???|?????????M/ +Y>???c??H???????1O?;??=>7??Z??? +C -???*[??w?* plq_?Z???k??k?QGM???W?7X?Pn????C???l??[e?U:"V.? +` +X??6?=|?????~>??C??G??>??}????7?_???Q?&??a>F?/???TOP)?? +???? +]5???d?I?C??4??l??"??7C?0?"??? .?@??'??Zf?e?*??+ +?V????Rx?y??????V/??7?6?tS??4???t'???"Lf +i??r#??/??? +J?DM? ??????`?B?j?`?/???~??%??????S.??P +??OH???c5????B?[L???!??&? +.M?sp[N????znb??????:J?2??'???z?g1<'?:b? ???;????? ??e???1??~?????[oE?c??c&(0*?L??Wh??? ?3q ??EY????_?d(?????&??!P?d]{??n?}?U?/P{???f3???D?q +?z?m????\+`??{0??????`K????*??2D???v?a??f +X??"K???(]??!??E e,"d+?t>??c??z????P.?~??n?Wl????????AX?.??2?m?[?e?! {??}u???{d??X-C@?????o?E??u???+J?"?????K? G`??Y???E?/?????? /????(C?q?B?%W????{????."o -??x? i?.??uy?Lx)?Q?L ??~1/??^Gu? ???g/A?yui?????R????7Q?'/?r^J?xI?h?H[???}?~?TbU/Yn????-8??3??"\?^???j?????K@?. +??{Ii?h?&?@3??2l?0/Y????I????t?m??????&?????c?? IDAT?u e3??3^J?5P2?;~?6??~N}?so=??c??0?Fl?4??jN?u?`???:?9???????H?1??\u?1??????{?m???Jo? ???3?t$?T?B?X?'???d???X[?7R???rC?Q(?1???5& ?0?? +/)r-o??_?l???@N5k??Vlb ??????4?(?A2q?S???qLBGR?V?)I????(?5??? ??J ?E??$????m?m??????> +)OX@???]?????K?.5?e??h????#?L?7 +??j7?,z??x?}???:??LdO@{?7$|k^???d at y?L??;??(???K.??n)?%U=??!n??B???K/?To??????!/$?~???5?.???? ??^??z???O?!a?? ??G?q?!?O???C??b??b???o??????r0??8???5???hG?c '?N,?Z?L^&4>L?,4n??ZT?????7 +eH??????jA?J??)?yK?~-???&?@????o???p?M?F??R?U???L?t?& ??>???j?1?B@,?JJ?????r????? b??.?H?????m??%5?B0?_|?W?lM??????'?????L3???Yf??1?????j?vJ???S?_?w(??V??h??H?=J4??b?*?m<]?m?T1??K.?????"????t??w?Yf?% +V~????a?6FC?a??r?-5Fh?1??????n?? +?5G??`]?(???q?I?mc????? ??c?.H??x? ???o??|?-9U?ho?WrA??E_i]?\G? ? +\????kS???m???o??_???%??=? +?y?i?7?$?p?B?^$??B[??V?Xc +?\y???H???J???y!?{,?{??qBZ?p????????v???mKIZ????????)???????V[?ib*N????ENJ??v?-We?m?Jd?????0?#??????p? ?-??R????A`,V??? +??HJa???u?F????2???????L?mS???rSK???" +?V??RI?$*???"??G? ?r?_J?HK=?6? J| ??? J???nb?#?:1T??z-n???Z??vSN9?VF?h??Z>?6Hr??c?9??>h?-_@=????N??N,????Liz?C=?$?C???'e???f.????A??Z?Ep>|Y?+????I???URl????????@??j??e#?$???H2%??)MU??8??@d8?l?fN??2????,??R??Cq????w[7L?c?(4j??|?d?M?%}?/?H??? +%J ,UJ?0$?!Pd??r?)?5z?????F?5????aF&M??n?R???]g???u?D?=)?S J???T???L???^?Z-T?n?????_TW??!??`]??G8 +?$?4e:?+`p?PH???g??(JM??ub?C?3.?I'?? UE?L??q~?-???(???????Kd~??? +?&" ?W?H?,/;??\0?F?\sM'o?4???t?f???0 ?2???N?=?6?h?C?jb??e?????? k??!?I???@?????X ?????o?4qS#??0Z?qaK/??2??~??Zy??H?VT???L0??3????3?*r`m??HVd??K>??iw???j??)_y/??o?C? owX?H?6+F:??,??{?=ue?bm????ND?lH?`?.B??3W??Q??s ??0?#0?????%e8???:~&?@5p?@;A ??!?????NJ?%?*r?b?.H2??>?????4??h&r_??????^{?-??"????[??????B +?_p??4????BH TXP?41:)M??;`??j??????l? +7?P?/\??|??f??!? X?0????;R +)g??5?=???????o??|?I%?%S??k???k???.%??=cbt:?s??????5???????v +?nCrM? B?*??&?#????:????g????3??7?9/?x8??u|M?!@i?j?Yg????B???????x??4??Q$??s??j}@X??@?#@?Y??q^y??n??A +C?=?Z?&?A?"??Q??^{m-T?P?u|?????Q?o???~???x??P??h;j?u?8??DO???)_??06 +C?^??Ep>?1?_/???E+I??=??#n?-?tN8a???p:>???n??W6?+???9?????R?I?#?????7?[?z??a??^{??.HC?hx? :?>??L??@?:????,??o???w_??? ?/(q???TG?u????n????_~Q~M??!0p?@?,/???0?V?x?9??Zf??0:??f?I?d+2dH?L??gRM??Xr? +6p7?x???u?1??QG?*"??w???g??????G?P|L??t????^3? ???Or?%??? +E#? +4$F1?Ey???????_}I?????{&BO?=??????? ?Vh??u???Z???s?1$2Z??1`d;?? ?31 ??A?@nQ?>?h?8J??=??S?@??"????w?J?~$??&?R?5???m??w`xZh?D?????Lu??L?@????wm?4?.8Y\??{?ZRY???"?q???S?C??.8?????k??I?@??Y?3$s??lJ?R=??m%BS)?~??fSK +?qJJQm?wV???f-?w??(`???T??O>Y??N??!`t??\pAw????} +?T???Y3??&'1I?5? f3z(x???V ??Q???????Jn?9?x??G??????g?q? /????Z??l???C???!`t'p??6?5?????o????\?R???????&?l??_??u3?6?}???D????? +??@?z??????3 ?6B??0??O=??6? +?^LKF.???5^ +??;????v?e?(????Y???#?M?)?.?zPT???c??P????U^_?f?q??z{??????$(d?2P)???u?mv???~F???H?F?QU ???'%???????? .??|???????????_~?j < ?????j1?Z????????????^?9?)>_n~? T??s?{??v,?J|??g??~??7}#???????v?mk?3~A30`tKq-%E????p????K??1?b?????/M ?nE??gG?=d?C??R???????????????A????{1?z?q???#??????8???~?o{?w?R?4?~????|???Ip????????y1?z1?z?^??8"?=?????]w]?K?[/f^k??"??Yf???kz)L??Xc +=???????^xa ????????^L?????K??????L3?4~?-???`????????G?W^ye??i?? ?T??0 *??m??g?7?pC??????%?4Z???Z??]2W)|?k +|?K ?r?-???fa???^SO=?_}??????X?u??v?m?(z????R??0??[????^c??`???[???0??*??X$?GX?D??0?;??-?mT?@8??s?^G^??f?CB??I'??p(U???o?L?t?h???????dx1??y???)?(e?? y1???[m?U???p??'??????_????'%E?kY?P1?j_b?(?F,3~?)??{??G??C9?KM??c}?Q??;??cz??y??p?D?q??s?]??MO???!??{??Wt~?9??=J;? +???k?|$???E?/??????mP???!q??R????L?/???%/ ????O??P?%?I?,i?=?,E?u??p? ]Nz???T? +?X?J?M?y???0~??2????m?/???L ?nE????CfA?v??7????Y ????"n??iD?a??? +?%????????AQ?:$?D=????k?2 ?"???D}?+ZX????/??????~???'?|???0??4%)`(? +?b!??k??X?K??U???d???9??}?c? U?#s-??H?}????@?G ???HX???wv?}~K??? ? * +|?u??$)`???}f???&VH,?? 7-?u??;?b#?5Wb???dbt#G?J?C0,_???Fe%? iS???f??InO??0?Rd???SK??e?h??????6lX??p+?F2Iz\???~p1?K?q!????[?h?1q~?F?q?F???????Y???????3????r?-?c?X???+???F??0J#X$ ??n????XG=M???Fm?xi?I +X=??A +???????[?e?G?_?3???b????pM??e???i???!????????Gb??_|!?9???YI?RF???iJ.???g??O +.??! +???_/?9|?p'?5?5????Q"??? ?G?????8, +4' O,uz?R1YI?&?????w?Yc??K?:????,???E?P-Bb???<%??????N,>J?1??!C?|????r'?R/?Y????q?????[B +?{???????? +?h???4?n???I???ed??????W???B?#?W??@y?|H'?*??????jvq<.0~K????;?\H2???4+??fI#s?m??bO[y?%I)k??`???9{???(??p???ZR????|a???F??k??U????$?????9 ??G?D??h?? +??X???O?e}}?j?!???V??Nb??!1*?Z[??????@?cn?-?p>??i'?N2???W?t?uL??ot??????"???qgyn?R?u??H?`? +K??re??? +sS???M?mK2???????Z?&?@7 ???R? ?)'????k?????I??^GV?@i???r?$??#??~?V`???q?2?f?A6{????/ ???Hf?B??!??p?z+5?????TT?x??u??T+??Oz????[?????\???-??2F?Bd1?W?X?`?c??*??????9?s=c?c^?????$ lp?]?i?N????[???IL`?p?????e? +1???????/??'?&?????9??q????VO?eV?k?yl???|?i?5?S??h$????|G?Dn!??~Z???/(?C?0????A? +?*??K?????H'?|r4&8?`??:>?u@??~??}?#???????7?=??(C?|GY???:??S?? ?LHQ?"?`z?X?J?v?aQ?^??f????,?N?+? +??5p??????5?x=s?{?T?X??????r ??|s~???w?BTK???W?*~}^?{,0?S?*.????Oi???'?[???/???G2l?sF?O????o???h???g?A?e?????+???6??^t?w?+? +MQ?g#22B?j9?W?8???D"???>[o?? +?1?Q?!?w6{????&??fa??7? +Q????qRo?"$?+W?2&?h?h?rY?5"??*?8?????bbt??r??Wc? F? +|/R|?y????eb?@*RH?R%$>??L???A?/?$?????Rk]2k?f? ?-????S???>?? |?? ? ?[???:0 ??B ?'^[ +?[7??$??I\?V?01:????o?'?{??}n????q?????7e??!`???? 0????????;?????Dqa&?@;#??d??u?????Dd???Yev?5a??0C1? ?X??]?j?V$TE2l? ?z???!?$? ?Jw?qM????2QC?0BO??E]?@?R???6.Y?(a&?@?"@YA?iBGUR????????? +7A5?f ??0 ?b = +T*?BQS ?:o p0?S?Cx;o?6??G? \????{??RQc p?P???5{Y??C????I? uA?t7PQP?T*5?w?}??????d=??????Ge??9??A? B???N???_?Yd?f???2 ?" ???A???"?E$?- ?? i??Go?]\?<?#????,?mx`??!? ??JYB%??????{k ^?D??????M???>Rn0C??^???a????5Wc???Pg|?g(-?f?m? ?41????=???II6w????l??? ?v?m???J??? +?:6 ??#@?#?I??T?W?Gl#h?c=??se?n??C?(x?p=R????'Z)U0?[o??&n????Z????? +?"W?g??????(G?????C5????x?@2 +??k????Fe??g?qZ>?? +#?O:??c????????@?8???5??Zi#??????AZ?-G`?q?u??w?VOYn??L k???@??????????I?n$??????Q?y??E???0?????????p7?t????7?W??]?d?I???????????&q??B??O>q?/??????B;?,??j(=?M??q?;???k,w??;?}a&`1 ?|?????=???iEj?????7?O???????[?LzBXL ?f#?????? ?+???-????B???V?0-S? +?%?\R?I?` C ???+??????g??m???tb?v$s?5??h;?E?-??????:r?6?b"@?m??B&?????h?Zc???????? ??lb??m?}??? ??cb???????[c?yRE????]?????v??ukkR?(?M?J??pE??@?"??????{? +7tX3L ?z@ {???]?~???k???=??z??k ?T????MV.?? ?*5)`LS?:???N??tw?=?u^6.C?h?Q?=8???h?.5????a??}?????_?e??"p?q???]?c?=V???0??po??'WB??>?,S?1C?h=??y??7?e?]?&?`???F????t?wh,??????^zi???_???l?G?h?!?P???b?????R??????D?FmdY??_f?!???]|??n???R??F??}n?? +??e??????#?{?m?Q???1????[hV????n"t?M kv?G??v???vB???rZ???!P ?,?l?N??/??. V?? .??:???a}?8%??=??L3?4M6?J?????3??3f6???=??&4Dy?+??B+7H????2Z?a???????8???!??-??(?'?t??,d-#?5^?????0?v??=?*?w?6aC??r?Jp?E9??Q?F?;?` +U?D? +????????X?(?$?-???????)???IV?J }?U/?XW??1?E?+??????A??od??5Q/D?0?P*?Ke?x?u6lX?%??W?k??Da??^$7 &U???0?C?????:i?&???X??????????7%#\S???'?+6? ??r??%w???{G??*]?t>?AX$?} ??????+I?O?7 ?F???I%???w+?#???(b?u?S???w?Y_(???????!vM???????(???????@???>??;??|? ??<?L!??~D?d??C????gq?{y?+_Uyb3? ??u?F?]??\?gIS?MJ ?wqz +?%???:???BS?U2????????Q^K????- ?O$Ne??"??H??f?L??i?,$????@??K???;?oKb?<?[!? +T?R??G?J??b?^???{?Q:PR?5?? ?R??CA7PPZ??g?h\????d???9R????%????=?#????3 +??????m?o??F}YW???3 +G?L?V/?p=? +c?D?q#??B?H?a>????p?q ?????es????}+?N}B? OJ|?:`??p??W?!?N?yy?S%K,??wy?`C\??4???|?????;???l??R?]???x???a???0?;??w??c?5???ud?? ?$????_2??{?E??n +??Aw0n("???L"c\?|???%??? p%??G??_?l]2H?0N?Q??x6;???86:?B)`L?\)???>.JC???6?l3};? ?q?????!`$#@%,D????:J-I J4:??S*?Z2?<_? %~?P?0??G9????N)?s?1???.?p??K(??? k??~w?)??nbt+?Cx99???5???#?tB?`????!l??@?A?&?r$?????wI2?x?95?d04???|??R??E$?????????Y1?X?pb?#???$|?6Da0p?l +.?V?+?l??2??qM ?nA??)?)???? ?? ++????????O:?BPw$?&??!?z??"???]??U??0?}??>?P??????rZ?&?I?????u?/?F?Y?cq?M???1??? ?B+`??>?H?z W?n4??y?7t?6??&{????;8??R7?pZi?0/'??_s?5??%\T?9o??? 61 ??B?V??fg?-G?-?0hFB2?o?TQ??Q???v?\?-????M7??/?r??z?????/R??D?%??A?:??!`?@[1? ????j?/D???????|?? +l +EA??'aI????c?w???b? +??!`?@?h+ (?v +C?0?????m??"??? ??!C??u???r????Z??11????T~ ???yx?v?}??JW|d?`GY ?q?l???J?gb? +,S?_~?Zla?F?b_?x%???s??7??r?l?4??9??!`???uAV??@ebi?:t??y???K??x?(|?A ?o?~????Q9???`?M7??j?z?r{??u+_?in???R6iC??:???&O???3c???_?b?'???vq??%~?s?9G??????Y??d?agn?.? +?0 ?t?p??@????????<W]uU??j??W\?Q???hS???Zw?%?8 +?B???:?????\s5?t?k? +? ???!`?"?U +X@???zH??)???A?"?????^????'???.*5??F??o>U????; K???/?*cZw?u; p??!`?@W*`?u???K/??=???#F????^[?k??w^??=?)P???????*4??S?a???S??"??sC6 i??0 ???z,%?????}???5xB?- IDAT? ??B??9????1???,o???????l???????g???_}?U4???#n? +p'???&?? .???:Xm??lM??0 ??????????+?EP?? 2? }????o,f|????N?&?x??&?????E,????o????B???j??J?Z?n)9E????[.qW????v??0 ?^0??  +???X?e#X?&1I(gXs(????U6?D??>}?`F????>sp????{??}?N ???: +iPPg?qF?&bI$!?[??????6oC?h7L+???0?? +nL?1???R??????c???I(e??;n?g?q???s.8b?8??F]r????~r?Y?P?0q??o??????o??_? +? !y!>!??\???_???N???]?h??m? +Y?? +?0 ????)`m?Pl>????jDy?O?????P,pN??Vi?(f?d??P?b?PQ?&?d???E?2P??|????q??E???37d?????!`4S???x ??[?P?P??RA2?r???`? +??Z?9??c?U?nP???????q?Z~??7???g?l[?gn??\6?!`t??u??w?t/??Md?|??;u?5????5?e'??!?tFlz???!??????z???e?]?C?????k??8h??[n???&d#6 C??0???[?C?t +?o?????+??V?y?V,???&??!`?E????o?g?@??B 5MM C?0Z??)`???z??8?*A??????fn? 7?5e?@???1??\k??c?? 2?????5*@???,?"? C????)`?5:????????VX?=???3?Z&bn?Z??s +C?h.??5o?-G??=????+j1?nsCv???? +C?0?V??? +?r X??????????j??N27d'????0: S?:i5?|.I? ???.??{???? +%sCv?r?d +C??0?????;?)`\??W_?e?YF ?w????V??j???)`??R6???? ???S????]??????? C?h:??5r?0/?-`PQ?e??????(a p???n^C)T???,?r?` C?PL???1TsA~???????w'?x??%????????6sCv?2?$ +C??0?????;ql?FH???n?QGu?n??????????????\e?U?i?!;~?m???!P@L+?????C`? '? '?h"w???Wl????/??X}?(?U??,???? C??0????cg