From noreply at r-forge.r-project.org Thu Dec 4 15:54:07 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 4 Dec 2014 15:54:07 +0100 (CET) Subject: [Pomp-commits] r1012 - in www: content vignettes Message-ID: <20141204145407.6CE8E1876C8@r-forge.r-project.org> Author: kingaa Date: 2014-12-04 15:54:07 +0100 (Thu, 04 Dec 2014) New Revision: 1012 Modified: www/content/NEWS.html www/vignettes/advanced_topics_in_pomp.pdf www/vignettes/plugin-C-code.rda www/vignettes/plugin-R-code.rda www/vignettes/pomp.pdf www/vignettes/vectorized-C-code.rda www/vignettes/vectorized-R-code.rda Log: - update NEWS and advanced topics vignette Modified: www/content/NEWS.html =================================================================== --- www/content/NEWS.html 2014-09-23 19:23:13 UTC (rev 1011) +++ www/content/NEWS.html 2014-12-04 14:54:07 UTC (rev 1012) @@ -8,6 +8,19 @@

News for package ‘pomp’

+

Changes in pomp version 0.54-1

+ + + + + +

Changes in pomp version 0.53-6

Modified: www/vignettes/advanced_topics_in_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/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 Thu Dec 4 15:55:36 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 4 Dec 2014 15:55:36 +0100 (CET) Subject: [Pomp-commits] r1013 - pkg/pomp pkg/pomp/R pkg/pomp/man www/vignettes Message-ID: <20141204145536.2D5AC1876C8@r-forge.r-project.org> Author: kingaa Date: 2014-12-04 15:55:35 +0100 (Thu, 04 Dec 2014) New Revision: 1013 Modified: pkg/pomp/DESCRIPTION pkg/pomp/NAMESPACE pkg/pomp/R/generics.R pkg/pomp/R/probe.R pkg/pomp/man/probed-pomp-methods.Rd 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/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 Log: - add 'values' method for 'probed.pomp' objects - fix DESCRIPTION file Modified: pkg/pomp/DESCRIPTION =================================================================== --- pkg/pomp/DESCRIPTION 2014-12-04 14:54:07 UTC (rev 1012) +++ pkg/pomp/DESCRIPTION 2014-12-04 14:55:35 UTC (rev 1013) @@ -1,8 +1,8 @@ Package: pomp Type: Package -Title: Statistical inference for partially observed Markov processes -Version: 0.54-1 -Date: 2014-09-23 +Title: Statistical Inference for Partially Observed Markov Processes +Version: 0.55-1 +Date: 2014-12-03 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")), @@ -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 +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 2014-12-04 14:54:07 UTC (rev 1012) +++ pkg/pomp/NAMESPACE 2014-12-04 14:55:35 UTC (rev 1013) @@ -64,6 +64,7 @@ eff.sample.size,cond.logLik, particles,mif,continue,states,trajectory, pred.mean,pred.var,filter.mean,conv.rec, + values, bsmc2,bsmc,pmcmc,abc,nlf, traj.match.objfun, probe.match.objfun, Modified: pkg/pomp/R/generics.R =================================================================== --- pkg/pomp/R/generics.R 2014-12-04 14:54:07 UTC (rev 1012) +++ pkg/pomp/R/generics.R 2014-12-04 14:55:35 UTC (rev 1013) @@ -45,6 +45,8 @@ setGeneric("eff.sample.size",function(object,...)standardGeneric("eff.sample.size")) ## convergence record setGeneric("conv.rec",function(object,...)standardGeneric("conv.rec")) +## values of probes +setGeneric("values",function(object,...)standardGeneric("values")) ## stochastic simulation setGeneric("simulate",function(object,nsim=1,seed=NULL,...)standardGeneric("simulate")) Modified: pkg/pomp/R/probe.R =================================================================== --- pkg/pomp/R/probe.R 2014-12-04 14:54:07 UTC (rev 1012) +++ pkg/pomp/R/probe.R 2014-12-04 14:55:35 UTC (rev 1013) @@ -208,3 +208,13 @@ setMethod("logLik",signature(object="probed.pomp"),function(object,...)object at synth.loglik) setMethod("$",signature=signature(x="probed.pomp"),function(x, name)slot(x,name)) + +values.probe.internal <- function (object, ...) { + x <- as.data.frame(rbind(object at datvals,object at simvals)) + row.names(x) <- seq.int(from=0,to=nrow(x)-1) + x$.id <- factor(c("data",rep("sim",nrow(x)-1))) + x +} + +setMethod("values",signature(object="probed.pomp"), + definition=values.probe.internal) Modified: pkg/pomp/man/probed-pomp-methods.Rd =================================================================== --- pkg/pomp/man/probed-pomp-methods.Rd 2014-12-04 14:54:07 UTC (rev 1012) +++ pkg/pomp/man/probed-pomp-methods.Rd 2014-12-04 14:55:35 UTC (rev 1013) @@ -8,6 +8,11 @@ \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} @@ -37,6 +42,7 @@ \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), @@ -70,6 +76,10 @@ \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. 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 2014-12-04 14:54:07 UTC (rev 1012) +++ www/vignettes/intro_to_pomp.R 2014-12-04 14:55:35 UTC (rev 1013) @@ -271,7 +271,6 @@ ## ----gompertz-perform,eval=F,echo=T-------------------------------------- -## ## tic <- Sys.time() ## sim1 <- simulate(gompertz,nsim=1000,seed=5676868L,obs=TRUE) ## toc <- Sys.time() @@ -295,7 +294,6 @@ ## g2pf <- toc-tic ## ## stopifnot(all.equal(logLik(pf1),logLik(pf2))) -## ## ----gompertz-perform-eval,eval=T,echo=F--------------------------------- binary.file <- "gompertz-performance.rda" @@ -303,7 +301,6 @@ load(binary.file) } else { set.seed(457645443L) - tic <- Sys.time() sim1 <- simulate(gompertz,nsim=1000,seed=5676868L,obs=TRUE) toc <- Sys.time() @@ -327,7 +324,6 @@ g2pf <- toc-tic stopifnot(all.equal(logLik(pf1),logLik(pf2))) - save(g1sim,g2sim,g1pf,g2pf,file=binary.file,compress='xz') } @@ -1256,9 +1252,9 @@ ## ----bsmc-example-flat-prior-3,eval=F------------------------------------ -## fit1 <- bsmc(ricker,Np=10000,transform=TRUE, -## est=c("r","sigma"),smooth=0.2, -## seed=1050180387L) +## fit1 <- bsmc2(ricker,Np=10000,transform=TRUE, +## est=c("r","sigma"),smooth=0.2, +## seed=1050180387L) ## ----bsmc-example-flat-prior-eval,eval=T,echo=F-------------------------- binary.file <- "bsmc-ricker-flat-prior.rda" @@ -1275,9 +1271,9 @@ params } ) - fit1 <- bsmc(ricker,Np=10000,transform=TRUE, - est=c("r","sigma"),smooth=0.2, - seed=1050180387L) + fit1 <- bsmc2(ricker,Np=10000,transform=TRUE, + est=c("r","sigma"),smooth=0.2, + seed=1050180387L) save(fit1,file=binary.file,compress="xz") } @@ -1299,9 +1295,9 @@ ## } ## ) ## -## fit2 <- bsmc(ricker,transform=TRUE,Np=10000, -## est=c("r","sigma"),smooth=0.2, -## seed=90348704L) +## fit2 <- bsmc2(ricker,transform=TRUE,Np=10000, +## est=c("r","sigma"),smooth=0.2, +## seed=90348704L) ## ## ----bsmc-example-normal-prior-eval,eval=T,echo=F------------------------ @@ -1317,9 +1313,9 @@ } ) -fit2 <- bsmc(ricker,transform=TRUE,Np=10000, - est=c("r","sigma"),smooth=0.2, - seed=90348704L) +fit2 <- bsmc2(ricker,transform=TRUE,Np=10000, + est=c("r","sigma"),smooth=0.2, + seed=90348704L) save(fit2,file=binary.file,compress="xz") } Modified: www/vignettes/intro_to_pomp.Rnw =================================================================== --- www/vignettes/intro_to_pomp.Rnw 2014-12-04 14:54:07 UTC (rev 1012) +++ www/vignettes/intro_to_pomp.Rnw 2014-12-04 14:55:35 UTC (rev 1013) @@ -563,7 +563,6 @@ Let's compare the performance of \code{gompertz} and \code{gomp2}. <>= - tic <- Sys.time() sim1 <- simulate(gompertz,nsim=1000,seed=5676868L,obs=TRUE) toc <- Sys.time() @@ -587,7 +586,6 @@ g2pf <- toc-tic stopifnot(all.equal(logLik(pf1),logLik(pf2))) - @ <>= binary.file <- "gompertz-performance.rda" @@ -1519,9 +1517,9 @@ %%\citet{Ellner1998,Kendall1999} \clearpage -\section{Bayesian sequential Monte Carlo: \code{bsmc}} +\section{Bayesian sequential Monte Carlo: \code{bsmc2}} -The approximate Bayesian sequential Monte Carlo method of \citet{Liu2001b} is implemented in \pkg{pomp}. +A modified version of the approximate Bayesian sequential Monte Carlo method of \citet{Liu2001b} is implemented in \pkg{pomp}. The following demonstrates its use on the Ricker model. First, we'll specify a prior distribution. @@ -1544,9 +1542,9 @@ The following runs the Bayesian sequential Monte Carlo algorithm with 10,000 particles. Note that, by specifying \code{transform=TRUE}, we cause the estimation to proceed on the transformed scale. <>= - fit1 <- bsmc(ricker,Np=10000,transform=TRUE, - est=c("r","sigma"),smooth=0.2, - seed=1050180387L) + fit1 <- bsmc2(ricker,Np=10000,transform=TRUE, + est=c("r","sigma"),smooth=0.2, + seed=1050180387L) @ <>= binary.file <- "bsmc-ricker-flat-prior.rda" @@ -1570,7 +1568,7 @@ plot(fit1,pars=c("r","sigma"),thin=5000) @ \caption{ - Results of \code{bsmc} on the Ricker model. + Results of \code{bsmc2} on the Ricker model. The off-diagonal panels show 5000 samples from the prior (grey) and posterior (blue) distributions. The diagonal panels show kernel density estimates of the marginal prior and posterior distributions for each of the parameters. Note that these are shown on the natural scale. @@ -1589,9 +1587,9 @@ } ) -fit2 <- bsmc(ricker,transform=TRUE,Np=10000, - est=c("r","sigma"),smooth=0.2, - seed=90348704L) +fit2 <- bsmc2(ricker,transform=TRUE,Np=10000, + est=c("r","sigma"),smooth=0.2, + seed=90348704L) <>= binary.file <- "bsmc-ricker-normal-prior.rda" 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/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) From noreply at r-forge.r-project.org Fri Dec 5 18:44:13 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 5 Dec 2014 18:44:13 +0100 (CET) Subject: [Pomp-commits] r1014 - in pkg/pomp: inst inst/include src Message-ID: <20141205174413.8ECBD1876DB@r-forge.r-project.org> Author: kingaa Date: 2014-12-05 18:44:13 +0100 (Fri, 05 Dec 2014) New Revision: 1014 Modified: pkg/pomp/inst/NEWS.Rd pkg/pomp/inst/include/pomp.h pkg/pomp/src/pomp.h Log: - improve documentation in 'pomp.h' - updated NEWS Modified: pkg/pomp/inst/NEWS.Rd =================================================================== --- pkg/pomp/inst/NEWS.Rd 2014-12-04 14:55:35 UTC (rev 1013) +++ pkg/pomp/inst/NEWS.Rd 2014-12-05 17:44:13 UTC (rev 1014) @@ -1,5 +1,12 @@ \name{NEWS} \title{News for package `pomp'} +\section{Changes in \pkg{pomp} version 0.55-1}{ + \itemize{ + \item New \code{values} method extracts simulated probe values on \code{probed.pomp} object. + \item Better documentation in the \file{pomp.h} header file. + \item Vignettes now feature \code{bsmc2} instead of \code{bsmc}. + } +} \section{Changes in \pkg{pomp} version 0.54-1}{ \itemize{ \item A modified version of the Liu and West (2001) algorithm is included as \code{bsmc2}. Modified: pkg/pomp/inst/include/pomp.h =================================================================== --- pkg/pomp/inst/include/pomp.h 2014-12-04 14:55:35 UTC (rev 1013) +++ pkg/pomp/inst/include/pomp.h 2014-12-05 17:44:13 UTC (rev 1014) @@ -187,8 +187,8 @@ // on input: // p = pointer to parameter vector // give_log = should the log likelihood be returned? -// parindex = pointer to vector of integers indexing the parameters in 'p' in the order specified by -// the 'paramnames' slot +// parindex = pointer to vector of integers indexing the parameters +// in 'p' in the order specified by the 'paramnames' slot // on output: // lik = pointer to vector containing likelihoods @@ -239,11 +239,24 @@ // C-LEVEL DEFINITIONS OF EULER-MULTINOMIAL DISTRIBUTION FUNCTIONS -// simulate Euler-multinomial transitions +// reulermultinom: simulate Euler-multinomial transitions +// Description: +// on input: +// m = (positive integer) number of potential transitions ("deaths") +// size = (positive integer) number of individuals at risk +// rate = pointer to vector of transition ("death") rates +// dt = (positive real) duration of time interval +// on output: +// trans = pointer to vector containing the random deviates +// (numbers of individuals making the respective transitions) +// See '?reulermultinom' and vignettes for more on the Euler-multinomial +// distributions. +// // NB: 'reulermultinom' does not call GetRNGstate() and PutRNGstate() internally // this must be done by the calling program -// But note that when reulermultinom is called inside a pomp 'rprocess', there is no need to call -// {Get,Put}RNGState() as this is handled by pomp +// But note that when reulermultinom is called inside a pomp 'rprocess', +// there is no need to call {Get,Put}RNGState() as this is handled by pomp + static void reulermultinom (int m, double size, double *rate, double dt, double *trans) { double p = 0.0; @@ -278,7 +291,21 @@ } } -// COMPUTE PROBABILITIES OF EULER-MULTINOMIAL TRANSITIONS +// deulermultinom: probabilities of Euler-multinomial transitions +// Description: +// on input: +// m = (positive integer) number of potential transitions ("deaths") +// size = (positive integer) number of individuals at risk +// rate = pointer to vector of transition ("death") rates +// dt = (positive real) duration of time interval +// trans = pointer to vector containing the data +// (numbers of individuals making the respective transitions) +// give_log = 1 if log probability is desired; 0 if probability is desired +// return value: probability or log probability (as requested) +// +// See '?deulermultinom' and vignettes for more on the Euler-multinomial +// distributions. + static double deulermultinom (int m, double size, double *rate, double dt, double *trans, int give_log) { double p = 0.0; Modified: pkg/pomp/src/pomp.h =================================================================== --- pkg/pomp/src/pomp.h 2014-12-04 14:55:35 UTC (rev 1013) +++ pkg/pomp/src/pomp.h 2014-12-05 17:44:13 UTC (rev 1014) @@ -187,8 +187,8 @@ // on input: // p = pointer to parameter vector // give_log = should the log likelihood be returned? -// parindex = pointer to vector of integers indexing the parameters in 'p' in the order specified by -// the 'paramnames' slot +// parindex = pointer to vector of integers indexing the parameters +// in 'p' in the order specified by the 'paramnames' slot // on output: // lik = pointer to vector containing likelihoods @@ -239,11 +239,24 @@ // C-LEVEL DEFINITIONS OF EULER-MULTINOMIAL DISTRIBUTION FUNCTIONS -// simulate Euler-multinomial transitions +// reulermultinom: simulate Euler-multinomial transitions +// Description: +// on input: +// m = (positive integer) number of potential transitions ("deaths") +// size = (positive integer) number of individuals at risk +// rate = pointer to vector of transition ("death") rates +// dt = (positive real) duration of time interval +// on output: +// trans = pointer to vector containing the random deviates +// (numbers of individuals making the respective transitions) +// See '?reulermultinom' and vignettes for more on the Euler-multinomial +// distributions. +// // NB: 'reulermultinom' does not call GetRNGstate() and PutRNGstate() internally // this must be done by the calling program -// But note that when reulermultinom is called inside a pomp 'rprocess', there is no need to call -// {Get,Put}RNGState() as this is handled by pomp +// But note that when reulermultinom is called inside a pomp 'rprocess', +// there is no need to call {Get,Put}RNGState() as this is handled by pomp + static void reulermultinom (int m, double size, double *rate, double dt, double *trans) { double p = 0.0; @@ -278,7 +291,21 @@ } } -// COMPUTE PROBABILITIES OF EULER-MULTINOMIAL TRANSITIONS +// deulermultinom: probabilities of Euler-multinomial transitions +// Description: +// on input: +// m = (positive integer) number of potential transitions ("deaths") +// size = (positive integer) number of individuals at risk +// rate = pointer to vector of transition ("death") rates +// dt = (positive real) duration of time interval +// trans = pointer to vector containing the data +// (numbers of individuals making the respective transitions) +// give_log = 1 if log probability is desired; 0 if probability is desired +// return value: probability or log probability (as requested) +// +// See '?deulermultinom' and vignettes for more on the Euler-multinomial +// distributions. + static double deulermultinom (int m, double size, double *rate, double dt, double *trans, int give_log) { double p = 0.0; From noreply at r-forge.r-project.org Fri Dec 5 18:44:32 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 5 Dec 2014 18:44:32 +0100 (CET) Subject: [Pomp-commits] r1015 - pkg/pomp/inst www/content www/vignettes Message-ID: <20141205174432.B8A9E1876DB@r-forge.r-project.org> Author: kingaa Date: 2014-12-05 18:44:32 +0100 (Fri, 05 Dec 2014) New Revision: 1015 Modified: pkg/pomp/inst/NEWS www/content/NEWS.html www/vignettes/pomp.pdf Log: - update NEWS Modified: pkg/pomp/inst/NEWS =================================================================== --- pkg/pomp/inst/NEWS 2014-12-05 17:44:13 UTC (rev 1014) +++ pkg/pomp/inst/NEWS 2014-12-05 17:44:32 UTC (rev 1015) @@ -1,5 +1,14 @@ _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_5-_1: + + ? New ?values? method extracts simulated probe values on + ?probed.pomp? object. + + ? Better documentation in the ?pomp.h? header file. + + ? Vignettes now feature ?bsmc2? instead of ?bsmc?. + _C_h_a_n_g_e_s _i_n '_p_o_m_p' _v_e_r_s_i_o_n _0._5_4-_1: ? A modified version of the Liu and West (2001) algorithm is Modified: www/content/NEWS.html =================================================================== --- www/content/NEWS.html 2014-12-05 17:44:13 UTC (rev 1014) +++ www/content/NEWS.html 2014-12-05 17:44:32 UTC (rev 1015) @@ -8,6 +8,22 @@

News for package ‘pomp’

+

Changes in pomp version 0.55-1

+ + +
    +
  • New values method extracts simulated probe values on probed.pomp object. +

    +
  • +
  • Better documentation in the ‘pomp.h’ header file. +

    +
  • +
  • Vignettes now feature bsmc2 instead of bsmc. +

    +
+ + +

Changes in pomp version 0.54-1

Modified: www/vignettes/pomp.pdf =================================================================== (Binary files differ) From noreply at r-forge.r-project.org Wed Dec 10 18:12:09 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 10 Dec 2014 18:12:09 +0100 (CET) Subject: [Pomp-commits] r1016 - in pkg/pomp: . inst/examples src Message-ID: <20141210171209.448A41833BB@r-forge.r-project.org> Author: kingaa Date: 2014-12-10 18:12:08 +0100 (Wed, 10 Dec 2014) New Revision: 1016 Added: pkg/pomp/inst/examples/parus.R pkg/pomp/src/parus.c Modified: pkg/pomp/DESCRIPTION Log: - add Parus major example codes Modified: pkg/pomp/DESCRIPTION =================================================================== --- pkg/pomp/DESCRIPTION 2014-12-05 17:44:32 UTC (rev 1015) +++ pkg/pomp/DESCRIPTION 2014-12-10 17:12:08 UTC (rev 1016) @@ -1,8 +1,8 @@ Package: pomp Type: Package Title: Statistical Inference for Partially Observed Markov Processes -Version: 0.55-1 -Date: 2014-12-03 +Version: 0.55-2 +Date: 2014-12-10 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")), Added: pkg/pomp/inst/examples/parus.R =================================================================== --- pkg/pomp/inst/examples/parus.R (rev 0) +++ pkg/pomp/inst/examples/parus.R 2014-12-10 17:12:08 UTC (rev 1016) @@ -0,0 +1,74 @@ +require(pomp) + +dat <- 'year,pop +1960,148 +1961,258 +1962,185 +1963,170 +1964,267 +1965,239 +1966,196 +1967,132 +1968,167 +1969,186 +1970,128 +1971,227 +1972,174 +1973,177 +1974,137 +1975,172 +1976,119 +1977,226 +1978,166 +1979,161 +1980,199 +1981,306 +1982,206 +1983,350 +1984,214 +1985,175 +1986,211 +' + +dat <- read.csv(text=dat) + +pomp( + data=dat, + times="year", + t0=1960, + params=c(K=190,r=2.7,sigma=0.2,tau=0.05,N.0=148), + rprocess=discrete.time.sim( + step.fun="_parus_gompertz_simulator" + ), + rmeasure="_parus_lognormal_rmeasure", + dmeasure="_parus_lognormal_dmeasure", + skeleton="_parus_gompertz_skeleton", + skeleton.type="map", + paramnames=c("r","K","sigma","tau"), + statenames=c("N"), + obsnames=c("pop"), + parameter.transform=function(params,...){ + exp(params) + }, + parameter.inv.transform=function(params,...){ + log(params) + } + ) -> parusG + +pomp( + parusG, + rprocess=discrete.time.sim( + step.fun="_parus_ricker_simulator" + ), + rmeasure="_parus_poisson_rmeasure", + dmeasure="_parus_poisson_dmeasure", + skeleton="_parus_ricker_skeleton", + skeleton.type="map", +# paramnames=c("r","K","sigma","tau"), +# statenames=c("N"), +# obsnames=c("pop"), + PACKAGE="pomp" + ) -> parusR + +c("parusG","parusR") + Added: pkg/pomp/src/parus.c =================================================================== --- pkg/pomp/src/parus.c (rev 0) +++ pkg/pomp/src/parus.c 2014-12-10 17:12:08 UTC (rev 1016) @@ -0,0 +1,75 @@ +// dear emacs, please treat this as -*- C++ -*- + +#include + +#include "pomp.h" + +#define R (p[parindex[0]]) // growth rate +#define K (p[parindex[1]]) // carrying capacity +#define SIGMA (p[parindex[2]]) // process noise level +#define TAU (p[parindex[3]]) // measurement noise level + +#define POP (y[obsindex[0]]) +#define N (x[stateindex[0]]) +#define NPRIME (f[stateindex[0]]) + +void _parus_lognormal_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) { + *lik = dlnorm(POP,log(N),TAU,give_log); +} + +void _parus_lognormal_rmeasure (double *y, double *x, double *p, + int *obsindex, int *stateindex, int *parindex, int *covindex, + int ncovars, double *covars, double t) { + POP = rlnorm(log(N),TAU); +} + +void _parus_poisson_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) { + *lik = dpois(POP,N,give_log); +} + +void _parus_poisson_rmeasure (double *y, double *x, double *p, + int *obsindex, int *stateindex, int *parindex, int *covindex, + int ncovars, double *covars, double t) { + POP = rpois(N); +} + +void _parus_gompertz_simulator (double *x, const double *p, + const int *stateindex, const int *parindex, const int *covindex, + int covdim, const double *covar, + double t, double dt) +{ + double S = exp(-R*dt); + double eps = (SIGMA > 0.0) ? exp(rnorm(0,SIGMA)) : 1.0; + N = pow(K,(1-S))*pow(N,S)*eps; +} + +// the deterministic skeleton +void _parus_gompertz_skeleton (double *f, double *x, const double *p, + const int *stateindex, const int *parindex, const int *covindex, + int covdim, const double *covar, double t) +{ + double dt = 1.0; + double S = exp(-R*dt); + NPRIME = pow(K,(1-S))*pow(N,S); +} + +// Ricker model with log-normal process noise +void _parus_ricker_simulator (double *x, const double *p, + const int *stateindex, const int *parindex, const int *covindex, + int covdim, const double *covar, + double t, double dt) +{ + double e = (SIGMA > 0.0) ? rnorm(0,SIGMA) : 0.0; + N = exp(log(N)+R*(1-N/K)+e); +} + +void _parus_ricker_skeleton (double *f, double *x, const double *p, + const int *stateindex, const int *parindex, const int *covindex, + int covdim, const double *covar, double t) +{ + NPRIME = exp(log(N)+R*(1-N/K)); +} From noreply at r-forge.r-project.org Wed Dec 10 18:12:15 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 10 Dec 2014 18:12:15 +0100 (CET) Subject: [Pomp-commits] r1017 - pkg/pomp/inst/examples Message-ID: <20141210171215.27E581833BB@r-forge.r-project.org> Author: kingaa Date: 2014-12-10 18:12:14 +0100 (Wed, 10 Dec 2014) New Revision: 1017 Modified: pkg/pomp/inst/examples/parus.R Log: - fix error in parusR Modified: pkg/pomp/inst/examples/parus.R =================================================================== --- pkg/pomp/inst/examples/parus.R 2014-12-10 17:12:08 UTC (rev 1016) +++ pkg/pomp/inst/examples/parus.R 2014-12-10 17:12:14 UTC (rev 1017) @@ -64,9 +64,9 @@ dmeasure="_parus_poisson_dmeasure", skeleton="_parus_ricker_skeleton", skeleton.type="map", -# paramnames=c("r","K","sigma","tau"), -# statenames=c("N"), -# obsnames=c("pop"), + paramnames=c("r","K","sigma","tau"), + statenames=c("N"), + obsnames=c("pop"), PACKAGE="pomp" ) -> parusR From noreply at r-forge.r-project.org Wed Dec 17 16:45:49 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 17 Dec 2014 16:45:49 +0100 (CET) Subject: [Pomp-commits] r1018 - in pkg/pomp: . R inst inst/examples man src Message-ID: <20141217154549.17F17186967@r-forge.r-project.org> Author: kingaa Date: 2014-12-17 16:45:48 +0100 (Wed, 17 Dec 2014) New Revision: 1018 Removed: pkg/pomp/inst/examples/parus.R pkg/pomp/src/parus.c Modified: pkg/pomp/DESCRIPTION pkg/pomp/R/aaa.R pkg/pomp/R/example.R pkg/pomp/inst/NEWS pkg/pomp/inst/NEWS.Rd pkg/pomp/man/example.Rd Log: - revamp pompExample facility Modified: pkg/pomp/DESCRIPTION =================================================================== --- pkg/pomp/DESCRIPTION 2014-12-10 17:12:14 UTC (rev 1017) +++ pkg/pomp/DESCRIPTION 2014-12-17 15:45:48 UTC (rev 1018) @@ -1,8 +1,8 @@ Package: pomp Type: Package Title: Statistical Inference for Partially Observed Markov Processes -Version: 0.55-2 -Date: 2014-12-10 +Version: 0.56-1 +Date: 2014-12-16 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/aaa.R =================================================================== --- pkg/pomp/R/aaa.R 2014-12-10 17:12:14 UTC (rev 1017) +++ pkg/pomp/R/aaa.R 2014-12-17 15:45:48 UTC (rev 1018) @@ -1,10 +1,12 @@ -## .onAttach <- function (...) { -## version <- library(help=pomp)$info[[1L]] -## version <- strsplit(version[pmatch("Version",version)]," ")[[1L]] -## version <- version[nchar(version)>0][2L] -## packageStartupMessage("This is pomp version ",version,"\n") -## } +.onAttach <- function (...) { + exampleDir <- getOption("pomp.examples") + pompExampleDir <- system.file("examples",package="pomp") + options(pomp.examples=c(exampleDir,pompExampleDir,recursive=TRUE)) +} -if (!exists("paste0",where="package:base")) { - paste0 <- function(...) paste(...,sep="") +.onDetach <- function (...) { + exampleDir <- getOption("pomp.examples") + pompExampleDir <- system.file("examples",package="pomp") + exampleDir <- exampleDir[exampleDir!=pompExampleDir] + options(pomp.examples=exampleDir) } Modified: pkg/pomp/R/example.R =================================================================== --- pkg/pomp/R/example.R 2014-12-10 17:12:14 UTC (rev 1017) +++ pkg/pomp/R/example.R 2014-12-17 15:45:48 UTC (rev 1018) @@ -1,22 +1,38 @@ -pompExample <- function (example, envir = .GlobalEnv) { +pompExample <- function (example, ..., envir = .GlobalEnv) { example <- as.character(substitute(example)) + pomp.dir <- system.file("examples",package="pomp") + exampleDirs <- getOption("pomp.examples",default=pomp.dir) + names(exampleDirs) <- exampleDirs if (example=="") { - avlbl <- list.files( - path=system.file("examples",package="pomp"), - pattern=".+?R$" - ) - avlbl <- gsub("\\.R$","",avlbl) - avlbl + avlbl <- lapply(exampleDirs,list.files,pattern=".+?R$") + avlbl <- lapply(avlbl,function(x) gsub("\\.R$","",x)) + for (dir in exampleDirs) { + cat("examples in ",dir,":\n",sep="") + print(avlbl[[dir]]) + } } else { - file <- system.file( - file.path("examples",paste(example,".R",sep="")), - package="pomp" - ) - objs <- source(file,local=TRUE) - for (i in seq_along(objs$value)) { - assign(objs$value[i],get(objs$value[i]),envir=envir) + evalEnv <- list2env(list(...)) + file <- c(lapply(exampleDirs,list.files, + pattern=paste0(example,".R"), + full.names=TRUE), + recursive=TRUE) + if (length(file)>1) { + warning("using ",sQuote(file[1])," from ",sQuote(names(file)[1])) } - cat("newly created pomp object(s):\n",objs$value,"\n") - invisible(NULL) + objs <- source(file[1],local=evalEnv) + if (is.null(envir)) { + obj <- setNames(lapply(objs$value,get,envir=evalEnv),objs$value) + } else if (is.environment(envir)) { + for (i in seq_along(objs$value)) { + assign(objs$value[i], + get(objs$value[i],envir=evalEnv), + envir=envir) + } + cat("newly created pomp object(s):\n",objs$value,"\n") + obj <- NULL + } else { + stop(sQuote("envir")," must be an environment or NULL") + } + invisible(obj) } } Modified: pkg/pomp/inst/NEWS =================================================================== --- pkg/pomp/inst/NEWS 2014-12-10 17:12:14 UTC (rev 1017) +++ pkg/pomp/inst/NEWS 2014-12-17 15:45:48 UTC (rev 1018) @@ -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._5_6-_1: + + ? Revamped the ?pompExample? function. A search path for + example directories is now stored in global option + "pomp.examples". + _C_h_a_n_g_e_s _i_n '_p_o_m_p' _v_e_r_s_i_o_n _0._5_5-_1: ? New ?values? method extracts simulated probe values on Modified: pkg/pomp/inst/NEWS.Rd =================================================================== --- pkg/pomp/inst/NEWS.Rd 2014-12-10 17:12:14 UTC (rev 1017) +++ pkg/pomp/inst/NEWS.Rd 2014-12-17 15:45:48 UTC (rev 1018) @@ -1,5 +1,11 @@ \name{NEWS} \title{News for package `pomp'} +\section{Changes in \pkg{pomp} version 0.56-1}{ + \itemize{ + \item Revamped the \code{pompExample} function. + A search path for example directories is now stored in global option "pomp.examples". + } +} \section{Changes in \pkg{pomp} version 0.55-1}{ \itemize{ \item New \code{values} method extracts simulated probe values on \code{probed.pomp} object. Deleted: pkg/pomp/inst/examples/parus.R =================================================================== --- pkg/pomp/inst/examples/parus.R 2014-12-10 17:12:14 UTC (rev 1017) +++ pkg/pomp/inst/examples/parus.R 2014-12-17 15:45:48 UTC (rev 1018) @@ -1,74 +0,0 @@ -require(pomp) - -dat <- 'year,pop -1960,148 -1961,258 -1962,185 -1963,170 -1964,267 -1965,239 -1966,196 -1967,132 -1968,167 -1969,186 -1970,128 -1971,227 -1972,174 -1973,177 -1974,137 -1975,172 -1976,119 -1977,226 -1978,166 -1979,161 -1980,199 -1981,306 -1982,206 -1983,350 -1984,214 -1985,175 -1986,211 -' - -dat <- read.csv(text=dat) - -pomp( - data=dat, - times="year", - t0=1960, - params=c(K=190,r=2.7,sigma=0.2,tau=0.05,N.0=148), - rprocess=discrete.time.sim( - step.fun="_parus_gompertz_simulator" - ), - rmeasure="_parus_lognormal_rmeasure", - dmeasure="_parus_lognormal_dmeasure", - skeleton="_parus_gompertz_skeleton", - skeleton.type="map", - paramnames=c("r","K","sigma","tau"), - statenames=c("N"), - obsnames=c("pop"), - parameter.transform=function(params,...){ - exp(params) - }, - parameter.inv.transform=function(params,...){ - log(params) - } - ) -> parusG - -pomp( - parusG, - rprocess=discrete.time.sim( - step.fun="_parus_ricker_simulator" - ), - rmeasure="_parus_poisson_rmeasure", - dmeasure="_parus_poisson_dmeasure", - skeleton="_parus_ricker_skeleton", - skeleton.type="map", - paramnames=c("r","K","sigma","tau"), - statenames=c("N"), - obsnames=c("pop"), - PACKAGE="pomp" - ) -> parusR - -c("parusG","parusR") - Modified: pkg/pomp/man/example.Rd =================================================================== --- pkg/pomp/man/example.Rd 2014-12-10 17:12:14 UTC (rev 1017) +++ pkg/pomp/man/example.Rd 2014-12-17 15:45:48 UTC (rev 1018) @@ -5,26 +5,37 @@ \code{pompExample} loads pre-built example \code{pomp} objects. } \usage{ -pompExample(example, envir = .GlobalEnv) +pompExample(example, \dots, envir = .GlobalEnv) } \arguments{ \item{example}{ example to load given as a name or literal character string. Evoked without an argument, \code{pompExample} lists all available examples. } + \item{\dots}{ + additional arguments define symbols in the environment within which the example code is executed. + } \item{envir}{ the environment into which the objects should be loaded. + If \code{envir=NULL}, then the created objects are returned in a list. } } +\details{ + Directories in the the global option \code{pomp.examples} (set using \code{options()}) are searched for files named \file{example.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. +} \value{ - \code{pompExample} has the side effect of creating one or more \code{pomp} objects in the global workspace. + 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. } \author{Aaron A. King \email{kingaa at umich dot edu}} \examples{ pompExample() pompExample(euler.sir) pompExample("gompertz") - file.show(system.file("include/pomp.h",package="pomp")) + pompExample(ricker,envir=NULL) + file.show(system.file("examples/bbs.R",package="pomp")) } \seealso{ \code{\link{blowflies}}, \code{\link{dacca}}, \code{\link{gompertz}}, Deleted: pkg/pomp/src/parus.c =================================================================== --- pkg/pomp/src/parus.c 2014-12-10 17:12:14 UTC (rev 1017) +++ pkg/pomp/src/parus.c 2014-12-17 15:45:48 UTC (rev 1018) @@ -1,75 +0,0 @@ -// dear emacs, please treat this as -*- C++ -*- - -#include - -#include "pomp.h" - -#define R (p[parindex[0]]) // growth rate -#define K (p[parindex[1]]) // carrying capacity -#define SIGMA (p[parindex[2]]) // process noise level -#define TAU (p[parindex[3]]) // measurement noise level - -#define POP (y[obsindex[0]]) -#define N (x[stateindex[0]]) -#define NPRIME (f[stateindex[0]]) - -void _parus_lognormal_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) { - *lik = dlnorm(POP,log(N),TAU,give_log); -} - -void _parus_lognormal_rmeasure (double *y, double *x, double *p, - int *obsindex, int *stateindex, int *parindex, int *covindex, - int ncovars, double *covars, double t) { - POP = rlnorm(log(N),TAU); -} - -void _parus_poisson_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) { - *lik = dpois(POP,N,give_log); -} - -void _parus_poisson_rmeasure (double *y, double *x, double *p, - int *obsindex, int *stateindex, int *parindex, int *covindex, - int ncovars, double *covars, double t) { - POP = rpois(N); -} - -void _parus_gompertz_simulator (double *x, const double *p, - const int *stateindex, const int *parindex, const int *covindex, - int covdim, const double *covar, - double t, double dt) -{ - double S = exp(-R*dt); - double eps = (SIGMA > 0.0) ? exp(rnorm(0,SIGMA)) : 1.0; - N = pow(K,(1-S))*pow(N,S)*eps; -} - -// the deterministic skeleton -void _parus_gompertz_skeleton (double *f, double *x, const double *p, - const int *stateindex, const int *parindex, const int *covindex, - int covdim, const double *covar, double t) -{ - double dt = 1.0; - double S = exp(-R*dt); - NPRIME = pow(K,(1-S))*pow(N,S); -} - -// Ricker model with log-normal process noise -void _parus_ricker_simulator (double *x, const double *p, - const int *stateindex, const int *parindex, const int *covindex, - int covdim, const double *covar, - double t, double dt) -{ - double e = (SIGMA > 0.0) ? rnorm(0,SIGMA) : 0.0; - N = exp(log(N)+R*(1-N/K)+e); -} - -void _parus_ricker_skeleton (double *f, double *x, const double *p, - const int *stateindex, const int *parindex, const int *covindex, - int covdim, const double *covar, double t) -{ - NPRIME = exp(log(N)+R*(1-N/K)); -} From noreply at r-forge.r-project.org Wed Dec 17 20:12:01 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 17 Dec 2014 20:12:01 +0100 (CET) Subject: [Pomp-commits] r1019 - in pkg/pompExamples: . R inst inst/examples src tests Message-ID: <20141217191201.354EB183E26@r-forge.r-project.org> Author: kingaa Date: 2014-12-17 20:12:00 +0100 (Wed, 17 Dec 2014) New Revision: 1019 Added: pkg/pompExamples/R/aaa.R pkg/pompExamples/inst/examples/ pkg/pompExamples/inst/examples/bbp.R pkg/pompExamples/inst/examples/parus.R pkg/pompExamples/src/parus.c pkg/pompExamples/tests/examples.R Modified: pkg/pompExamples/DESCRIPTION pkg/pompExamples/inst/NEWS pkg/pompExamples/inst/NEWS.Rd pkg/pompExamples/tests/pertussis.Rout.save Log: - revamp the 'pompExample' facility to accept a path of directories in which to search - it is now possible to pass variables to the 'pompExample' scripts - move the 'parus' example to the pompExamples package - new "bbp" example for the Bombay plague outbreak of 1905-06. - pompExample can now return the objects as a list instead of creating them in a specified environment, if desired Modified: pkg/pompExamples/DESCRIPTION =================================================================== --- pkg/pompExamples/DESCRIPTION 2014-12-17 15:45:48 UTC (rev 1018) +++ pkg/pompExamples/DESCRIPTION 2014-12-17 19:12:00 UTC (rev 1019) @@ -1,8 +1,8 @@ Package: pompExamples Type: Package Title: Additional pomp examples -Version: 0.23-3 -Date: 2014-07-15 +Version: 0.24-1 +Date: 2014-12-16 Maintainer: Aaron A. King Authors at R: c(person(given=c("Aaron","A."),family="King",role=c("aut","cre"), email="kingaa at umich.edu"), @@ -21,4 +21,4 @@ License: GPL (>= 2) LazyData: false BuildVignettes: true -Collate: budmoth.R pertussis.R +Collate: aaa.R budmoth.R pertussis.R Added: pkg/pompExamples/R/aaa.R =================================================================== --- pkg/pompExamples/R/aaa.R (rev 0) +++ pkg/pompExamples/R/aaa.R 2014-12-17 19:12:00 UTC (rev 1019) @@ -0,0 +1,12 @@ +.onAttach <- function (...) { + exampleDir <- getOption("pomp.examples") + newDir <- system.file("examples",package="pompExamples") + options(pomp.examples=c(exampleDir,newDir,recursive=TRUE)) +} + +.onDetach <- function (...) { + exampleDir <- getOption("pomp.examples") + newDir <- system.file("examples",package="pompExamples") + exampleDir <- exampleDir[exampleDir!=newDir] + options(pomp.examples=exampleDir) +} Modified: pkg/pompExamples/inst/NEWS =================================================================== --- pkg/pompExamples/inst/NEWS 2014-12-17 15:45:48 UTC (rev 1018) +++ pkg/pompExamples/inst/NEWS 2014-12-17 19:12:00 UTC (rev 1019) @@ -1,5 +1,12 @@ _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_4-_1: + + ? Examples included in the package can now be accessed using + ?pomp?'s ?pompExample? function. + + ? New _Parus major_ example. + _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_3-_2: ? Update for use with ?pomp? version 0.50. Modified: pkg/pompExamples/inst/NEWS.Rd =================================================================== --- pkg/pompExamples/inst/NEWS.Rd 2014-12-17 15:45:48 UTC (rev 1018) +++ pkg/pompExamples/inst/NEWS.Rd 2014-12-17 19:12:00 UTC (rev 1019) @@ -1,5 +1,11 @@ \name{NEWS} \title{News for Package 'pompExamples'} +\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. + \item New \emph{Parus major} example. + } +} \section{Changes in \pkg{pompExamples} version 0.23-2}{ \itemize{ \item Update for use with \pkg{pomp} version 0.50. Added: pkg/pompExamples/inst/examples/bbp.R =================================================================== --- pkg/pompExamples/inst/examples/bbp.R (rev 0) +++ pkg/pompExamples/inst/examples/bbp.R 2014-12-17 19:12:00 UTC (rev 1019) @@ -0,0 +1,89 @@ +require(pomp) + +dat <- read.csv(text=' +## Deaths due to plague during an outbreak on the Island of Bombay +## over the period 17 Dec 1905 to 21 July 1906. +## From Kermack, W. O. & McKendrick, A. G. (1927) +## A Contribution to the Mathematical Theory of Epidemics +## Proceedings of the Royal Society of London, Series A, 115: 700--721. +## "date" is date of end of the week (Saturday) +"week","date","deaths" +1,1905-12-23,4 +2,1905-12-30,10 +3,1906-01-06,15 +4,1906-01-13,18 +5,1906-01-20,21 +6,1906-01-27,31 +7,1906-02-03,51 +8,1906-02-10,53 +9,1906-02-17,97 +10,1906-02-24,125 +11,1906-03-03,183 +12,1906-03-10,292 +13,1906-03-17,390 +14,1906-03-24,448 +15,1906-03-31,641 +16,1906-04-07,771 +17,1906-04-14,701 +18,1906-04-21,696 +19,1906-04-28,867 +20,1906-05-05,925 +21,1906-05-12,801 +22,1906-05-19,580 +23,1906-05-26,409 +24,1906-06-02,351 +25,1906-06-09,210 +26,1906-06-16,113 +27,1906-06-23,65 +28,1906-06-30,52 +29,1906-07-07,51 +30,1906-07-14,39 +31,1906-07-21,33 +',comment.char="#") + +pomp(data=subset(dat,select=c(week,deaths)), + times="week", + t0=0, + params=c( + beta=2,delta=1.5,y0=0.0004,theta=54, + sigma=0.02, + mu=0,gamma=0.2,ratio=10000 + ), + rprocess=euler.sim( + step.fun=Csnippet(" + double X = exp(x); + double Y = exp(y); + double dx, dy, dn, dW, ito; + dx = (mu*(1.0/X-1)+(delta-beta)*Y)*dt; + dy = (beta*X+delta*(Y-1)-gamma-mu)*dt; + dn = -delta*Y*dt; + dW = rnorm(0,sigma*sqrt(dt)); + ito = 0.5*sigma*sigma*dt; + x += dx - beta*Y*(dW-beta*Y*ito); + y += dy + beta*X*(dW+beta*X*ito); + n += dn; + " + ), + delta.t=1/24), + paramnames=c("beta","delta","mu","gamma","sigma","theta","ratio"), + statenames=c("x","y","n"), + measurement.model=deaths~nbinom(mu=ratio*exp(y),size=theta), + logvar=c("beta","delta","ratio","sigma","theta"), + logitvar=c("y0"), + parameter.inv.transform=function (params, logvar, logitvar, ...) { + params[logvar] <- log(params[logvar]) + params[logitvar] <- qlogis(params[logitvar]) + params + }, + parameter.transform=function (params, logvar, logitvar, ...) { + params[logvar] <- exp(params[logvar]) + params[logitvar] <- plogis(params[logitvar]) + params + }, + initializer=function(params, t0, ...) { + y0 <- unname(params["y0"]) + c(x=log(1-y0),y=log(y0),n=log(1)) + } + ) -> bbp + +c("bbp") Added: pkg/pompExamples/inst/examples/parus.R =================================================================== --- pkg/pompExamples/inst/examples/parus.R (rev 0) +++ pkg/pompExamples/inst/examples/parus.R 2014-12-17 19:12:00 UTC (rev 1019) @@ -0,0 +1,90 @@ +require(pomp) + +proc.avail <- c("Gompertz","Ricker") +meas.avail <- c("lognormal","Poisson","negbin") + +if (!exists("proc",where=environment())) + stop("choose a process model: proc = ",sQuote(proc.avail)) +if (!exists("meas",where=environment())) + stop("choose a measurement model: meas = ",sQuote(meas.avail)) + +proc <- proc.avail[pmatch(proc,proc.avail)] +meas <- meas.avail[pmatch(meas,meas.avail)] + +dat <- 'year,pop +1960,148 +1961,258 +1962,185 +1963,170 +1964,267 +1965,239 +1966,196 +1967,132 +1968,167 +1969,186 +1970,128 +1971,227 +1972,174 +1973,177 +1974,137 +1975,172 +1976,119 +1977,226 +1978,166 +1979,161 +1980,199 +1981,306 +1982,206 +1983,350 +1984,214 +1985,175 +1986,211 +' + +dat <- read.csv(text=dat) + +pomp( + data=dat, + times="year", + t0=1960, + params=c(K=190,r=2.7,sigma=0.2,theta=0.05,N.0=148), + rprocess=discrete.time.sim( + step.fun=switch(proc, + Gompertz="_parus_gompertz_simulator", + Ricker="_parus_ricker_simulator", + stop("unrecognized value of ",sQuote("proc")) + ), + delta.t=1 + ), + skeleton=switch(proc, + Gompertz="_parus_gompertz_skeleton", + Ricker="_parus_ricker_skeleton", + stop("unrecognized value of ",sQuote("proc")) + ), + skeleton.type="map", + skelmap.delta.t=1, + rmeasure=switch(meas, + lognormal="_parus_lognormal_rmeasure", + Poisson="_parus_poisson_rmeasure", + negbin="_parus_nbinom_rmeasure", + stop("unrecognized value of ",sQuote("meas")) + ), + dmeasure=switch(meas, + lognormal="_parus_lognormal_dmeasure", + Poisson="_parus_poisson_dmeasure", + negbin="_parus_nbinom_dmeasure", + stop("unrecognized value of ",sQuote("meas")) + ), + paramnames=c("r","K","sigma","theta"), + statenames=c("N"), + obsnames=c("pop"), + parameter.transform=function(params,...){ + exp(params) + }, + parameter.inv.transform=function(params,...){ + log(params) + }, + PACKAGE="pompExamples" + ) -> parus + +c("parus") Added: pkg/pompExamples/src/parus.c =================================================================== --- pkg/pompExamples/src/parus.c (rev 0) +++ pkg/pompExamples/src/parus.c 2014-12-17 19:12:00 UTC (rev 1019) @@ -0,0 +1,87 @@ +// dear emacs, please treat this as -*- C++ -*- + +#include + +#include "pomp.h" + +#define R (p[parindex[0]]) // growth rate +#define K (p[parindex[1]]) // carrying capacity +#define SIGMA (p[parindex[2]]) // process noise level +#define THETA (p[parindex[3]]) // measurement noise level + +#define POP (y[obsindex[0]]) +#define N (x[stateindex[0]]) +#define NPRIME (f[stateindex[0]]) + +void _parus_lognormal_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) { + *lik = dlnorm(POP,log(N),THETA,give_log); +} + +void _parus_lognormal_rmeasure (double *y, double *x, double *p, + int *obsindex, int *stateindex, int *parindex, int *covindex, + int ncovars, double *covars, double t) { + POP = rlnorm(log(N),THETA); +} + +void _parus_poisson_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) { + *lik = dpois(POP,N+1.0e-10,give_log); +} + +void _parus_poisson_rmeasure (double *y, double *x, double *p, + int *obsindex, int *stateindex, int *parindex, int *covindex, + int ncovars, double *covars, double t) { + POP = rpois(N+1.0e-10); +} + +void _parus_nbinom_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) { + *lik = dnbinom_mu(POP,1.0/THETA,N+1.0e-10,give_log); +} + +void _parus_nbinom_rmeasure (double *y, double *x, double *p, + int *obsindex, int *stateindex, int *parindex, int *covindex, + int ncovars, double *covars, double t) { + POP = rnbinom_mu(1.0/THETA,N+1.0e-10); +} + +void _parus_gompertz_simulator (double *x, const double *p, + const int *stateindex, const int *parindex, const int *covindex, + int covdim, const double *covar, + double t, double dt) +{ + double S = exp(-R*dt); + double eps = (SIGMA > 0.0) ? exp(rnorm(0,SIGMA)) : 1.0; + N = pow(K,(1-S))*pow(N,S)*eps; +} + +// the deterministic skeleton +void _parus_gompertz_skeleton (double *f, double *x, const double *p, + const int *stateindex, const int *parindex, const int *covindex, + int covdim, const double *covar, double t) +{ + double dt = 1.0; + double S = exp(-R*dt); + NPRIME = pow(K,(1-S))*pow(N,S); +} + +// Ricker model with log-normal process noise +void _parus_ricker_simulator (double *x, const double *p, + const int *stateindex, const int *parindex, const int *covindex, + int covdim, const double *covar, + double t, double dt) +{ + double e = (SIGMA > 0.0) ? rnorm(0,SIGMA) : 0.0; + N = exp(log(N)+R*(1-N/K)+e); +} + +void _parus_ricker_skeleton (double *f, double *x, const double *p, + const int *stateindex, const int *parindex, const int *covindex, + int covdim, const double *covar, double t) +{ + NPRIME = exp(log(N)+R*(1-N/K)); +} Added: pkg/pompExamples/tests/examples.R =================================================================== --- pkg/pompExamples/tests/examples.R (rev 0) +++ pkg/pompExamples/tests/examples.R 2014-12-17 19:12:00 UTC (rev 1019) @@ -0,0 +1,28 @@ +library(pompExamples) + +## pdf.options(useDingbats=FALSE) +## pdf(file="examples.pdf") + +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) + +po <- pompExample(parus,proc="Ricker",meas="negbin",envir=NULL) +pf <- pfilter(simulate(po$parus),Np=100,max.fail=Inf) + +po <- pompExample(parus,proc="Ricker",meas="Poisson",envir=NULL) +pf <- pfilter(simulate(po$parus),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 <- pompExample(parus,proc="Gompertz",meas="lognormal",envir=NULL) +pf <- pfilter(simulate(po$parus),Np=100,max.fail=Inf) + +po <- pompExample(bbp,envir=NULL) +pf <- pfilter(simulate(pf$bbp),Np=100,max.fail=Inf) + +## dev.off() Modified: pkg/pompExamples/tests/pertussis.Rout.save =================================================================== --- pkg/pompExamples/tests/pertussis.Rout.save 2014-12-17 15:45:48 UTC (rev 1018) +++ pkg/pompExamples/tests/pertussis.Rout.save 2014-12-17 19:12:00 UTC (rev 1019) @@ -1,6 +1,6 @@ -R version 3.0.1 (2013-05-16) -- "Good Sport" -Copyright (C) 2013 The R Foundation for Statistical Computing +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. @@ -17,9 +17,8 @@ > library(pompExamples) Loading required package: pomp -Loading required package: mvtnorm Loading required package: subplex -Loading required package: deSolve +Loading required package: nloptr > > all <- c("SEIR.small","SEIR.big","SEIRS.small","SEIRS.big","SEIRR.small","SEIRR.big","full.small","full.big") > @@ -147,7 +146,7 @@ > > system.time(pf <- pfilter(pertussis.sim(full.small),seed=3445886L,Np=1000)) user system elapsed - 19.717 0.000 19.778 + 18.793 0.000 18.864 > logLik(pf) [1] -3829.33 > @@ -171,4 +170,4 @@ > > proc.time() user system elapsed - 20.497 0.064 20.642 + 19.533 0.040 19.671 From noreply at r-forge.r-project.org Wed Dec 17 20:12:06 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 17 Dec 2014 20:12:06 +0100 (CET) Subject: [Pomp-commits] r1020 - pkg/pompExamples/inst/examples Message-ID: <20141217191206.AC8CD183E26@r-forge.r-project.org> Author: kingaa Date: 2014-12-17 20:12:06 +0100 (Wed, 17 Dec 2014) New Revision: 1020 Modified: pkg/pompExamples/inst/examples/parus.R Log: - improved parus example Modified: pkg/pompExamples/inst/examples/parus.R =================================================================== --- pkg/pompExamples/inst/examples/parus.R 2014-12-17 19:12:00 UTC (rev 1019) +++ pkg/pompExamples/inst/examples/parus.R 2014-12-17 19:12:06 UTC (rev 1020) @@ -1,16 +1,5 @@ require(pomp) -proc.avail <- c("Gompertz","Ricker") -meas.avail <- c("lognormal","Poisson","negbin") - -if (!exists("proc",where=environment())) - stop("choose a process model: proc = ",sQuote(proc.avail)) -if (!exists("meas",where=environment())) - stop("choose a measurement model: meas = ",sQuote(meas.avail)) - -proc <- proc.avail[pmatch(proc,proc.avail)] -meas <- meas.avail[pmatch(meas,meas.avail)] - dat <- 'year,pop 1960,148 1961,258 @@ -43,48 +32,57 @@ dat <- read.csv(text=dat) -pomp( - data=dat, - times="year", - t0=1960, - params=c(K=190,r=2.7,sigma=0.2,theta=0.05,N.0=148), - rprocess=discrete.time.sim( - step.fun=switch(proc, - Gompertz="_parus_gompertz_simulator", - Ricker="_parus_ricker_simulator", - stop("unrecognized value of ",sQuote("proc")) +parus.example <- function (proc = c("Gompertz","Ricker"), + meas = c("lognormal","Poisson","negbin")) { + + proc <- match.arg(proc) + meas <- match.arg(meas) + + pomp( + data=dat, + times="year", + t0=1960, + params=c(K=190,r=2.7,sigma=0.2,theta=0.05,N.0=148), + rprocess=discrete.time.sim( + step.fun=switch(proc, + Gompertz="_parus_gompertz_simulator", + Ricker="_parus_ricker_simulator", + stop("unrecognized value of ",sQuote("proc")) + ), + delta.t=1 ), - delta.t=1 - ), - skeleton=switch(proc, + skeleton=switch(proc, Gompertz="_parus_gompertz_skeleton", Ricker="_parus_ricker_skeleton", stop("unrecognized value of ",sQuote("proc")) ), - skeleton.type="map", - skelmap.delta.t=1, - rmeasure=switch(meas, - lognormal="_parus_lognormal_rmeasure", - Poisson="_parus_poisson_rmeasure", - negbin="_parus_nbinom_rmeasure", - stop("unrecognized value of ",sQuote("meas")) - ), - dmeasure=switch(meas, - lognormal="_parus_lognormal_dmeasure", - Poisson="_parus_poisson_dmeasure", - negbin="_parus_nbinom_dmeasure", - stop("unrecognized value of ",sQuote("meas")) - ), - paramnames=c("r","K","sigma","theta"), - statenames=c("N"), - obsnames=c("pop"), - parameter.transform=function(params,...){ - exp(params) - }, - parameter.inv.transform=function(params,...){ - log(params) - }, - PACKAGE="pompExamples" - ) -> parus + skeleton.type="map", + skelmap.delta.t=1, + rmeasure=switch(meas, + lognormal="_parus_lognormal_rmeasure", + Poisson="_parus_poisson_rmeasure", + negbin="_parus_nbinom_rmeasure", + stop("unrecognized value of ",sQuote("meas")) + ), + dmeasure=switch(meas, + lognormal="_parus_lognormal_dmeasure", + Poisson="_parus_poisson_dmeasure", + negbin="_parus_nbinom_dmeasure", + stop("unrecognized value of ",sQuote("meas")) + ), + paramnames=c("r","K","sigma","theta"), + statenames=c("N"), + obsnames=c("pop"), + parameter.transform=function(params,...){ + exp(params) + }, + parameter.inv.transform=function(params,...){ + log(params) + }, + PACKAGE="pompExamples" + ) +} +parus <- parus.example(proc=proc,meas=meas) + c("parus") From noreply at r-forge.r-project.org Wed Dec 17 20:12:10 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 17 Dec 2014 20:12:10 +0100 (CET) Subject: [Pomp-commits] r1021 - pkg/pompExamples/vignettes Message-ID: <20141217191211.01A02183E26@r-forge.r-project.org> Author: kingaa Date: 2014-12-17 20:12:10 +0100 (Wed, 17 Dec 2014) New Revision: 1021 Removed: pkg/pompExamples/vignettes/Makefile pkg/pompExamples/vignettes/budmoth-model-slices.rda pkg/pompExamples/vignettes/budmoth-model-true-loglik.rda pkg/pompExamples/vignettes/budmoth-model.Rnw pkg/pompExamples/vignettes/budmoth-model.pdf pkg/pompExamples/vignettes/fullnat.bst pkg/pompExamples/vignettes/pertussis-model-true-loglik.rda pkg/pompExamples/vignettes/pertussis-model.Rnw pkg/pompExamples/vignettes/pertussis-model.pdf pkg/pompExamples/vignettes/pomp.bib Log: - remove all vignettes Deleted: pkg/pompExamples/vignettes/Makefile =================================================================== --- pkg/pompExamples/vignettes/Makefile 2014-12-17 19:12:06 UTC (rev 1020) +++ pkg/pompExamples/vignettes/Makefile 2014-12-17 19:12:10 UTC (rev 1021) @@ -1,25 +0,0 @@ -RSCRIPT = $(R_HOME)/bin/Rscript --vanilla -REXE = $(R_HOME)/bin/R --vanilla -LATEX = latex -BIBTEX = bibtex -PDFLATEX = pdflatex - -default: vignettes clean - -vignettes: budmoth-model.pdf pertussis-model.pdf - -%.tex: %.Rnw - $(REXE) CMD Sweave $* - -%.pdf: %.tex - $(PDFLATEX) $* - -$(BIBTEX) $* - $(PDFLATEX) $* - $(PDFLATEX) $* - $(RSCRIPT) -e "tools::compactPDF(\"$*.pdf\")"; - -clean: - $(RM) *.tex *.log *.aux *.blg *.bbl *.out *.Rout *.toc *.lof *.lot - $(RM) Rplots.pdf - $(RM) budmoth-model-*.pdf pertussis-model-*.pdf - $(RM) budmoth-model-*.png pertussis-model-*.png Deleted: pkg/pompExamples/vignettes/budmoth-model-slices.rda =================================================================== (Binary files differ) Deleted: pkg/pompExamples/vignettes/budmoth-model-true-loglik.rda =================================================================== (Binary files differ) Deleted: pkg/pompExamples/vignettes/budmoth-model.Rnw =================================================================== --- pkg/pompExamples/vignettes/budmoth-model.Rnw 2014-12-17 19:12:06 UTC (rev 1020) +++ pkg/pompExamples/vignettes/budmoth-model.Rnw 2014-12-17 19:12:10 UTC (rev 1021) @@ -1,518 +0,0 @@ -\documentclass[10pt,reqno,final]{amsart} -%\VignetteIndexEntry{The larch budmoth example} -\usepackage{times} -\pagestyle{plain} -\usepackage[utf8]{inputenc} -\usepackage{natbib} -\usepackage[pdftex]{graphicx} -\usepackage{paralist} -\usepackage[nogin]{Sweave} -\bibliographystyle{ecology} - -\setlength{\textwidth}{6.25in} -\setlength{\textheight}{8.75in} -\setlength{\evensidemargin}{0in} -\setlength{\oddsidemargin}{0in} -\setlength{\topmargin}{-.35in} -\setlength{\parskip}{.1in} -\setlength{\parindent}{0.0in} -\setcounter{secnumdepth}{1} -\setcounter{tocdepth}{1} - -\newcommand\code[1]{\texttt{#1}} -\newcommand{\R}{\textsf{R}} -\newcommand\logit{{\mathrm{logit}}} -\newcommand\expit{{\mathrm{expit}}} - -\SweaveOpts{echo=T,results=verbatim,print=F,eps=F,pdf=F,png=T,keep.source=T,split=F,prefix=T,prefix.string=budmoth-model,resolution=150} - -\title{Larch Budmoth State-Space Model} -\author{AAK, ELI, SPE, KBN} -\date{\today} - -\begin{document} - -\maketitle - -<>= -require(pompExamples) -require(xtable) -glop <- options(keep.source=TRUE,width=60,continue=" ",prompt=" ") -options( - device='pdf', - SweaveHooks=list( - clean=function()rm(list=ls(envir=.GlobalEnv),envir=.GlobalEnv) - ) - ) -pdf.options(useDingbats=FALSE) -set.seed(5384959) -@ - -\begin{itemize} -\item Three state variables, - $Q_t$ (measure of food quality on $[0,1]$), - $N_t$ (budmoth density) and - $S_t$ (fraction of budmoth larvae infected with parasitoids). - -\item Three observations, $\hat Q_t$ (needle length), $\hat N_t$ and $\hat S_t$. -\end{itemize} - -\section{State process} - -Uncorrelated random effects, for $t=1,\ldots,T$: -\begin{eqnarray} -\alpha_t &\sim& \mathrm{LogitNormal}(\logit(\alpha),\sigma_{\alpha}^2)\\ -\lambda_t &\sim& \mathrm{Gamma}(\lambda,\sigma_{\lambda}^2)\\ -a_t &\sim& \mathrm{LogNormal}(\log(a),\sigma_{a}^2) -\end{eqnarray} -Note: $X$ is $\mathrm{LogitNormal}(\mu,\sigma^2)$ if $\logit(X)$ is $\mathrm{Normal}(\mu,\sigma^2)$. - -The inverse of $\logit$ is $\expit$. -R functions \texttt{logit}, \texttt{expit}, \texttt{rlogitnorm}, \texttt{dlogitnorm} are part of \texttt{pompExamples}. - -The state process, for $t=1,\ldots,T$: -\begin{eqnarray} -Q_{t} &=& (1-\alpha_{t})\frac{\gamma}{\gamma+N_{t-1}} +\alpha_{t}Q_{t-1} \\ -N_{t} &=& \lambda_t N_{t-1} (1-S_{t-1})\exp\big\{-gN_{t-1}-\delta(1-Q_{t-1})\big\} \\ -S_{t} &=& 1-\exp - \left(\frac{-a_tS_{t-1}N_{t-1}}{1+a_twS_{t-1}N_{t-1}} \right) \label{eq6} -\end{eqnarray} - -\section{Measurement process} -For $t=1,\ldots,T$: -\begin{eqnarray} -\hat Q_t &\sim& \mathrm{LogNormal}(\log(\beta_0+\beta_1Q_t),\sigma_Q^2) \label{eq7}\\ -\hat N_t &\sim& \mathrm{LogNormal}(\log(N_t),\sigma_N^2) \\ -\hat S_t &\sim& \mathrm{LogitNormal}(\logit(uS_t),\sigma_S^2)\label{eq9} -\end{eqnarray} - -\section{Identifiability and constraints} - -One may wish to set $\beta_0=0$. -The logic is as follows: the steady state value of $Q_t$ is $\bar Q=\gamma/(\gamma+\bar N)$. -If $Q_t$ is in practice close to this value then $\bar Q$ identifies the mean of $\hat Q_t$ in (\ref{eq7}), leaving only the scale parameter $\beta_1$ to be determined. -Thus, the combination of $\gamma$, $\beta_0$ and $\beta_1$ is only weakly identifiable when $Q_t$ varies over only a fraction of its full range of $[0,1]$. - -\section{The budmoth example implemented} - -This model is implemented in the package and can be loaded with the command -<<>>= - -require(pompExamples) - -budmoth.sim() -bmPomps <- list( - tri=budmoth.sim(tri), - food=budmoth.sim(food), - para1=budmoth.sim(para1), - para2=budmoth.sim(para2) - ) - -@ -The object thereby loaded contains a named, length-\Sexpr{length(budmoth.sim)} list of pomp objects -<<>>= -names(bmPomps) -@ -There are three parameter regimes (``food'', ``para'', and ``tri'' representing a food-quality-dominated, a parasitoid-dominated, and true tritrophic dynamics, respectively). -In total, there are \Sexpr{length(bmPomps)} imulated data sets of length \Sexpr{diff(range(time(bmPomps[[1]])))+1} years. -<>= -for (q in names(bmPomps)) { - time(bmPomps[[q]]) <- 1:60 -} -@ -The process model is implemented using the \code{euler.simulate} plugin with step function \verb+budmoth_map+ defined in \code{src/budmoth.c} in the package source. -The log likelihood of any state transition is given by the native routine \verb+budmoth_density+. -The measurement model is simulated using \verb+budmoth_rmeasure+ -and the likelihood is computed via \verb+budmoth_dmeasure+. -Finally, the state process is initialized by -<>= -bmPomps[[1]]@initializer -@ -The parameters at which the simulated data are generated can be extracted via -<>= -true.pars <- sapply(bmPomps[c("food","para1","para2","tri")],coef) -@ -and are displayed in Table~\ref{tab:sim-params}. - -<>= -params <- as.data.frame(true.pars) -params$name <- rownames(params) -params$math <- "" -params[c("alpha","sig.alpha","gam","lambda","sig.lambda", - "g","delta","a","w","sig.a","beta0","beta1","u", - "sigQobs","sigNobs","sigSobs","Q.0","N.0","S.0"),"math"] <- c("$\\alpha$","$\\sigma_{\\alpha}$","$\\gamma$", - "$\\lambda$","$\\sigma_{\\lambda}$","$g$","$\\delta$", - "$a$","$w$","$\\sigma_{a}$", - "$\\beta_{0}$","$\\beta_{1}$", - "$u$","$\\sigma_{Q}$","$\\sigma_{N}$","$\\sigma_{S}$", - "$Q_{0}$","$N_{0}$","$S_{0}$") -params <- params[c("math","name","food","para1","para2","tri")] -names(params) <- c("parameter","R name","food","para1","para2","tri") -print( - xtable( - params, - caption="Parameters of the larch budmoth model, and the values corresponding to the simulated data.", - label="tab:sim-params" - ), - type='latex', - floating=TRUE, - caption.placement="top", - include.rownames=FALSE, - hline.after=c(-1,-1,0,nrow(params)), - sanitize.text.function=identity - ) -@ - -\setkeys{Gin}{width=0.8\textwidth} - -\begin{figure} -<>= -require(pompExamples) -require(plyr) -require(reshape2) -require(ggplot2) -bmPomps <- list( - tri=budmoth.sim(tri), - food=budmoth.sim(food), - para1=budmoth.sim(para1), - para2=budmoth.sim(para2) - ) -x <- ldply(bmPomps,as.data.frame) -x <- rename(x,c(.id="dataset")) -x <- melt(x,id.var=c("dataset","time")) -x <- subset(x,variable%in%c("Qobs","Nobs","Sobs")) -pl <- ggplot(data=x,mapping=aes(x=time,y=value))+ - geom_line()+facet_grid(variable~dataset,scale="free") -print(pl) -@ - \caption{Plot of the simulated budmoth data.} -\end{figure} - -We can get a benchmark for likelihood-based fitting methods by computing the true likelihood at the true parameter values. -To do this, we run the \code{pfilter} particle filtering code. -<>= -require(Rmpi) -require(mpifarm) -require(pompExamples) - -bmPomps <- list( - tri=budmoth.sim(tri), - food=budmoth.sim(food), - para1=budmoth.sim(para1), - para2=budmoth.sim(para2) - ) - -ncpus <- length(bmPomps) - -nrep <- 10 ### number of particle filters to run -Np <- 10000 ### number of particles - -set.seed(5384959) - -mpi.spawn.Rslaves(nslaves=ncpus) - -mpi.farmer( - chunk=5, - seeds=as.integer(floor(runif(n=nrep,1,2^31))), - jobs={ - require(plyr) - dlply( - expand.grid( - seed=seeds, - dataset=names(bmPomps) - ), - ~dataset+seed - ) - }, - common=list( - pomps=bmPomps, - Np=Np - ), - main={ - require(pompExamples) - save.seed <- .Random.seed - set.seed(seed) - tic <- Sys.time() - pf <- try(pfilter(pomps[[dataset]],Np=Np,max.fail=100,warn=FALSE)) - if (inherits(pf,"try-error")) { - loglik <- NA - nfail <- NA - } else { - loglik <- logLik(pf) - nfail <- pf$nfail - } - toc <- Sys.time() - .Random.seed <<- save.seed - data.frame( - seed=seed, - dataset=dataset, - loglik=loglik, - nfail=nfail, - etime=toc-tic - ) - }, - post={ - require(plyr) - ldply(results) - } - ) -> results - -mpi.close.Rslaves() - -if (any(with(results,nfail!=0))) - warning("filtering failures occurred!") - -etime <- sum(results$etime) - -ll.est <- function (x) { - bl <- mean(x$loglik) - loglik <- bl+log(mean(exp(x$loglik-bl))) - se <- sd(exp(x$loglik-bl))/exp(loglik-bl) - data.frame(loglik=loglik,se=se) -} - -loglik.truth <- ddply(results,~dataset,ll.est) - -save(loglik.truth,etime,Np,nrep,ncpus,file=binary.file,compress="xz") -@ -<>= -binary.file <- "budmoth-model-true-loglik.rda" -if (file.exists(binary.file)) { - load(binary.file) -} else { -<> -} -@ -Table~\ref{tab:true-loglik} shows these likelihoods. - -<>= -nest <- 6 -loglik.truth[["5\\%"]] <- loglik.truth$loglik+qchisq(p=0.05,df=nest)/2 -print( - xtable( - loglik.truth, - caption=paste( - "Estimated log likelihood at the true parameters for the simulated budmoth data. ", - "To obtain these,",nrep,"particle filtering runs, each with",Np,"particles, were used. ", - "The column labeled",dQuote("se"),"gives the standard error of the Monte Carlo likelihood calculation. ", - "The computation took ",signif(etime,2),"~CPU~",units(etime),"on inexpensive processors. ", - "The last column shows the likelihood we would expect to achieve at the MLE 95\\% of the time when estimating", - nest,"parameters.", - sep=" " - ), - label="tab:true-loglik", - digits=c(0,0,1,2,1) - ), - type="latex", - floating=TRUE, - caption.placement="top", - include.rownames=FALSE, - sanitize.text.function=identity, - hline.after=c(-1,-1,0,nrow(loglik.truth)) - ) -@ - -To get some sense of the shape of the likelihood surface, we can construct slices through each of the true parameter points. -These likelihood slices are shown in Fig.~\ref{fig:slices}. -<>= -require(pompExamples) -require(Rmpi) -require(mpifarm) - -nrep <- 3 ### number of particle filters to run per parameter point -Np <- 1000 ### number of particles per filter -slice.length <- 100 ### number of points per slice - -bmPomps <- list( - tri=budmoth.sim(tri), - food=budmoth.sim(food), - para1=budmoth.sim(para1), - para2=budmoth.sim(para2) - ) - -true.pars <- sapply(bmPomps,coef) -estnames <- c("gam","lambda","g","delta","a","w") -par.range <- t(apply(true.pars[estnames,],1,function(x)c(0.5*min(x),1.5*max(x)))) - -ncpus <- as.integer(Sys.getenv("PBS_NP")) - -slices <- lapply( - bmPomps, - function (po) { - center <- coef(po) - ranges <- lapply( - estnames, - function(n) seq( - from=par.range[n,1], - to=par.range[n,2], - length=slice.length - ) - ) - names(ranges) <- estnames - do.call(sliceDesign,c(list(center=center),ranges)) - } - ) - -require(plyr) -slices <- ldply(slices) -rename(slices,c(.id="dataset")) -> slices - -set.seed(5384959) - -mpi.spawn.Rslaves(nslaves=ncpus) - -mpi.farmer( - chunk=20, - checkpoint=1000, - checkpoint.file=file.path(getwd(),"budmoth-slices-ckpt.rda"), - seeds=as.integer(floor(runif(n=nrep*nrow(slices),1,2^31))), - jobs={ - joblist <- vector(mode="list",length=nrep*nrow(slices)) - s <- 0 - for (j in seq_len(nrow(slices))) { - ds <- slices$dataset[j] - sl <- slices$slice[j] - paramnames <- names(coef(bmPomps[[ds]])) - for (k in seq_len(nrep)) { - s <- s+1 - joblist[[s]] <- list( - params=unlist(slices[j,paramnames]), - seed=seeds[s], - dataset=ds, - slice=sl - ) - } - } - joblist - }, - common=list( - pomps=bmPomps, - Np=Np, - estnames=estnames - ), - main={ - require(pompExamples) - po <- pomps[[dataset]] - save.seed <- .Random.seed - set.seed(seed) - tic <- Sys.time() - pf <- try(pfilter(po,params=params,Np=Np,max.fail=100,warn=FALSE)) - if (inherits(pf,"try-error")) { - loglik <- NA - nfail <- NA - cond.loglik <- pf$cond.loglik - } else { - loglik <- logLik(pf) - nfail <- pf$nfail - cond.loglik <- pf$cond.loglik - } - toc <- Sys.time() - .Random.seed <<- save.seed - list( - params=params, - slice=slice, - dataset=dataset, - loglik=loglik, - nfail=nfail, - cond.loglik=cond.loglik, - etime=toc-tic - ) - }, - post={ - require(plyr) - ldply( - results, - function(x)data.frame( - dataset=x$dataset, - slice=x$slice, - as.list(x$params), - loglik=x$loglik, - nfail=x$nfail, - etime=x$etime - ) - ) - } - ) -> slices - -mpi.close.Rslaves() - -save(slices,file=binary.file,compress="xz") -@ -<>= -binary.file <- "budmoth-model-slices.rda" -if (file.exists(binary.file)) { - load(binary.file) -} else { -<> -} -@ -These calculations took \Sexpr{signif(etime,3)}~CPU~\Sexpr{units(etime)} on inexpensive processors. - -\setkeys{Gin}{width=0.95\textwidth} - -\begin{figure} -<>= -require(ggplot2) -require(plyr) -require(reshape2) -slices$.id <- NULL -slices$etime <- NULL -slices$nfail <- NULL -x <- melt(slices,id.vars=c("dataset","slice","loglik")) -x$slice <- factor(x$slice,levels=levels(x$variable)) -x <- subset(x,slice==variable) -x <- ddply(x,~dataset+slice,subset,loglik>max(loglik)-50) -pl <- ggplot(data=x,mapping=aes(x=value,y=loglik))+ - geom_point()+facet_grid(dataset~slice,scale="free")+ - geom_smooth(method="loess") -print(pl) -@ - \caption{ - Sliced likelihood plots. - \label{fig:slices} - } -\end{figure} - -To simulate ignorance, we will assume that we are uncertain about the values of some of the parameters. -In particular, we will suppose that we wish to estimate the parameters that distinguish the regimes. -<>= -estnames <- names(which(apply(true.pars,1,function(x)diff(range(x))>0))) -par.range <- signif( - t( - apply( - true.pars[estnames,], - 1, - function(x)c(0.5*min(x),1.5*max(x)) - ) - ), - digits=3 - ) -colnames(par.range) <- c("lower","upper") -@ -We will assume a hypercube within which we are uniformly uncertain as to the parameter values. -The upper and lower limits for each of the parameters we will estimate are given in Table~\ref{tab:par-range}. - -<>= -print( - xtable( - par.range, - caption="Parameters to estimate, and limits of uncertainty.", - label="tab:par-range", - display=c("s","fg","fg"), - digits=c(0,3,3) - ), - type="latex", - floating=TRUE, - caption.placement="top", - include.rownames=TRUE, -# sanitize.text.function=identity, - hline.after=c(-1,-1,0,nrow(par.range)) - ) -@ - -\end{document} - -<>= -options(glop) -@ - Deleted: pkg/pompExamples/vignettes/budmoth-model.pdf =================================================================== (Binary files differ) Deleted: pkg/pompExamples/vignettes/fullnat.bst =================================================================== --- pkg/pompExamples/vignettes/fullnat.bst 2014-12-17 19:12:06 UTC (rev 1020) +++ pkg/pompExamples/vignettes/fullnat.bst 2014-12-17 19:12:10 UTC (rev 1021) @@ -1,1429 +0,0 @@ -%% -%% This is file `fullnat.bst', -%% generated with the docstrip utility. -%% -%% The original source files were: -%% -%% merlin.mbs (with options: `ay,nat,vonx,nm-init,ed-au,keyxyr,yr-par,note-yr,vol-bf,vnum-x,num-xser,jnm-x,pub-date,pp,ed,abr,xedn,etal-it,nfss,') -%% ---------------------------------------- -%% *** *** -%% -%% Copyright 1994-2004 Patrick W Daly - % =============================================================== - % IMPORTANT NOTICE: - % This bibliographic style (bst) file has been generated from one or - % more master bibliographic style (mbs) files, listed above. - % - % This generated file can be redistributed and/or modified under the terms - % of the LaTeX Project Public License Distributed from CTAN - % archives in directory macros/latex/base/lppl.txt; either - % version 1 of the License, or any later version. - % =============================================================== - % Name and version information of the main mbs file: - % \ProvidesFile{merlin.mbs}[2004/02/09 4.13 (PWD, AO, DPC)] - % For use with BibTeX version 0.99a or later - %------------------------------------------------------------------- - % This bibliography style file is intended for texts in ENGLISH - % This is an author-year citation style bibliography. As such, it is - % non-standard LaTeX, and requires a special package file to function properly. - % Such a package is natbib.sty by Patrick W. Daly - % The form of the \bibitem entries is - % \bibitem[Jones et al.(1990)]{key}... - % \bibitem[Jones et al.(1990)Jones, Baker, and Smith]{key}... - % The essential feature is that the label (the part in brackets) consists - % of the author names, as they should appear in the citation, with the year - % in parentheses following. There must be no space before the opening - % parenthesis! - % With natbib v5.3, a full list of authors may also follow the year. - % In natbib.sty, it is possible to define the type of enclosures that is - % really wanted (brackets or parentheses), but in either case, there must - % be parentheses in the label. - % The \cite command functions as follows: - % \citet{key} ==>> Jones et al. (1990) - % \citet*{key} ==>> Jones, Baker, and Smith (1990) - % \citep{key} ==>> (Jones et al., 1990) - % \citep*{key} ==>> (Jones, Baker, and Smith, 1990) - % \citep[chap. 2]{key} ==>> (Jones et al., 1990, chap. 2) - % \citep[e.g.][]{key} ==>> (e.g. Jones et al., 1990) - % \citep[e.g.][p. 32]{key} ==>> (e.g. Jones et al., p. 32) - % \citeauthor{key} ==>> Jones et al. - % \citeauthor*{key} ==>> Jones, Baker, and Smith - % \citeyear{key} ==>> 1990 - %--------------------------------------------------------------------- - -ENTRY - { address - author - booktitle - chapter - edition - editor - eid - howpublished - institution - journal - key - month - note - number - organization - pages - publisher - school - series - title - type - volume - year - } - {} - { label extra.label sort.label short.list } -INTEGERS { output.state before.all mid.sentence after.sentence after.block } -FUNCTION {init.state.consts} -{ #0 'before.all := - #1 'mid.sentence := - #2 'after.sentence := - #3 'after.block := -} -STRINGS { s t} -FUNCTION {output.nonnull} -{ 's := - output.state mid.sentence = - { ", " * write$ } - { output.state after.block = - { add.period$ write$ - newline$ - "\newblock " write$ - } - { output.state before.all = - 'write$ - { add.period$ " " * write$ } - if$ - } - if$ - mid.sentence 'output.state := - } - if$ - s -} -FUNCTION {output} -{ duplicate$ empty$ - 'pop$ - 'output.nonnull - if$ -} -FUNCTION {output.check} -{ 't := - duplicate$ empty$ - { pop$ "empty " t * " in " * cite$ * warning$ } - 'output.nonnull - if$ -} -FUNCTION {fin.entry} -{ add.period$ - write$ - newline$ -} - -FUNCTION {new.block} -{ output.state before.all = - 'skip$ - { after.block 'output.state := } - if$ -} -FUNCTION {new.sentence} -{ output.state after.block = - 'skip$ - { output.state before.all = - 'skip$ - { after.sentence 'output.state := } - if$ - } - if$ -} -FUNCTION {add.blank} -{ " " * before.all 'output.state := -} - -FUNCTION {date.block} -{ - new.block -} - -FUNCTION {not} -{ { #0 } - { #1 } - if$ -} -FUNCTION {and} -{ 'skip$ - { pop$ #0 } - if$ -} -FUNCTION {or} -{ { pop$ #1 } - 'skip$ - if$ -} -FUNCTION {new.block.checkb} -{ empty$ - swap$ empty$ - and - 'skip$ - 'new.block - if$ -} -FUNCTION {field.or.null} -{ duplicate$ empty$ - { pop$ "" } - 'skip$ - if$ -} -FUNCTION {emphasize} -{ duplicate$ empty$ - { pop$ "" } - { "\emph{" swap$ * "}" * } - if$ -} -FUNCTION {bolden} -{ duplicate$ empty$ - { pop$ "" } - { "\textbf{" swap$ * "}" * } - if$ -} -FUNCTION {tie.or.space.prefix} -{ duplicate$ text.length$ #3 < - { "~" } - { " " } - if$ - swap$ -} - -FUNCTION {capitalize} -{ "u" change.case$ "t" change.case$ } - -FUNCTION {space.word} -{ " " swap$ * " " * } - % Here are the language-specific definitions for explicit words. - % Each function has a name bbl.xxx where xxx is the English word. - % The language selected here is ENGLISH -FUNCTION {bbl.and} -{ "and"} - -FUNCTION {bbl.etal} -{ "et~al." } - -FUNCTION {bbl.editors} -{ "eds." } - -FUNCTION {bbl.editor} -{ "ed." } - -FUNCTION {bbl.edby} -{ "edited by" } - -FUNCTION {bbl.edition} -{ "edn." } - -FUNCTION {bbl.volume} -{ "vol." } - -FUNCTION {bbl.of} -{ "of" } - -FUNCTION {bbl.number} -{ "no." } - -FUNCTION {bbl.nr} -{ "no." } - -FUNCTION {bbl.in} -{ "in" } - -FUNCTION {bbl.pages} -{ "pp." } - -FUNCTION {bbl.page} -{ "p." } - -FUNCTION {bbl.chapter} -{ "chap." } - -FUNCTION {bbl.techrep} -{ "Tech. Rep." } - -FUNCTION {bbl.mthesis} -{ "Master's thesis" } - -FUNCTION {bbl.phdthesis} -{ "Ph.D. thesis" } - -MACRO {jan} {"Jan."} - -MACRO {feb} {"Feb."} - -MACRO {mar} {"Mar."} - -MACRO {apr} {"Apr."} - -MACRO {may} {"May"} - -MACRO {jun} {"Jun."} - -MACRO {jul} {"Jul."} - -MACRO {aug} {"Aug."} - -MACRO {sep} {"Sep."} - -MACRO {oct} {"Oct."} - -MACRO {nov} {"Nov."} - -MACRO {dec} {"Dec."} - -MACRO {acmcs} {"ACM Computing Surveys"} - -MACRO {acta} {"Acta Informatica"} - -MACRO {cacm} {"Communications of the ACM"} - -MACRO {ibmjrd} {"IBM Journal of Research and Development"} - -MACRO {ibmsj} {"IBM Systems Journal"} - -MACRO {ieeese} {"IEEE Transactions on Software Engineering"} - -MACRO {ieeetc} {"IEEE Transactions on Computers"} - -MACRO {ieeetcad} - {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"} - -MACRO {ipl} {"Information Processing Letters"} - -MACRO {jacm} {"Journal of the ACM"} - -MACRO {jcss} {"Journal of Computer and System Sciences"} - -MACRO {scp} {"Science of Computer Programming"} - -MACRO {sicomp} {"SIAM Journal on Computing"} - -MACRO {tocs} {"ACM Transactions on Computer Systems"} - -MACRO {tods} {"ACM Transactions on Database Systems"} - -MACRO {tog} {"ACM Transactions on Graphics"} - -MACRO {toms} {"ACM Transactions on Mathematical Software"} - -MACRO {toois} {"ACM Transactions on Office Information Systems"} - -MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"} - -MACRO {tcs} {"Theoretical Computer Science"} -FUNCTION {bibinfo.check} -{ swap$ - duplicate$ missing$ - { - pop$ pop$ - "" - } - { duplicate$ empty$ - { - swap$ pop$ - } - { swap$ - pop$ - } - if$ - } - if$ -} -FUNCTION {bibinfo.warn} -{ swap$ - duplicate$ missing$ - { - swap$ "missing " swap$ * " in " * cite$ * warning$ pop$ - "" - } - { duplicate$ empty$ - { - swap$ "empty " swap$ * " in " * cite$ * warning$ - } - { swap$ - pop$ - } - if$ - } - if$ -} -STRINGS { bibinfo} -INTEGERS { nameptr namesleft numnames } - -FUNCTION {format.names} -{ 'bibinfo := - duplicate$ empty$ 'skip$ { - 's := - "" 't := - #1 'nameptr := - s num.names$ 'numnames := - numnames 'namesleft := - { namesleft #0 > } - { s nameptr - "{f.~}{vv~}{ll}{, jj}" - format.name$ - bibinfo bibinfo.check - 't := - nameptr #1 > - { - namesleft #1 > - { ", " * t * } - { - numnames #2 > - { "," * } - 'skip$ - if$ - s nameptr "{ll}" format.name$ duplicate$ "others" = - { 't := } - { pop$ } - if$ - t "others" = - { - " " * bbl.etal emphasize * - } - { - bbl.and - space.word * t * - } - if$ - } - if$ - } - 't - if$ - nameptr #1 + 'nameptr := - namesleft #1 - 'namesleft := - } - while$ - } if$ -} -FUNCTION {format.names.ed} -{ - format.names -} -FUNCTION {format.key} -{ empty$ - { key field.or.null } - { "" } - if$ -} - -FUNCTION {format.authors} -{ author "author" format.names -} -FUNCTION {get.bbl.editor} -{ editor num.names$ #1 > 'bbl.editors 'bbl.editor if$ } - -FUNCTION {format.editors} -{ editor "editor" format.names duplicate$ empty$ 'skip$ - { - "," * - " " * - get.bbl.editor - * - } - if$ -} -FUNCTION {format.note} -{ - note empty$ - { "" } - { note #1 #1 substring$ - duplicate$ "{" = - 'skip$ - { output.state mid.sentence = - { "l" } - { "u" } - if$ - change.case$ - } - if$ - note #2 global.max$ substring$ * "note" bibinfo.check - } - if$ -} - -FUNCTION {format.title} -{ title - duplicate$ empty$ 'skip$ - { "t" change.case$ } - if$ - "title" bibinfo.check -} -FUNCTION {format.full.names} -{'s := - "" 't := - #1 'nameptr := - s num.names$ 'numnames := - numnames 'namesleft := - { namesleft #0 > } - { s nameptr - "{vv~}{ll}" format.name$ - 't := - nameptr #1 > - { - namesleft #1 > - { ", " * t * } - { - s nameptr "{ll}" format.name$ duplicate$ "others" = - { 't := } - { pop$ } - if$ - t "others" = - { - " " * bbl.etal emphasize * - } - { - numnames #2 > - { "," * } - 'skip$ - if$ - bbl.and - space.word * t * - } - if$ - } - if$ - } - 't - if$ - nameptr #1 + 'nameptr := - namesleft #1 - 'namesleft := - } - while$ -} - -FUNCTION {author.editor.key.full} -{ author empty$ - { editor empty$ - { key empty$ - { cite$ #1 #3 substring$ } - 'key - if$ - } - { editor format.full.names } - if$ - } - { author format.full.names } - if$ -} - -FUNCTION {author.key.full} -{ author empty$ - { key empty$ - { cite$ #1 #3 substring$ } - 'key - if$ - } - { author format.full.names } - if$ -} - -FUNCTION {editor.key.full} -{ editor empty$ - { key empty$ - { cite$ #1 #3 substring$ } - 'key - if$ - } - { editor format.full.names } - if$ -} - -FUNCTION {make.full.names} -{ type$ "book" = - type$ "inbook" = - or - 'author.editor.key.full - { type$ "proceedings" = - 'editor.key.full - 'author.key.full - if$ - } - if$ -} - -FUNCTION {output.bibitem} -{ newline$ - "\bibitem[{" write$ - label write$ - ")" make.full.names duplicate$ short.list = - { pop$ } - { * } - if$ - "}]{" * write$ - cite$ write$ - "}" write$ - newline$ - "" - before.all 'output.state := -} - -FUNCTION {n.dashify} -{ - 't := - "" - { t empty$ not } - { t #1 #1 substring$ "-" = - { t #1 #2 substring$ "--" = not - { "--" * - t #2 global.max$ substring$ 't := - } - { { t #1 #1 substring$ "-" = } - { "-" * - t #2 global.max$ substring$ 't := - } - while$ - } - if$ - } - { t #1 #1 substring$ * - t #2 global.max$ substring$ 't := - } - if$ - } - while$ -} - -FUNCTION {word.in} -{ bbl.in capitalize - " " * } - -FUNCTION {format.date} -{ year "year" bibinfo.check duplicate$ empty$ - { - "empty year in " cite$ * "; set to ????" * warning$ - pop$ "????" - } - 'skip$ - if$ - extra.label * - before.all 'output.state := - " (" swap$ * ")" * -} -FUNCTION {format.btitle} -{ title "title" bibinfo.check - duplicate$ empty$ 'skip$ - { - emphasize - } - if$ -} -FUNCTION {either.or.check} -{ empty$ - 'pop$ - { "can't use both " swap$ * " fields in " * cite$ * warning$ } - if$ -} -FUNCTION {format.bvolume} -{ volume empty$ - { "" } - { bbl.volume volume tie.or.space.prefix - "volume" bibinfo.check * * - series "series" bibinfo.check - duplicate$ empty$ 'pop$ - { swap$ bbl.of space.word * swap$ - emphasize * } - if$ - "volume and number" number either.or.check - } - if$ -} -FUNCTION {format.number.series} -{ volume empty$ - { number empty$ - { series field.or.null } - { series empty$ - { number "number" bibinfo.check } - { output.state mid.sentence = - { bbl.number } - { bbl.number capitalize } - if$ - number tie.or.space.prefix "number" bibinfo.check * * - bbl.in space.word * - series "series" bibinfo.check * - } - if$ - } - if$ - } - { "" } - if$ -} - -FUNCTION {format.edition} -{ edition duplicate$ empty$ 'skip$ - { - output.state mid.sentence = - { "l" } - { "t" } [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/pomp -r 1021 From noreply at r-forge.r-project.org Wed Dec 17 20:12:15 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 17 Dec 2014 20:12:15 +0100 (CET) Subject: [Pomp-commits] r1022 - pkg/pompExamples/inst/examples Message-ID: <20141217191215.80B57183E26@r-forge.r-project.org> Author: kingaa Date: 2014-12-17 20:12:15 +0100 (Wed, 17 Dec 2014) New Revision: 1022 Modified: pkg/pompExamples/inst/examples/parus.R Log: - include better documentation of Parus data Modified: pkg/pompExamples/inst/examples/parus.R =================================================================== --- pkg/pompExamples/inst/examples/parus.R 2014-12-17 19:12:10 UTC (rev 1021) +++ pkg/pompExamples/inst/examples/parus.R 2014-12-17 19:12:15 UTC (rev 1022) @@ -1,6 +1,31 @@ +#' Annual *Parus major* counts in Wytham Wood, Oxfordshire, England. +#' +#' @param proc the process model (Gompertz or Ricker are currently supported) +#' @param meas the measurement model +#' (lognormal, negative binomial, and Poisson are currently supported) +#' @references McCleery, R. & Perrins, C. (1991) +#' Effects of predation on the numbers of Great Tits, Parus major. +#' In: Bird Population Studies, +#' edited by Perrins, C.M., Lebreton, J.-D. & Hirons, G.J.M. +#' Oxford. Univ. Press. pp. 129--147. +#' @author Aaron A. King \email{kingaa@@umich.edu} + require(pomp) -dat <- 'year,pop +dat <- ' +## Parus major (Great Tit) census (all individuals) +## Wytham Wood, Oxfordshire +## Global Population Dynamics Database dataset #10163. +## (NERC Centre for Population Biology, Imperial College (2010) +## The Global Population Dynamics Database Version 2. +## http://www.sw.ic.ac.uk/cpb/cpb/gpdd.html"). +## Original source: +## McCleery, R. & Perrins, C. (1991) +## Effects of predation on the numbers of Great Tits, Parus major. +## In: Bird Population Studies, +## edited by Perrins, C.M., Lebreton, J.-D. & Hirons, G.J.M. +## Oxford. Univ. Press. pp. 129--147. +year,pop 1960,148 1961,258 1962,185 @@ -30,7 +55,7 @@ 1986,211 ' -dat <- read.csv(text=dat) +dat <- read.csv(text=dat,comment.char="#") parus.example <- function (proc = c("Gompertz","Ricker"), meas = c("lognormal","Poisson","negbin")) { From noreply at r-forge.r-project.org Wed Dec 17 20:12:21 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 17 Dec 2014 20:12:21 +0100 (CET) Subject: [Pomp-commits] r1023 - in pkg/pompExamples: . R inst/examples man tests Message-ID: <20141217191221.70BF2183E26@r-forge.r-project.org> Author: kingaa Date: 2014-12-17 20:12:21 +0100 (Wed, 17 Dec 2014) New Revision: 1023 Added: pkg/pompExamples/inst/examples/budmoth.R Removed: pkg/pompExamples/R/budmoth.R Modified: pkg/pompExamples/DESCRIPTION pkg/pompExamples/NAMESPACE pkg/pompExamples/man/budmoth.Rd pkg/pompExamples/tests/budmoth.R pkg/pompExamples/tests/budmoth.Rout.save pkg/pompExamples/tests/examples.R Log: - implement budmoth example for 'pompExample' Modified: pkg/pompExamples/DESCRIPTION =================================================================== --- pkg/pompExamples/DESCRIPTION 2014-12-17 19:12:15 UTC (rev 1022) +++ pkg/pompExamples/DESCRIPTION 2014-12-17 19:12:21 UTC (rev 1023) @@ -21,4 +21,4 @@ License: GPL (>= 2) LazyData: false BuildVignettes: true -Collate: aaa.R budmoth.R pertussis.R +Collate: aaa.R pertussis.R Modified: pkg/pompExamples/NAMESPACE =================================================================== --- pkg/pompExamples/NAMESPACE 2014-12-17 19:12:15 UTC (rev 1022) +++ pkg/pompExamples/NAMESPACE 2014-12-17 19:12:21 UTC (rev 1023) @@ -1,3 +1,3 @@ useDynLib(pompExamples) import(pomp) -export(pertussis.sim,budmoth.sim) +export(pertussis.sim) Deleted: pkg/pompExamples/R/budmoth.R =================================================================== --- pkg/pompExamples/R/budmoth.R 2014-12-17 19:12:15 UTC (rev 1022) +++ pkg/pompExamples/R/budmoth.R 2014-12-17 19:12:21 UTC (rev 1023) @@ -1,106 +0,0 @@ -budmoth.sim <- function (which) { - if (missing(which)) { - datasets <- c("food","para1","para2","tri") - cat("available datasets:",sQuote(datasets),"\n") - invisible(datasets) - } else { - which <- as.character(substitute(which)) - simulate( - pomp( - data=data.frame( - time=seq(from=0,to=60,by=1), - Qobs=NA,Nobs=NA,Sobs=NA - ), - time="time", - t0=-1, - params=switch( - which, - tri=c( - alpha=0.5, sig.alpha=0.1, gam=50, lambda=22, - sig.lambda=0.25, g=0.08, delta=10, - a=1.7, sig.a=0.1, w=0.15, beta0=0, beta1=35, u=0.9, - sigQobs=0.03, sigNobs=0.5, sigSobs=0.1, - Q.0=0.96, N.0=0.02, S.0=0.22 - ), - food=c( - alpha=0.5, sig.alpha=0.1, gam=20, lambda=5, - sig.lambda=0.25, g=0.02, delta=10, - a=1, sig.a=0.1, w=0, beta0=0, beta1=35, u=0.9, - sigQobs=0.03, sigNobs=0.5, sigSobs=0.1, - Q.0=0.96, N.0=0.02, S.0=0.22 - ), - para1=c( - alpha=0.5, sig.alpha=0.1, gam=50, lambda=22, - sig.lambda=0.25, g=0.08, delta=0.5, - a=1.7, sig.a=0.1, w=0.15, beta0=0, beta1=35, u=0.9, - sigQobs=0.03, sigNobs=0.5, sigSobs=0.1, - Q.0=0.96, N.0=0.02, S.0=0.22 - ), - para2=c( - alpha=0.5, sig.alpha=0.1, gam=50, lambda=10, - sig.lambda=5, g=0.08, delta=0.5, - a=1.7, sig.a=1, w=0.15, beta0=0, beta1=35, u=0.9, - sigQobs=0.03, sigNobs=0.5, sigSobs=0.1, - Q.0=0.96, N.0=0.02, S.0=0.22 - ), - stop("unrecognized dataset ",sQuote(which),call.=FALSE) - ), - rprocess=euler.sim( - step.fun="budmoth_map", - delta.t=1, - PACKAGE="pompExamples" - ), - dprocess=onestep.dens( - dens.fun="budmoth_density", - PACKAGE="pompExamples" - ), - rmeasure="budmoth_rmeasure", - dmeasure="budmoth_dmeasure", - skeleton.type="map", - skeleton="budmoth_skeleton", - PACKAGE="pompExamples", - paramnames=c( - "alpha","sig.alpha","gam","lambda","sig.lambda", - "g","delta","a","sig.a", - "w","beta0","beta1","u", - "sigQobs","sigNobs","sigSobs" - ), - statenames=c( - "Alpha","Lambda","A","Q","N","S" - ), - obsnames=c("Qobs","Nobs","Sobs"), - initializer=function (params, t0, ...) { - x <- c(params[c("Q.0","N.0","S.0")],c(0,0,0)) - names(x) <- c("Q","N","S","Alpha","Lambda","A") - x - }, - logitvar=c("alpha","Q.0","S.0","u"), - logvar=c( - "sig.alpha","gam","lambda","sig.lambda", - "g","delta","a","w","sig.a","beta1","sigQobs", - "sigNobs", "sigSobs","N.0" - ), - parameter.transform=function (params, logitvar, - logvar, ...) { - params[logitvar] <- plogis(params[logitvar]) - params[logvar] <- exp(params[logvar]) - params - }, - parameter.inv.transform=function (params, logitvar, - logvar, ...) { - params[logitvar] <- qlogis(params[logitvar]) - params[logvar] <- log(params[logvar]) - params - } - ), - seed=switch( - which, - tri=1691699385L, - food=1054866677L, - para1=1116757478L, - para2=1361101458L, - stop("unrecognized dataset ",sQuote(which),call.=FALSE) - ) - ) - } -} Added: pkg/pompExamples/inst/examples/budmoth.R =================================================================== --- pkg/pompExamples/inst/examples/budmoth.R (rev 0) +++ pkg/pompExamples/inst/examples/budmoth.R 2014-12-17 19:12:21 UTC (rev 1023) @@ -0,0 +1,113 @@ +require(pomp) + +budmoth.example <- function (which = c("food","para1","para2","tri")) { + which <- match.arg(which) + simulate( + pomp( + data=data.frame( + time=seq(from=0,to=60,by=1), + Qobs=NA,Nobs=NA,Sobs=NA + ), + time="time", + t0=-1, + params=switch( + which, + tri=c( + alpha=0.5, sig.alpha=0.1, gam=50, lambda=22, + sig.lambda=0.25, g=0.08, delta=10, + a=1.7, sig.a=0.1, w=0.15, beta0=0, beta1=35, u=0.9, + sigQobs=0.03, sigNobs=0.5, sigSobs=0.1, + Q.0=0.96, N.0=0.02, S.0=0.22 + ), + food=c( + alpha=0.5, sig.alpha=0.1, gam=20, lambda=5, + sig.lambda=0.25, g=0.02, delta=10, + a=1, sig.a=0.1, w=0, beta0=0, beta1=35, u=0.9, + sigQobs=0.03, sigNobs=0.5, sigSobs=0.1, + Q.0=0.96, N.0=0.02, S.0=0.22 + ), + para1=c( + alpha=0.5, sig.alpha=0.1, gam=50, lambda=22, + sig.lambda=0.25, g=0.08, delta=0.5, + a=1.7, sig.a=0.1, w=0.15, beta0=0, beta1=35, u=0.9, + sigQobs=0.03, sigNobs=0.5, sigSobs=0.1, + Q.0=0.96, N.0=0.02, S.0=0.22 + ), + para2=c( + alpha=0.5, sig.alpha=0.1, gam=50, lambda=10, + sig.lambda=5, g=0.08, delta=0.5, + a=1.7, sig.a=1, w=0.15, beta0=0, beta1=35, u=0.9, + sigQobs=0.03, sigNobs=0.5, sigSobs=0.1, + Q.0=0.96, N.0=0.02, S.0=0.22 + ), + stop("unrecognized dataset ",sQuote(which),call.=FALSE) + ), + rprocess=euler.sim( + step.fun="budmoth_map", + delta.t=1, + PACKAGE="pompExamples" + ), + dprocess=onestep.dens( + dens.fun="budmoth_density", + PACKAGE="pompExamples" + ), + rmeasure="budmoth_rmeasure", + dmeasure="budmoth_dmeasure", + skeleton.type="map", + skeleton="budmoth_skeleton", + PACKAGE="pompExamples", + paramnames=c( + "alpha","sig.alpha","gam","lambda","sig.lambda", + "g","delta","a","sig.a", + "w","beta0","beta1","u", + "sigQobs","sigNobs","sigSobs" + ), + statenames=c( + "Alpha","Lambda","A","Q","N","S" + ), + obsnames=c("Qobs","Nobs","Sobs"), + initializer=function (params, t0, ...) { + x <- c(params[c("Q.0","N.0","S.0")],c(0,0,0)) + names(x) <- c("Q","N","S","Alpha","Lambda","A") + x + }, + logitvar=c("alpha","Q.0","S.0","u"), + logvar=c( + "sig.alpha","gam","lambda","sig.lambda", + "g","delta","a","w","sig.a","beta1","sigQobs", + "sigNobs", "sigSobs","N.0" + ), + parameter.transform=function (params, logitvar, + logvar, ...) { + params[logitvar] <- plogis(params[logitvar]) + params[logvar] <- exp(params[logvar]) + params + }, + parameter.inv.transform=function (params, logitvar, + logvar, ...) { + params[logitvar] <- qlogis(params[logitvar]) + params[logvar] <- log(params[logvar]) + params + } + ), + seed=switch( + which, + tri=1691699385L, + food=1054866677L, + para1=1116757478L, + para2=1361101458L, + stop("unrecognized dataset ",sQuote(which),call.=FALSE) + ) + ) +} + +if (exists("which",where=environment(),inherits=FALSE)) { + budmoth.example(which) -> budmoth + c("budmoth") +} else { + budmoth.example(which="food") -> food + budmoth.example(which="para1") -> para1 + budmoth.example(which="para2") -> para2 + budmoth.example(which="tri") -> tri + c("food","para1","para2","tri") +} Modified: pkg/pompExamples/man/budmoth.Rd =================================================================== --- pkg/pompExamples/man/budmoth.Rd 2014-12-17 19:12:15 UTC (rev 1022) +++ pkg/pompExamples/man/budmoth.Rd 2014-12-17 19:12:21 UTC (rev 1023) @@ -1,26 +1,17 @@ \name{budmoth} +\docType{data} \alias{budmoth.sim} \title{Larch budmoth model POMPs with real and simulated data.} \description{ - \code{budmoth.sim} constructs a \code{pomp} object containing the larch budmoth model and simulated budmoth density, parasitism rate, and food quality (needle-length) data. + \code{pompExample(budmoth.sim)} constructs a \code{pomp} object containing the larch budmoth model and simulated budmoth density, parasitism rate, and food quality (needle-length) data. Four datasets, representing four distinct parameter regimes, are avaiable. } -\usage{ -budmoth.sim(which) -} -\arguments{ - \item{which}{ - dataset to load given as a name or literal character string. - Evoked without an argument, \code{budmoth.sim} lists all available datasets. - } -} \examples{ -budmoth.sim() ## print a list of all available datasets ## three regimes, high and low noise regimes for parasitism and tritrophic -plot(budmoth.sim(food)) -plot(budmoth.sim(para1)) -plot(budmoth.sim(para2)) -plot(budmoth.sim("tri")) +bm <- pompExample(budmoth,envir=NULL) +plot(bm$food) +plot(bm$para1) +plot(bm$para2) +plot(bm$tri) } -\seealso{the \dQuote{budmoth-model} vignette} \keyword{datasets} Modified: pkg/pompExamples/tests/budmoth.R =================================================================== --- pkg/pompExamples/tests/budmoth.R 2014-12-17 19:12:15 UTC (rev 1022) +++ pkg/pompExamples/tests/budmoth.R 2014-12-17 19:12:21 UTC (rev 1023) @@ -2,18 +2,18 @@ all <- c("food","para1","para2","tri") -sapply(all,function(n)eval(bquote(budmoth.sim(.(n))))) -> bm +bm <- pompExample(budmoth,envir=NULL) names(bm) x <- lapply(bm,as,"data.frame") print(lapply(x,tail)) -y <- simulate(budmoth.sim(food),seed=3434996L,as.data.frame=TRUE) +y <- simulate(bm$food,seed=3434996L,as.data.frame=TRUE) tail(y) -z <- trajectory(budmoth.sim(tri),as.data.frame=TRUE) +z <- trajectory(bm$tri,as.data.frame=TRUE) tail(z) -pf <- pfilter(budmoth.sim(food),seed=34348885L,Np=1000) +pf <- pfilter(bm$para1,seed=34348885L,Np=1000) logLik(pf) Modified: pkg/pompExamples/tests/budmoth.Rout.save =================================================================== --- pkg/pompExamples/tests/budmoth.Rout.save 2014-12-17 19:12:15 UTC (rev 1022) +++ pkg/pompExamples/tests/budmoth.Rout.save 2014-12-17 19:12:21 UTC (rev 1023) @@ -1,6 +1,6 @@ -R version 3.0.1 (2013-05-16) -- "Good Sport" -Copyright (C) 2013 The R Foundation for Statistical Computing +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. @@ -17,13 +17,12 @@ > library(pompExamples) Loading required package: pomp -Loading required package: mvtnorm Loading required package: subplex -Loading required package: deSolve +Loading required package: nloptr > > all <- c("food","para1","para2","tri") > -> sapply(all,function(n)eval(bquote(budmoth.sim(.(n))))) -> bm +> bm <- pompExample(budmoth,envir=NULL) > > names(bm) [1] "food" "para1" "para2" "tri" @@ -95,7 +94,7 @@ 61 0.4828455 22.35338 1.429722 > -> y <- simulate(budmoth.sim(food),seed=3434996L,as.data.frame=TRUE) +> y <- simulate(bm$food,seed=3434996L,as.data.frame=TRUE) > tail(y) time Qobs Nobs Sobs Q N S 56 55 24.75707 1.2571930 0.0536837100 0.6960924 0.6909030 0.0655207892 @@ -112,7 +111,7 @@ 60 0.4994891 5.038971 1.0048781 1 61 0.4818151 4.973050 0.9217527 1 > -> z <- trajectory(budmoth.sim(tri),as.data.frame=TRUE) +> z <- trajectory(bm$tri,as.data.frame=TRUE) > tail(z) Q N S Alpha Lambda A time traj 56 0.9795835 16.9946885 0.0001199655 0.5 22 1.7 55 1 @@ -122,10 +121,10 @@ 60 0.8998638 0.5133800 0.1500321097 0.5 22 1.7 59 1 61 0.9448503 3.3848665 0.1205147616 0.5 22 1.7 60 1 > -> pf <- pfilter(budmoth.sim(food),seed=34348885L,Np=1000) +> pf <- pfilter(bm$para1,seed=34348885L,Np=1000) > logLik(pf) -[1] 360.1747 +[1] 10.68836 > > proc.time() user system elapsed - 0.604 0.064 0.689 + 0.649 0.033 0.670 Modified: pkg/pompExamples/tests/examples.R =================================================================== --- pkg/pompExamples/tests/examples.R 2014-12-17 19:12:15 UTC (rev 1022) +++ pkg/pompExamples/tests/examples.R 2014-12-17 19:12:21 UTC (rev 1023) @@ -23,6 +23,6 @@ pf <- pfilter(simulate(po$parus),Np=100,max.fail=Inf) po <- pompExample(bbp,envir=NULL) -pf <- pfilter(simulate(pf$bbp),Np=100,max.fail=Inf) +pf <- pfilter(simulate(po$bbp),Np=100,max.fail=Inf) ## dev.off() From noreply at r-forge.r-project.org Wed Dec 17 20:12:26 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 17 Dec 2014 20:12:26 +0100 (CET) Subject: [Pomp-commits] r1024 - pkg/pompExamples/man Message-ID: <20141217191227.0243D183E26@r-forge.r-project.org> Author: kingaa Date: 2014-12-17 20:12:26 +0100 (Wed, 17 Dec 2014) New Revision: 1024 Modified: pkg/pompExamples/man/budmoth.Rd Log: - update budmoth model documentation Modified: pkg/pompExamples/man/budmoth.Rd =================================================================== --- pkg/pompExamples/man/budmoth.Rd 2014-12-17 19:12:21 UTC (rev 1023) +++ pkg/pompExamples/man/budmoth.Rd 2014-12-17 19:12:26 UTC (rev 1024) @@ -4,8 +4,43 @@ \title{Larch budmoth model POMPs with real and simulated data.} \description{ \code{pompExample(budmoth.sim)} constructs a \code{pomp} object containing the larch budmoth model and simulated budmoth density, parasitism rate, and food quality (needle-length) data. - Four datasets, representing four distinct parameter regimes, are avaiable. + Four datasets, representing four distinct parameter regimes, are available. + + The model has three state variables: + \enumerate{ + \item{\eqn{Q_t} (measure of food quality on \eqn{[0,1]})} + \item{\eqn{N_t} (budmoth density)} + \item{\eqn{S_t} (fraction of budmoth larvae infected with parasitoids)} + } + + There are three observables: + \enumerate{ + \item{\eqn{\hat Q_t} (needle length)} + \item{\eqn{\hat N_t}} + \item{\eqn{\hat S_t}} + } } +\section{State process}{ + Uncorrelated random effects, for \eqn{t=1,\dots,T}: + \deqn{\alpha_t \sim \mathrm{LogitNormal}(\mathrm{logit}(\alpha),\sigma_{\alpha}^2)} + \deqn{\lambda_t \sim \mathrm{Gamma}(\lambda,\sigma_{\lambda}^2)} + \deqn{a_t \sim \mathrm{LogNormal}(\log(a),\sigma_{a}^2)} + Note: \eqn{X} is \eqn{\mathrm{LogitNormal}(\mu,\sigma)} if \eqn{\mathrm{logit}(X)} is \eqn{\mathrm{Normal}(\mu,\sigma)}. + + The inverse of \eqn{\mathrm{logit}} is \eqn{\mathrm{expit}}. + \pkg{R} functions \code{logit}, \code{expit}, \code{rlogitnorm}, \code{dlogitnorm} are defined in \pkg{pompExamples}. + + The state process, for \eqn{t=1,\dots,T}: + \deqn{Q_{t} = (1-\alpha_{t})\frac{\gamma}{\gamma+N_{t-1}} +\alpha_{t}Q_{t-1}} + \deqn{N_{t} = \lambda_t N_{t-1} (1-S_{t-1})\exp\big\{-gN_{t-1}-\delta(1-Q_{t-1})\big\}} + \deqn{S_{t} = 1-\exp\left(\frac{-a_tS_{t-1}N_{t-1}}{1+a_twS_{t-1}N_{t-1}} \right)} +} +\section{Measurement process}{ + For \eqn{t=1,\dots,T}: + \deqn{\hat Q_t \sim \mathrm{LogNormal}(\log(\beta_0+\beta_1Q_t),\sigma_Q)} + \deqn{\hat N_t \sim \mathrm{LogNormal}(\log(N_t),\sigma_N)} + \deqn{\hat S_t \sim \mathrm{LogitNormal}(\mathrm{logit}(uS_t),\sigma_S)} +} \examples{ ## three regimes, high and low noise regimes for parasitism and tritrophic bm <- pompExample(budmoth,envir=NULL) @@ -14,4 +49,4 @@ plot(bm$para2) plot(bm$tri) } -\keyword{datasets} +\keyword{models} From noreply at r-forge.r-project.org Wed Dec 17 20:12:31 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 17 Dec 2014 20:12:31 +0100 (CET) Subject: [Pomp-commits] r1025 - in pkg/pompExamples: inst/examples man Message-ID: <20141217191231.C2C2B183E26@r-forge.r-project.org> Author: kingaa Date: 2014-12-17 20:12:31 +0100 (Wed, 17 Dec 2014) New Revision: 1025 Added: pkg/pompExamples/man/parus.Rd Modified: pkg/pompExamples/inst/examples/parus.R pkg/pompExamples/man/pertussis.Rd Log: - improve documentation Modified: pkg/pompExamples/inst/examples/parus.R =================================================================== --- pkg/pompExamples/inst/examples/parus.R 2014-12-17 19:12:26 UTC (rev 1024) +++ pkg/pompExamples/inst/examples/parus.R 2014-12-17 19:12:31 UTC (rev 1025) @@ -1,14 +1,7 @@ -#' Annual *Parus major* counts in Wytham Wood, Oxfordshire, England. -#' -#' @param proc the process model (Gompertz or Ricker are currently supported) -#' @param meas the measurement model -#' (lognormal, negative binomial, and Poisson are currently supported) -#' @references McCleery, R. & Perrins, C. (1991) -#' Effects of predation on the numbers of Great Tits, Parus major. -#' In: Bird Population Studies, -#' edited by Perrins, C.M., Lebreton, J.-D. & Hirons, G.J.M. -#' Oxford. Univ. Press. pp. 129--147. -#' @author Aaron A. King \email{kingaa@@umich.edu} +# Annual *Parus major* counts in Wytham Wood, Oxfordshire, England. +# +# 'proc' specifies the process model (Gompertz or Ricker currently supported) +# 'meas' specifies the measurement model (lognormal, negbin, or Poisson) require(pomp) @@ -108,6 +101,6 @@ ) } -parus <- parus.example(proc=proc,meas=meas) +parus <- parus.example(proc,meas) c("parus") Added: pkg/pompExamples/man/parus.Rd =================================================================== --- pkg/pompExamples/man/parus.Rd (rev 0) +++ pkg/pompExamples/man/parus.Rd 2014-12-17 19:12:31 UTC (rev 1025) @@ -0,0 +1,41 @@ +\name{parus} +\docType{data} +\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. + + The model has one state variables, \eqn{N_t}, the true abundance. + There is one observable, \eqn{\mathrm{pop}_t}. +} +\section{State process}{ + If \code{proc="Gompertz"}, the state process is the stochastic Gompertz model + \deqn{N_{t} = K^{1-S}\,N_{t-1}^S\,\epsilon_t,} + where \eqn{S=e^r} and \eqn{\epsilon_t\sim\mathrm{Lognormal}(0,\sigma)} i.i.d. + + If \code{proc="Ricker"}, the state process is the stochastic Ricker model + \deqn{N_{t} = N_{t-1}\,\exp\left(r\,\left(1-\frac{N_{t-1}}{K}\right)\right)\,\epsilon_t,} + where, again, \eqn{\epsilon_t\sim\mathrm{Lognormal}(0,\sigma)} i.i.d. +} +\section{Measurement process}{ + There are three alternative measurement models. + + If \code{meas="Poisson"}, the measurement process is + \deqn{\mathrm{pop}_{t} \sim \mathrm{Poisson}(N_t).} + + If \code{meas="negbin"}, the measurement process is + \deqn{\mathrm{pop}_{t} \sim \mathrm{Negbin}(N_t,\theta),} + i.e., \eqn{\mathrm{pop}_t} has mean \eqn{N_t} and variance \eqn{N_t+\frac{N_t^2}{\theta}}. + + If \code{meas="lognormal"}, the measurement process is + \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,proc="Gompertz",meas="lognormal") +plot(simulate(parus)) +} +\keyword{models,datasets} Modified: pkg/pompExamples/man/pertussis.Rd =================================================================== --- pkg/pompExamples/man/pertussis.Rd 2014-12-17 19:12:26 UTC (rev 1024) +++ pkg/pompExamples/man/pertussis.Rd 2014-12-17 19:12:31 UTC (rev 1025) @@ -21,4 +21,4 @@ plot(pertussis.sim("full.big")) } \seealso{the \dQuote{pertussis-model} vignette} -\keyword{datasets} +\keyword{models} From noreply at r-forge.r-project.org Wed Dec 17 20:12:36 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 17 Dec 2014 20:12:36 +0100 (CET) Subject: [Pomp-commits] r1026 - pkg/pompExamples/tests Message-ID: <20141217191236.686DD183E26@r-forge.r-project.org> Author: kingaa Date: 2014-12-17 20:12:36 +0100 (Wed, 17 Dec 2014) New Revision: 1026 Modified: pkg/pompExamples/tests/examples.R Log: - include parus and Bombay plague (bbp) examples Modified: pkg/pompExamples/tests/examples.R =================================================================== --- pkg/pompExamples/tests/examples.R 2014-12-17 19:12:31 UTC (rev 1025) +++ pkg/pompExamples/tests/examples.R 2014-12-17 19:12:36 UTC (rev 1026) @@ -1,8 +1,5 @@ library(pompExamples) -## pdf.options(useDingbats=FALSE) -## pdf(file="examples.pdf") - set.seed(47575684L) po <- pompExample(parus,proc="Ricker",meas="lognormal",envir=NULL) @@ -22,7 +19,5 @@ po <- pompExample(parus,proc="Gompertz",meas="lognormal",envir=NULL) pf <- pfilter(simulate(po$parus),Np=100,max.fail=Inf) -po <- pompExample(bbp,envir=NULL) -pf <- pfilter(simulate(po$bbp),Np=100,max.fail=Inf) - -## dev.off() +pompExample(bbp) +pf <- pfilter(simulate(bbp),Np=100,max.fail=Inf) From noreply at r-forge.r-project.org Wed Dec 17 20:12:41 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 17 Dec 2014 20:12:41 +0100 (CET) Subject: [Pomp-commits] r1027 - in pkg/pompExamples: . inst/examples src tests Message-ID: <20141217191241.E31E4183E26@r-forge.r-project.org> Author: kingaa Date: 2014-12-17 20:12:41 +0100 (Wed, 17 Dec 2014) New Revision: 1027 Added: pkg/pompExamples/src/bbp.c Modified: pkg/pompExamples/DESCRIPTION pkg/pompExamples/inst/examples/bbp.R pkg/pompExamples/tests/examples.R pkg/pompExamples/tests/pertussis.Rout.save Log: - work on Bombay plague example Modified: pkg/pompExamples/DESCRIPTION =================================================================== --- pkg/pompExamples/DESCRIPTION 2014-12-17 19:12:36 UTC (rev 1026) +++ pkg/pompExamples/DESCRIPTION 2014-12-17 19:12:41 UTC (rev 1027) @@ -17,7 +17,6 @@ URL: http://pomp.r-forge.r-project.org Description: More 'pomp' examples. Depends: R(>= 3.0.0), stats, graphics, pomp(>= 0.49-1) -Suggests: Rmpi,mpifarm,plyr,reshape2,ggplot2,xtable License: GPL (>= 2) LazyData: false BuildVignettes: true Modified: pkg/pompExamples/inst/examples/bbp.R =================================================================== --- pkg/pompExamples/inst/examples/bbp.R 2014-12-17 19:12:36 UTC (rev 1026) +++ pkg/pompExamples/inst/examples/bbp.R 2014-12-17 19:12:41 UTC (rev 1027) @@ -63,12 +63,23 @@ y += dy + beta*X*(dW+beta*X*ito); n += dn; " + ), + delta.t=1/24/7 ), - delta.t=1/24), + skeleton=Csnippet(" + double X = exp(x); + double Y = exp(y); + Dx = mu*(1.0/X-1)+(delta-beta)*Y; + Dy = beta*X+delta*(Y-1)-gamma-mu; + Dn = -delta*Y; + " + ), + skeleton.type="vectorfield", paramnames=c("beta","delta","mu","gamma","sigma","theta","ratio"), statenames=c("x","y","n"), - measurement.model=deaths~nbinom(mu=ratio*exp(y),size=theta), - logvar=c("beta","delta","ratio","sigma","theta"), + rmeasure=Csnippet("deaths=rnbinom_mu(theta,ratio*exp(y));"), + dmeasure=Csnippet("lik=dnbinom_mu(deaths,theta,ratio*exp(y),give_log);"), + logvar=c("beta","delta","ratio","sigma","theta","mu"), logitvar=c("y0"), parameter.inv.transform=function (params, logvar, logitvar, ...) { params[logvar] <- log(params[logvar]) Added: pkg/pompExamples/src/bbp.c =================================================================== --- pkg/pompExamples/src/bbp.c (rev 0) +++ pkg/pompExamples/src/bbp.c 2014-12-17 19:12:41 UTC (rev 1027) @@ -0,0 +1,103 @@ +/* pomp model file: _bombay_plague */ + +#include +#include + + +#define Beta (__p[__parindex[0]]) +#define delta (__p[__parindex[1]]) +#define mu (__p[__parindex[2]]) +#define gamma (__p[__parindex[3]]) +#define sigma (__p[__parindex[4]]) +#define theta (__p[__parindex[5]]) +#define ratio (__p[__parindex[6]]) +#define x (__x[__stateindex[0]]) +#define y (__x[__stateindex[1]]) +#define n (__x[__stateindex[2]]) +#define deaths (__y[__obsindex[0]]) +#define Dx (__f[__stateindex[0]]) +#define Dy (__f[__stateindex[1]]) +#define Dn (__f[__stateindex[2]]) +#define TBeta (__pt[__parindex[0]]) +#define Tdelta (__pt[__parindex[1]]) +#define Tmu (__pt[__parindex[2]]) +#define Tgamma (__pt[__parindex[3]]) +#define Tsigma (__pt[__parindex[4]]) +#define Ttheta (__pt[__parindex[5]]) +#define Tratio (__pt[__parindex[6]]) +#define lik (__lik[0]) + +void _bombay_plague_rmeasure (double *__y, double *__x, double *__p, int *__obsindex, int *__stateindex, int *__parindex, int *__covindex, int __ncovars, double *__covars, double t) +{ + deaths=rnbinom_mu(theta,ratio*exp(y)); +} + + +void _bombay_plague_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) +{ + lik=dnbinom_mu(deaths,theta,ratio*exp(y),give_log); +} + + +void _bombay_plague_stepfn (double *__x, const double *__p, const int *__stateindex, const int *__parindex, const int *__covindex, int __covdim, const double *__covars, double t, double dt) +{ + + double X = exp(x); + double Y = exp(y); + double dx, dy, dn, dW, ito; + dx = (mu*(1.0/X-1)+(delta-Beta)*Y)*dt; + dy = (Beta*X+delta*(Y-1)-gamma-mu)*dt; + dn = -delta*Y*dt; + dW = rnorm(0,sigma*sqrt(dt)); + ito = 0.5*sigma*sigma*dt; + x += dx - Beta*Y*(dW-Beta*Y*ito); + y += dy + Beta*X*(dW+Beta*X*ito); + n += dn; + +} + + +void _bombay_plague_skelfn (double *__f, double *__x, double *__p, int *__stateindex, int *__parindex, int *__covindex, int __ncovars, double *__covars, double t) +{ + + double X = exp(x); + double Y = exp(y); + Dx = mu*(1.0/X-1)+(delta-Beta)*Y; + Dy = Beta*X+delta*(Y-1)-gamma-mu; + Dn = -delta*Y; + +} + + +void _bombay_plague_rprior (double *__p, int *__parindex) +{ + error("'rprior' not defined"); +} + + +void _bombay_plague_dprior (double *__lik, double *__p, int give_log, int *__parindex) +{ + error("'dprior' not defined"); +} + +#undef Beta +#undef delta +#undef mu +#undef gamma +#undef sigma +#undef theta +#undef ratio +#undef x +#undef y +#undef n +#undef deaths +#undef Dx +#undef Dy +#undef Dn +#undef TBeta +#undef Tdelta +#undef Tmu +#undef Tgamma +#undef Tsigma +#undef Ttheta +#undef Tratio Modified: pkg/pompExamples/tests/examples.R =================================================================== --- pkg/pompExamples/tests/examples.R 2014-12-17 19:12:36 UTC (rev 1026) +++ pkg/pompExamples/tests/examples.R 2014-12-17 19:12:41 UTC (rev 1027) @@ -21,3 +21,4 @@ pompExample(bbp) pf <- pfilter(simulate(bbp),Np=100,max.fail=Inf) +tj <- trajectory(bbp) Modified: pkg/pompExamples/tests/pertussis.Rout.save =================================================================== --- pkg/pompExamples/tests/pertussis.Rout.save 2014-12-17 19:12:36 UTC (rev 1026) +++ pkg/pompExamples/tests/pertussis.Rout.save 2014-12-17 19:12:41 UTC (rev 1027) @@ -1,5 +1,5 @@ -R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" +R Under development (unstable) (2014-12-14 r67168) -- "Unsuffered Consequences" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -146,7 +146,7 @@ > > system.time(pf <- pfilter(pertussis.sim(full.small),seed=3445886L,Np=1000)) user system elapsed - 18.793 0.000 18.864 + 17.801 0.004 17.861 > logLik(pf) [1] -3829.33 > @@ -170,4 +170,4 @@ > > proc.time() user system elapsed - 19.533 0.040 19.671 + 18.657 0.060 18.801 From noreply at r-forge.r-project.org Thu Dec 18 03:21:20 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 18 Dec 2014 03:21:20 +0100 (CET) Subject: [Pomp-commits] r1028 - pkg/pompExamples Message-ID: <20141218022120.961F21855E9@r-forge.r-project.org> Author: kingaa Date: 2014-12-18 03:21:18 +0100 (Thu, 18 Dec 2014) New Revision: 1028 Modified: pkg/pompExamples/DESCRIPTION Log: - bump Modified: pkg/pompExamples/DESCRIPTION =================================================================== --- pkg/pompExamples/DESCRIPTION 2014-12-17 19:12:41 UTC (rev 1027) +++ pkg/pompExamples/DESCRIPTION 2014-12-18 02:21:18 UTC (rev 1028) @@ -2,7 +2,7 @@ Type: Package Title: Additional pomp examples Version: 0.24-1 -Date: 2014-12-16 +Date: 2014-12-17 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 Thu Dec 18 13:04:40 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 18 Dec 2014 13:04:40 +0100 (CET) Subject: [Pomp-commits] r1029 - pkg/pompExamples/man Message-ID: <20141218120440.6E04B187904@r-forge.r-project.org> Author: kingaa Date: 2014-12-18 13:04:39 +0100 (Thu, 18 Dec 2014) New Revision: 1029 Modified: pkg/pompExamples/man/budmoth.Rd pkg/pompExamples/man/parus.Rd Log: - temporarily turn off checking of examples in budmoth.Rd and parus.Rd Modified: pkg/pompExamples/man/budmoth.Rd =================================================================== --- pkg/pompExamples/man/budmoth.Rd 2014-12-18 02:21:18 UTC (rev 1028) +++ pkg/pompExamples/man/budmoth.Rd 2014-12-18 12:04:39 UTC (rev 1029) @@ -43,10 +43,12 @@ } \examples{ ## three regimes, high and low noise regimes for parasitism and tritrophic +\dontrun{ bm <- pompExample(budmoth,envir=NULL) plot(bm$food) plot(bm$para1) plot(bm$para2) plot(bm$tri) } +} \keyword{models} Modified: pkg/pompExamples/man/parus.Rd =================================================================== --- pkg/pompExamples/man/parus.Rd 2014-12-18 02:21:18 UTC (rev 1028) +++ pkg/pompExamples/man/parus.Rd 2014-12-18 12:04:39 UTC (rev 1029) @@ -31,6 +31,7 @@ \deqn{\mathrm{pop}_{t} \sim \mathrm{Lognormal}(\log(N_t),\theta).} } \examples{ +\dontrun{ pompExample(parus,proc="Ricker",meas="negbin") plot(parus) plot(simulate(parus)) @@ -38,4 +39,5 @@ pompExample(parus,proc="Gompertz",meas="lognormal") plot(simulate(parus)) } +} \keyword{models,datasets} From noreply at r-forge.r-project.org Thu Dec 18 15:55:14 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 18 Dec 2014 15:55:14 +0100 (CET) Subject: [Pomp-commits] r1030 - pkg/pompExamples/tests Message-ID: <20141218145514.7765B185953@r-forge.r-project.org> Author: kingaa Date: 2014-12-18 15:55:14 +0100 (Thu, 18 Dec 2014) New Revision: 1030 Removed: pkg/pompExamples/tests/budmoth.R pkg/pompExamples/tests/budmoth.Rout.save pkg/pompExamples/tests/examples.R pkg/pompExamples/tests/pertussis.R pkg/pompExamples/tests/pertussis.Rout.save Log: - remove tests directory as a temporary measure Deleted: pkg/pompExamples/tests/budmoth.R =================================================================== --- pkg/pompExamples/tests/budmoth.R 2014-12-18 12:04:39 UTC (rev 1029) +++ pkg/pompExamples/tests/budmoth.R 2014-12-18 14:55:14 UTC (rev 1030) @@ -1,19 +0,0 @@ -library(pompExamples) - -all <- c("food","para1","para2","tri") - -bm <- pompExample(budmoth,envir=NULL) - -names(bm) -x <- lapply(bm,as,"data.frame") - -print(lapply(x,tail)) - -y <- simulate(bm$food,seed=3434996L,as.data.frame=TRUE) -tail(y) - -z <- trajectory(bm$tri,as.data.frame=TRUE) -tail(z) - -pf <- pfilter(bm$para1,seed=34348885L,Np=1000) -logLik(pf) Deleted: pkg/pompExamples/tests/budmoth.Rout.save =================================================================== --- pkg/pompExamples/tests/budmoth.Rout.save 2014-12-18 12:04:39 UTC (rev 1029) +++ pkg/pompExamples/tests/budmoth.Rout.save 2014-12-18 14:55:14 UTC (rev 1030) @@ -1,130 +0,0 @@ - -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(pompExamples) -Loading required package: pomp -Loading required package: subplex -Loading required package: nloptr -> -> all <- c("food","para1","para2","tri") -> -> bm <- pompExample(budmoth,envir=NULL) -> -> names(bm) -[1] "food" "para1" "para2" "tri" -> x <- lapply(bm,as,"data.frame") -> -> print(lapply(x,tail)) -$food - time Qobs Nobs Sobs Q N S -56 55 28.90370 20.4806075 2.870679e-05 0.8502012 19.7570009 0.0000257055 -57 56 25.04577 17.2422706 4.340917e-04 0.6794912 14.4355348 0.0005305078 -58 57 21.68427 2.1931554 7.856243e-03 0.6288764 1.9239332 0.0079677582 -59 58 27.25406 0.3103408 1.348361e-02 0.7899212 0.1973302 0.0141600465 -60 59 32.38417 0.1216027 3.499077e-03 0.8898312 0.1200628 0.0032722573 -61 60 32.80127 0.1632687 3.512564e-04 0.9346055 0.1908352 0.0003751743 - Alpha Lambda A -56 0.5413771 4.932935 0.8677828 -57 0.5082460 4.851747 1.0428964 -58 0.4871643 4.388592 1.0444642 -59 0.4316777 4.394991 0.9302542 -60 0.5012195 5.063878 1.1726507 -61 0.5703106 4.810311 0.9525775 - -$para1 - time Qobs Nobs Sobs Q N S -56 55 28.45210 0.01658405 0.498973510 0.8126219 0.02020849 0.573040310 -57 56 32.58924 0.27733546 0.018765592 0.9177534 0.17066444 0.022035629 -58 57 33.73454 5.79328447 0.005823772 0.9567875 3.49854944 0.005907819 -59 58 33.57238 46.79128317 0.030243114 0.9456880 56.35560023 0.033871059 -60 59 25.61890 7.50489123 0.791479385 0.7153921 12.65588781 0.871324054 -61 60 26.46555 8.12880629 0.894923272 0.7569961 11.25818628 0.992799332 - Alpha Lambda A -56 0.4707325 21.78521 1.754212 -57 0.4377213 21.75771 1.930505 -58 0.5049253 22.14170 1.576733 -59 0.4996302 21.90574 1.675765 -60 0.5157446 21.68244 1.551352 -61 0.4964261 21.93769 1.721177 - -$para2 - time Qobs Nobs Sobs Q N S -56 55 33.87640 15.747819 2.248998e-06 0.9749960 6.921067 2.575005e-06 -57 56 33.94564 50.157117 1.166632e-05 0.9265344 33.878434 1.350848e-05 -58 57 26.54568 39.257279 7.764646e-04 0.7668865 21.145329 1.028206e-03 -59 58 25.06245 37.080107 1.942558e-02 0.7334130 32.430161 2.124212e-02 -60 59 24.65754 10.630755 8.364070e-01 0.6707489 14.812001 9.357010e-01 -61 60 26.63838 2.623661 8.898155e-01 0.7198956 2.691147 9.968919e-01 - Alpha Lambda A -56 0.5034550 4.475840 0.7140993 -57 0.4982577 8.622703 0.7018725 -58 0.5168533 9.734355 2.2460464 -59 0.4777904 9.364085 0.9906918 -60 0.5059549 7.138668 6.7705675 -61 0.5120129 10.895242 3.1116150 - -$tri - time Qobs Nobs Sobs Q N S -56 55 33.36428 5.9679756 3.009644e-06 0.9830185 17.7373560 2.949154e-06 -57 56 29.34035 68.3377210 7.255485e-05 0.8608373 80.4984855 8.681423e-05 -58 57 21.75336 1.2686716 8.552474e-03 0.6310693 0.7176525 9.751675e-03 -59 58 29.15848 0.3500365 1.047452e-02 0.8025905 0.3723865 1.256469e-02 -60 59 32.98213 1.6128525 6.718390e-03 0.8941107 1.0912736 7.410424e-03 -61 60 33.51183 13.0954506 1.173616e-02 0.9378258 7.6959192 1.147648e-02 - Alpha Lambda A -56 0.4833379 21.87970 1.738908 -57 0.5010435 22.22843 1.640583 -58 0.5190030 22.45659 1.404177 -59 0.5165432 22.20828 1.810056 -60 0.5183574 22.01444 1.591250 -61 0.4828455 22.35338 1.429722 - -> -> y <- simulate(bm$food,seed=3434996L,as.data.frame=TRUE) -> tail(y) - time Qobs Nobs Sobs Q N S -56 55 24.75707 1.2571930 0.0536837100 0.6960924 0.6909030 0.0655207892 -57 56 29.35042 0.2081742 0.0312580513 0.8328430 0.1516087 0.0367590933 -58 57 29.68381 0.1063595 0.0058573296 0.9128312 0.1262158 0.0061363639 -59 58 33.43385 0.6853961 0.0007332514 0.9501525 0.2684836 0.0007689092 -60 59 32.70001 1.8683455 0.0002049072 0.9684718 0.8167865 0.0002084246 -61 60 33.33550 1.4268639 0.0001321697 0.9644772 2.9148822 0.0001579051 - Alpha Lambda A sim -56 0.4386467 5.049427 1.0766197 1 -57 0.4944825 4.972702 0.8273030 1 -58 0.4989262 4.612384 1.1043024 1 -59 0.5386598 5.130300 0.9918653 1 -60 0.4994891 5.038971 1.0048781 1 -61 0.4818151 4.973050 0.9217527 1 -> -> z <- trajectory(bm$tri,as.data.frame=TRUE) -> tail(z) - Q N S Alpha Lambda A time traj -56 0.9795835 16.9946885 0.0001199655 0.5 22 1.7 55 1 -57 0.8629557 78.2636478 0.0034591173 0.5 22 1.7 56 1 -58 0.6263889 0.8320401 0.3498223901 0.5 22 1.7 57 1 -59 0.8050102 0.2655329 0.3691104688 0.5 22 1.7 58 1 -60 0.8998638 0.5133800 0.1500321097 0.5 22 1.7 59 1 -61 0.9448503 3.3848665 0.1205147616 0.5 22 1.7 60 1 -> -> pf <- pfilter(bm$para1,seed=34348885L,Np=1000) -> logLik(pf) -[1] 10.68836 -> -> proc.time() - user system elapsed - 0.649 0.033 0.670 Deleted: pkg/pompExamples/tests/examples.R =================================================================== --- pkg/pompExamples/tests/examples.R 2014-12-18 12:04:39 UTC (rev 1029) +++ pkg/pompExamples/tests/examples.R 2014-12-18 14:55:14 UTC (rev 1030) @@ -1,24 +0,0 @@ -library(pompExamples) - -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) - -po <- pompExample(parus,proc="Ricker",meas="negbin",envir=NULL) -pf <- pfilter(simulate(po$parus),Np=100,max.fail=Inf) - -po <- pompExample(parus,proc="Ricker",meas="Poisson",envir=NULL) -pf <- pfilter(simulate(po$parus),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 <- pompExample(parus,proc="Gompertz",meas="lognormal",envir=NULL) -pf <- pfilter(simulate(po$parus),Np=100,max.fail=Inf) - -pompExample(bbp) -pf <- pfilter(simulate(bbp),Np=100,max.fail=Inf) -tj <- trajectory(bbp) Deleted: pkg/pompExamples/tests/pertussis.R =================================================================== --- pkg/pompExamples/tests/pertussis.R 2014-12-18 12:04:39 UTC (rev 1029) +++ pkg/pompExamples/tests/pertussis.R 2014-12-18 14:55:14 UTC (rev 1030) @@ -1,37 +0,0 @@ -library(pompExamples) - -all <- c("SEIR.small","SEIR.big","SEIRS.small","SEIRS.big","SEIRR.small","SEIRR.big","full.small","full.big") - -sapply(all,function(n)eval(bquote(pertussis.sim(.(n))))) -> pt - -names(pt) -x <- lapply(pt,as.data.frame) - -print(lapply(x,tail)) - -x <- simulate(pertussis.sim(full.big),seed=395885L,as.data.frame=TRUE) -tail(x) - -y <- trajectory(pertussis.sim(SEIRS.small),as.data.frame=TRUE) -tail(y) - -system.time(pf <- pfilter(pertussis.sim(full.small),seed=3445886L,Np=1000)) -logLik(pf) - -pttest <- function (po, digits = 15) { - identical( - signif(coef(po),digits=digits), - signif(partrans(po,partrans(po,coef(po),dir='inv'),dir='for'),digits=digits) - ) -} - -stopifnot(all(sapply(pt,pttest))) - -pttest <- function (po, digits = 15) { - identical( - signif(coef(po,trans=T),digits=digits), - signif(partrans(po,partrans(po,coef(po,trans=T),dir='f'),dir='inv'),digits=digits) - ) -} - -stopifnot(all(sapply(pt,pttest))) Deleted: pkg/pompExamples/tests/pertussis.Rout.save =================================================================== --- pkg/pompExamples/tests/pertussis.Rout.save 2014-12-18 12:04:39 UTC (rev 1029) +++ pkg/pompExamples/tests/pertussis.Rout.save 2014-12-18 14:55:14 UTC (rev 1030) @@ -1,173 +0,0 @@ - -R Under development (unstable) (2014-12-14 r67168) -- "Unsuffered Consequences" -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(pompExamples) -Loading required package: pomp -Loading required package: subplex -Loading required package: nloptr -> -> all <- c("SEIR.small","SEIR.big","SEIRS.small","SEIRS.big","SEIRR.small","SEIRR.big","full.small","full.big") -> -> sapply(all,function(n)eval(bquote(pertussis.sim(.(n))))) -> pt -> -> names(pt) -[1] "SEIR.small" "SEIR.big" "SEIRS.small" "SEIRS.big" "SEIRR.small" -[6] "SEIRR.big" "full.small" "full.big" -> x <- lapply(pt,as.data.frame) -> -> print(lapply(x,tail)) -$SEIR.small - time reports S E I R1 R2 cases W err simpop -1036 19.90385 70 26873 244 409 472429 0 225 0 7 499955 -1037 19.92308 69 26810 239 435 472458 0 221 0 7 499942 -1038 19.94231 54 26797 244 435 472497 0 208 0 7 499973 -1039 19.96154 46 26746 274 417 472542 0 205 0 7 499979 -1040 19.98077 53 26709 256 450 472538 0 228 0 7 499953 -1041 20.00000 71 26679 273 415 472560 0 183 0 7 499927 - -$SEIR.big - time reports S E I R1 R2 cases W err simpop -1036 19.90385 520 255547 1703 2917 4739686 0 1470 0 7 4999853 -1037 19.92308 484 255784 1759 3003 4739211 0 1489 0 7 4999757 -1038 19.94231 406 256081 1856 2995 4738900 0 1444 0 7 4999832 -1039 19.96154 533 256320 1869 3129 4738606 0 1597 0 7 4999924 -1040 19.98077 425 256551 1879 3164 4738317 0 1545 0 7 4999911 -1041 20.00000 412 257106 1639 3151 4738010 0 1495 0 7 4999906 - -$SEIRS.small - time reports S E I R1 R2 cases W err simpop -1036 19.90385 47 80392 539 920 228000 190629 467 0 7 500480 -1037 19.92308 41 80392 578 909 227952 190651 431 0 7 500482 -1038 19.94231 49 80395 591 914 227879 190690 464 0 7 500469 -1039 19.96154 67 80471 575 975 227795 190660 500 0 7 500476 -1040 19.98077 42 80516 553 993 227732 190669 513 0 7 500463 -1041 20.00000 61 80660 492 986 227653 190677 461 0 7 500468 - -$SEIRS.big - time reports S E I R1 R2 cases W err simpop -1036 19.90385 489 773965 5409 9193 2299336 1912393 4484 0 7 5000296 -1037 19.92308 568 774652 5472 9318 2298462 1912401 4574 0 7 5000305 -1038 19.94231 397 775170 5539 9426 2297714 1912390 4671 0 7 5000239 -1039 19.96154 411 775614 5740 9491 2297059 1912330 4609 0 7 5000234 -1040 19.98077 442 776437 5571 9697 2296283 1912273 4748 0 7 5000261 -1041 20.00000 518 778090 4858 9441 2295594 1912196 4335 0 7 5000179 - -$SEIRR.small - time reports S E I R1 R2 cases W err simpop -1036 19.90385 73 64537 864 1441 317687 115760 714 0 7 500289 -1037 19.92308 69 64260 896 1502 318088 115525 758 0 7 500271 -1038 19.94231 76 63954 981 1543 318494 115282 748 0 7 500254 -1039 19.96154 84 63664 965 1638 318953 115037 836 0 7 500257 -1040 19.98077 91 63373 992 1670 319485 114723 802 0 7 500243 -1041 20.00000 81 63266 861 1646 319863 114604 760 0 7 500240 - -$SEIRR.big - time reports S E I R1 R2 cases W err simpop -1036 19.90385 481 641670 4792 7924 3195207 1153657 3925 0 7 5003250 -1037 19.92308 379 642044 5038 8097 3193839 1154198 4018 0 7 5003216 -1038 19.94231 541 642462 5084 8425 3192769 1154480 4217 0 7 5003220 -1039 19.96154 577 642681 5221 8605 3192041 1154729 4331 0 7 5003277 -1040 19.98077 437 643030 5160 8849 3191258 1155014 4418 0 7 5003311 -1041 20.00000 400 644214 4588 8562 3189940 1155983 3884 0 7 5003287 - -$full.small - time reports S E I R1 R2 cases W err simpop -1036 19.90385 38 60812 492 892 330814 107242 437 -9.164189 7 500252 -1037 19.92308 35 60904 514 881 330659 107326 413 -9.153313 7 500284 -1038 19.94231 44 60988 464 873 330490 107453 420 -9.279501 7 500268 -1039 19.96154 46 61032 517 876 330295 107543 398 -9.092366 7 500263 -1040 19.98077 39 61122 504 845 330138 107631 403 -9.103926 7 500240 -1041 20.00000 43 61258 474 820 329898 107806 384 -8.973250 7 500256 - -$full.big - time reports S E I R1 R2 cases W err -1036 19.90385 319 624607 4552 7566 3278019 1088429 3664 -4.654307 7 -1037 19.92308 372 625824 4363 7590 3275577 1089789 3677 -4.795999 7 -1038 19.94231 348 626800 4490 7621 3273350 1090834 3689 -4.774106 7 -1039 19.96154 377 628074 4334 7672 3271128 1091904 3713 -4.848567 7 -1040 19.98077 331 629454 4185 7381 3268762 1093266 3431 -5.014912 7 -1041 20.00000 367 631218 3705 7153 3265743 1095129 3306 -4.966009 7 - simpop -1036 5003173 -1037 5003143 -1038 5003095 -1039 5003112 -1040 5003048 -1041 5002948 - -> -> x <- simulate(pertussis.sim(full.big),seed=395885L,as.data.frame=TRUE) -> tail(x) - time reports S E I R1 R2 cases W err -1036 19.90385 432 662434 5677 9458 3201351 1118149 4831 -0.4801610 7 -1037 19.92308 524 662819 5615 9625 3200616 1118455 4737 -0.6165661 7 -1038 19.94231 396 662918 5888 9754 3200171 1118414 4831 -0.5954462 7 -1039 19.96154 515 663272 5698 9925 3199550 1118678 4928 -0.7923733 7 -1040 19.98077 504 663479 5812 9991 3198989 1118914 4782 -0.8369185 7 -1041 20.00000 529 664560 5030 9867 3197787 1119969 4609 -0.8803061 7 - simpop sim -1036 4997069 1 -1037 4997130 1 -1038 4997145 1 -1039 4997123 1 -1040 4997185 1 -1041 4997213 1 -> -> y <- trajectory(pertussis.sim(SEIRS.small),as.data.frame=TRUE) -> tail(y) - S E I R1 R2 cases W err simpop -1036 81409.73 558.4599 942.3100 227353.0 189736.5 487.2963 0 0 5e+05 -1037 81420.36 573.0107 965.5155 227305.3 189735.8 500.4770 0 0 5e+05 -1038 81418.14 587.5604 989.6877 227269.6 189735.0 513.3168 0 0 5e+05 -1039 81402.73 602.3328 1014.5493 227246.2 189734.2 526.2802 0 0 5e+05 -1040 81415.22 580.7639 1035.4780 227235.2 189733.4 534.7187 0 0 5e+05 -1041 81532.40 510.2405 1002.6699 227222.2 189732.5 478.9785 0 0 5e+05 - time traj -1036 19.90385 1 -1037 19.92308 1 -1038 19.94231 1 -1039 19.96154 1 -1040 19.98077 1 -1041 20.00000 1 -> -> system.time(pf <- pfilter(pertussis.sim(full.small),seed=3445886L,Np=1000)) - user system elapsed - 17.801 0.004 17.861 -> logLik(pf) -[1] -3829.33 -> -> pttest <- function (po, digits = 15) { -+ identical( -+ signif(coef(po),digits=digits), -+ signif(partrans(po,partrans(po,coef(po),dir='inv'),dir='for'),digits=digits) -+ ) -+ } -> -> stopifnot(all(sapply(pt,pttest))) -> -> pttest <- function (po, digits = 15) { -+ identical( -+ signif(coef(po,trans=T),digits=digits), -+ signif(partrans(po,partrans(po,coef(po,trans=T),dir='f'),dir='inv'),digits=digits) -+ ) -+ } -> -> stopifnot(all(sapply(pt,pttest))) -> -> proc.time() - user system elapsed - 18.657 0.060 18.801 From noreply at r-forge.r-project.org Fri Dec 19 20:36:46 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 19 Dec 2014 20:36:46 +0100 (CET) Subject: [Pomp-commits] r1031 - pkg/pompExamples/tests Message-ID: <20141219193646.235A1186509@r-forge.r-project.org> Author: kingaa Date: 2014-12-19 20:36:45 +0100 (Fri, 19 Dec 2014) New Revision: 1031 Added: pkg/pompExamples/tests/budmoth.R pkg/pompExamples/tests/budmoth.Rout.save pkg/pompExamples/tests/examples.R pkg/pompExamples/tests/pertussis.R pkg/pompExamples/tests/pertussis.Rout.save Log: - put tests directory back in This reverts commit c2926f7cdf783d51acf9b01c7233fcce5772e089. Added: pkg/pompExamples/tests/budmoth.R =================================================================== --- pkg/pompExamples/tests/budmoth.R (rev 0) +++ pkg/pompExamples/tests/budmoth.R 2014-12-19 19:36:45 UTC (rev 1031) @@ -0,0 +1,19 @@ +library(pompExamples) + +all <- c("food","para1","para2","tri") + +bm <- pompExample(budmoth,envir=NULL) + +names(bm) +x <- lapply(bm,as,"data.frame") + +print(lapply(x,tail)) + +y <- simulate(bm$food,seed=3434996L,as.data.frame=TRUE) +tail(y) + +z <- trajectory(bm$tri,as.data.frame=TRUE) +tail(z) + +pf <- pfilter(bm$para1,seed=34348885L,Np=1000) +logLik(pf) Added: pkg/pompExamples/tests/budmoth.Rout.save =================================================================== --- pkg/pompExamples/tests/budmoth.Rout.save (rev 0) +++ pkg/pompExamples/tests/budmoth.Rout.save 2014-12-19 19:36:45 UTC (rev 1031) @@ -0,0 +1,130 @@ + +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(pompExamples) +Loading required package: pomp +Loading required package: subplex +Loading required package: nloptr +> +> all <- c("food","para1","para2","tri") +> +> bm <- pompExample(budmoth,envir=NULL) +> +> names(bm) +[1] "food" "para1" "para2" "tri" +> x <- lapply(bm,as,"data.frame") +> +> print(lapply(x,tail)) +$food + time Qobs Nobs Sobs Q N S +56 55 28.90370 20.4806075 2.870679e-05 0.8502012 19.7570009 0.0000257055 +57 56 25.04577 17.2422706 4.340917e-04 0.6794912 14.4355348 0.0005305078 +58 57 21.68427 2.1931554 7.856243e-03 0.6288764 1.9239332 0.0079677582 +59 58 27.25406 0.3103408 1.348361e-02 0.7899212 0.1973302 0.0141600465 +60 59 32.38417 0.1216027 3.499077e-03 0.8898312 0.1200628 0.0032722573 +61 60 32.80127 0.1632687 3.512564e-04 0.9346055 0.1908352 0.0003751743 + Alpha Lambda A +56 0.5413771 4.932935 0.8677828 +57 0.5082460 4.851747 1.0428964 +58 0.4871643 4.388592 1.0444642 +59 0.4316777 4.394991 0.9302542 +60 0.5012195 5.063878 1.1726507 +61 0.5703106 4.810311 0.9525775 + +$para1 + time Qobs Nobs Sobs Q N S +56 55 28.45210 0.01658405 0.498973510 0.8126219 0.02020849 0.573040310 +57 56 32.58924 0.27733546 0.018765592 0.9177534 0.17066444 0.022035629 +58 57 33.73454 5.79328447 0.005823772 0.9567875 3.49854944 0.005907819 +59 58 33.57238 46.79128317 0.030243114 0.9456880 56.35560023 0.033871059 +60 59 25.61890 7.50489123 0.791479385 0.7153921 12.65588781 0.871324054 +61 60 26.46555 8.12880629 0.894923272 0.7569961 11.25818628 0.992799332 + Alpha Lambda A +56 0.4707325 21.78521 1.754212 +57 0.4377213 21.75771 1.930505 +58 0.5049253 22.14170 1.576733 +59 0.4996302 21.90574 1.675765 +60 0.5157446 21.68244 1.551352 +61 0.4964261 21.93769 1.721177 + +$para2 + time Qobs Nobs Sobs Q N S +56 55 33.87640 15.747819 2.248998e-06 0.9749960 6.921067 2.575005e-06 +57 56 33.94564 50.157117 1.166632e-05 0.9265344 33.878434 1.350848e-05 +58 57 26.54568 39.257279 7.764646e-04 0.7668865 21.145329 1.028206e-03 +59 58 25.06245 37.080107 1.942558e-02 0.7334130 32.430161 2.124212e-02 +60 59 24.65754 10.630755 8.364070e-01 0.6707489 14.812001 9.357010e-01 +61 60 26.63838 2.623661 8.898155e-01 0.7198956 2.691147 9.968919e-01 + Alpha Lambda A +56 0.5034550 4.475840 0.7140993 +57 0.4982577 8.622703 0.7018725 +58 0.5168533 9.734355 2.2460464 +59 0.4777904 9.364085 0.9906918 +60 0.5059549 7.138668 6.7705675 +61 0.5120129 10.895242 3.1116150 + +$tri + time Qobs Nobs Sobs Q N S +56 55 33.36428 5.9679756 3.009644e-06 0.9830185 17.7373560 2.949154e-06 +57 56 29.34035 68.3377210 7.255485e-05 0.8608373 80.4984855 8.681423e-05 +58 57 21.75336 1.2686716 8.552474e-03 0.6310693 0.7176525 9.751675e-03 +59 58 29.15848 0.3500365 1.047452e-02 0.8025905 0.3723865 1.256469e-02 +60 59 32.98213 1.6128525 6.718390e-03 0.8941107 1.0912736 7.410424e-03 +61 60 33.51183 13.0954506 1.173616e-02 0.9378258 7.6959192 1.147648e-02 + Alpha Lambda A +56 0.4833379 21.87970 1.738908 +57 0.5010435 22.22843 1.640583 +58 0.5190030 22.45659 1.404177 +59 0.5165432 22.20828 1.810056 +60 0.5183574 22.01444 1.591250 +61 0.4828455 22.35338 1.429722 + +> +> y <- simulate(bm$food,seed=3434996L,as.data.frame=TRUE) +> tail(y) + time Qobs Nobs Sobs Q N S +56 55 24.75707 1.2571930 0.0536837100 0.6960924 0.6909030 0.0655207892 +57 56 29.35042 0.2081742 0.0312580513 0.8328430 0.1516087 0.0367590933 +58 57 29.68381 0.1063595 0.0058573296 0.9128312 0.1262158 0.0061363639 +59 58 33.43385 0.6853961 0.0007332514 0.9501525 0.2684836 0.0007689092 +60 59 32.70001 1.8683455 0.0002049072 0.9684718 0.8167865 0.0002084246 +61 60 33.33550 1.4268639 0.0001321697 0.9644772 2.9148822 0.0001579051 + Alpha Lambda A sim +56 0.4386467 5.049427 1.0766197 1 +57 0.4944825 4.972702 0.8273030 1 +58 0.4989262 4.612384 1.1043024 1 +59 0.5386598 5.130300 0.9918653 1 +60 0.4994891 5.038971 1.0048781 1 +61 0.4818151 4.973050 0.9217527 1 +> +> z <- trajectory(bm$tri,as.data.frame=TRUE) +> tail(z) + Q N S Alpha Lambda A time traj +56 0.9795835 16.9946885 0.0001199655 0.5 22 1.7 55 1 +57 0.8629557 78.2636478 0.0034591173 0.5 22 1.7 56 1 +58 0.6263889 0.8320401 0.3498223901 0.5 22 1.7 57 1 +59 0.8050102 0.2655329 0.3691104688 0.5 22 1.7 58 1 +60 0.8998638 0.5133800 0.1500321097 0.5 22 1.7 59 1 +61 0.9448503 3.3848665 0.1205147616 0.5 22 1.7 60 1 +> +> pf <- pfilter(bm$para1,seed=34348885L,Np=1000) +> logLik(pf) +[1] 10.68836 +> +> proc.time() + user system elapsed + 0.649 0.033 0.670 Added: pkg/pompExamples/tests/examples.R =================================================================== --- pkg/pompExamples/tests/examples.R (rev 0) +++ pkg/pompExamples/tests/examples.R 2014-12-19 19:36:45 UTC (rev 1031) @@ -0,0 +1,24 @@ +library(pompExamples) + +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) + +po <- pompExample(parus,proc="Ricker",meas="negbin",envir=NULL) +pf <- pfilter(simulate(po$parus),Np=100,max.fail=Inf) + +po <- pompExample(parus,proc="Ricker",meas="Poisson",envir=NULL) +pf <- pfilter(simulate(po$parus),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 <- pompExample(parus,proc="Gompertz",meas="lognormal",envir=NULL) +pf <- pfilter(simulate(po$parus),Np=100,max.fail=Inf) + +pompExample(bbp) +pf <- pfilter(simulate(bbp),Np=100,max.fail=Inf) +tj <- trajectory(bbp) Added: pkg/pompExamples/tests/pertussis.R =================================================================== --- pkg/pompExamples/tests/pertussis.R (rev 0) +++ pkg/pompExamples/tests/pertussis.R 2014-12-19 19:36:45 UTC (rev 1031) @@ -0,0 +1,37 @@ +library(pompExamples) + +all <- c("SEIR.small","SEIR.big","SEIRS.small","SEIRS.big","SEIRR.small","SEIRR.big","full.small","full.big") + +sapply(all,function(n)eval(bquote(pertussis.sim(.(n))))) -> pt + +names(pt) +x <- lapply(pt,as.data.frame) + +print(lapply(x,tail)) + +x <- simulate(pertussis.sim(full.big),seed=395885L,as.data.frame=TRUE) +tail(x) + +y <- trajectory(pertussis.sim(SEIRS.small),as.data.frame=TRUE) +tail(y) + +system.time(pf <- pfilter(pertussis.sim(full.small),seed=3445886L,Np=1000)) +logLik(pf) + +pttest <- function (po, digits = 15) { + identical( + signif(coef(po),digits=digits), + signif(partrans(po,partrans(po,coef(po),dir='inv'),dir='for'),digits=digits) + ) +} + +stopifnot(all(sapply(pt,pttest))) + +pttest <- function (po, digits = 15) { + identical( + signif(coef(po,trans=T),digits=digits), + signif(partrans(po,partrans(po,coef(po,trans=T),dir='f'),dir='inv'),digits=digits) + ) +} + +stopifnot(all(sapply(pt,pttest))) Added: pkg/pompExamples/tests/pertussis.Rout.save =================================================================== --- pkg/pompExamples/tests/pertussis.Rout.save (rev 0) +++ pkg/pompExamples/tests/pertussis.Rout.save 2014-12-19 19:36:45 UTC (rev 1031) @@ -0,0 +1,173 @@ + +R Under development (unstable) (2014-12-14 r67168) -- "Unsuffered Consequences" +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(pompExamples) +Loading required package: pomp +Loading required package: subplex +Loading required package: nloptr +> +> all <- c("SEIR.small","SEIR.big","SEIRS.small","SEIRS.big","SEIRR.small","SEIRR.big","full.small","full.big") +> +> sapply(all,function(n)eval(bquote(pertussis.sim(.(n))))) -> pt +> +> names(pt) +[1] "SEIR.small" "SEIR.big" "SEIRS.small" "SEIRS.big" "SEIRR.small" +[6] "SEIRR.big" "full.small" "full.big" +> x <- lapply(pt,as.data.frame) +> +> print(lapply(x,tail)) +$SEIR.small + time reports S E I R1 R2 cases W err simpop +1036 19.90385 70 26873 244 409 472429 0 225 0 7 499955 +1037 19.92308 69 26810 239 435 472458 0 221 0 7 499942 +1038 19.94231 54 26797 244 435 472497 0 208 0 7 499973 +1039 19.96154 46 26746 274 417 472542 0 205 0 7 499979 +1040 19.98077 53 26709 256 450 472538 0 228 0 7 499953 +1041 20.00000 71 26679 273 415 472560 0 183 0 7 499927 + +$SEIR.big + time reports S E I R1 R2 cases W err simpop +1036 19.90385 520 255547 1703 2917 4739686 0 1470 0 7 4999853 +1037 19.92308 484 255784 1759 3003 4739211 0 1489 0 7 4999757 +1038 19.94231 406 256081 1856 2995 4738900 0 1444 0 7 4999832 +1039 19.96154 533 256320 1869 3129 4738606 0 1597 0 7 4999924 +1040 19.98077 425 256551 1879 3164 4738317 0 1545 0 7 4999911 +1041 20.00000 412 257106 1639 3151 4738010 0 1495 0 7 4999906 + +$SEIRS.small + time reports S E I R1 R2 cases W err simpop +1036 19.90385 47 80392 539 920 228000 190629 467 0 7 500480 +1037 19.92308 41 80392 578 909 227952 190651 431 0 7 500482 +1038 19.94231 49 80395 591 914 227879 190690 464 0 7 500469 +1039 19.96154 67 80471 575 975 227795 190660 500 0 7 500476 +1040 19.98077 42 80516 553 993 227732 190669 513 0 7 500463 +1041 20.00000 61 80660 492 986 227653 190677 461 0 7 500468 + +$SEIRS.big + time reports S E I R1 R2 cases W err simpop +1036 19.90385 489 773965 5409 9193 2299336 1912393 4484 0 7 5000296 +1037 19.92308 568 774652 5472 9318 2298462 1912401 4574 0 7 5000305 +1038 19.94231 397 775170 5539 9426 2297714 1912390 4671 0 7 5000239 +1039 19.96154 411 775614 5740 9491 2297059 1912330 4609 0 7 5000234 +1040 19.98077 442 776437 5571 9697 2296283 1912273 4748 0 7 5000261 +1041 20.00000 518 778090 4858 9441 2295594 1912196 4335 0 7 5000179 + +$SEIRR.small + time reports S E I R1 R2 cases W err simpop +1036 19.90385 73 64537 864 1441 317687 115760 714 0 7 500289 +1037 19.92308 69 64260 896 1502 318088 115525 758 0 7 500271 +1038 19.94231 76 63954 981 1543 318494 115282 748 0 7 500254 +1039 19.96154 84 63664 965 1638 318953 115037 836 0 7 500257 +1040 19.98077 91 63373 992 1670 319485 114723 802 0 7 500243 +1041 20.00000 81 63266 861 1646 319863 114604 760 0 7 500240 + +$SEIRR.big + time reports S E I R1 R2 cases W err simpop +1036 19.90385 481 641670 4792 7924 3195207 1153657 3925 0 7 5003250 +1037 19.92308 379 642044 5038 8097 3193839 1154198 4018 0 7 5003216 +1038 19.94231 541 642462 5084 8425 3192769 1154480 4217 0 7 5003220 +1039 19.96154 577 642681 5221 8605 3192041 1154729 4331 0 7 5003277 +1040 19.98077 437 643030 5160 8849 3191258 1155014 4418 0 7 5003311 +1041 20.00000 400 644214 4588 8562 3189940 1155983 3884 0 7 5003287 + +$full.small + time reports S E I R1 R2 cases W err simpop +1036 19.90385 38 60812 492 892 330814 107242 437 -9.164189 7 500252 +1037 19.92308 35 60904 514 881 330659 107326 413 -9.153313 7 500284 +1038 19.94231 44 60988 464 873 330490 107453 420 -9.279501 7 500268 +1039 19.96154 46 61032 517 876 330295 107543 398 -9.092366 7 500263 +1040 19.98077 39 61122 504 845 330138 107631 403 -9.103926 7 500240 +1041 20.00000 43 61258 474 820 329898 107806 384 -8.973250 7 500256 + +$full.big + time reports S E I R1 R2 cases W err +1036 19.90385 319 624607 4552 7566 3278019 1088429 3664 -4.654307 7 +1037 19.92308 372 625824 4363 7590 3275577 1089789 3677 -4.795999 7 +1038 19.94231 348 626800 4490 7621 3273350 1090834 3689 -4.774106 7 +1039 19.96154 377 628074 4334 7672 3271128 1091904 3713 -4.848567 7 +1040 19.98077 331 629454 4185 7381 3268762 1093266 3431 -5.014912 7 +1041 20.00000 367 631218 3705 7153 3265743 1095129 3306 -4.966009 7 + simpop +1036 5003173 +1037 5003143 +1038 5003095 +1039 5003112 +1040 5003048 +1041 5002948 + +> +> x <- simulate(pertussis.sim(full.big),seed=395885L,as.data.frame=TRUE) +> tail(x) + time reports S E I R1 R2 cases W err +1036 19.90385 432 662434 5677 9458 3201351 1118149 4831 -0.4801610 7 +1037 19.92308 524 662819 5615 9625 3200616 1118455 4737 -0.6165661 7 +1038 19.94231 396 662918 5888 9754 3200171 1118414 4831 -0.5954462 7 +1039 19.96154 515 663272 5698 9925 3199550 1118678 4928 -0.7923733 7 +1040 19.98077 504 663479 5812 9991 3198989 1118914 4782 -0.8369185 7 +1041 20.00000 529 664560 5030 9867 3197787 1119969 4609 -0.8803061 7 + simpop sim +1036 4997069 1 +1037 4997130 1 +1038 4997145 1 +1039 4997123 1 +1040 4997185 1 +1041 4997213 1 +> +> y <- trajectory(pertussis.sim(SEIRS.small),as.data.frame=TRUE) +> tail(y) + S E I R1 R2 cases W err simpop +1036 81409.73 558.4599 942.3100 227353.0 189736.5 487.2963 0 0 5e+05 +1037 81420.36 573.0107 965.5155 227305.3 189735.8 500.4770 0 0 5e+05 +1038 81418.14 587.5604 989.6877 227269.6 189735.0 513.3168 0 0 5e+05 +1039 81402.73 602.3328 1014.5493 227246.2 189734.2 526.2802 0 0 5e+05 +1040 81415.22 580.7639 1035.4780 227235.2 189733.4 534.7187 0 0 5e+05 +1041 81532.40 510.2405 1002.6699 227222.2 189732.5 478.9785 0 0 5e+05 + time traj +1036 19.90385 1 +1037 19.92308 1 +1038 19.94231 1 +1039 19.96154 1 +1040 19.98077 1 +1041 20.00000 1 +> +> system.time(pf <- pfilter(pertussis.sim(full.small),seed=3445886L,Np=1000)) + user system elapsed + 17.801 0.004 17.861 +> logLik(pf) +[1] -3829.33 +> +> pttest <- function (po, digits = 15) { ++ identical( ++ signif(coef(po),digits=digits), ++ signif(partrans(po,partrans(po,coef(po),dir='inv'),dir='for'),digits=digits) ++ ) ++ } +> +> stopifnot(all(sapply(pt,pttest))) +> +> pttest <- function (po, digits = 15) { ++ identical( ++ signif(coef(po,trans=T),digits=digits), ++ signif(partrans(po,partrans(po,coef(po,trans=T),dir='f'),dir='inv'),digits=digits) ++ ) ++ } +> +> stopifnot(all(sapply(pt,pttest))) +> +> proc.time() + user system elapsed + 18.657 0.060 18.801 From noreply at r-forge.r-project.org Fri Dec 19 20:36:51 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 19 Dec 2014 20:36:51 +0100 (CET) Subject: [Pomp-commits] r1032 - pkg/pompExamples/man Message-ID: <20141219193651.0A47F186509@r-forge.r-project.org> Author: kingaa Date: 2014-12-19 20:36:50 +0100 (Fri, 19 Dec 2014) New Revision: 1032 Modified: pkg/pompExamples/man/budmoth.Rd pkg/pompExamples/man/parus.Rd Log: - turn back on example checking This reverts commit f2fff9a837b78fa8d20f85cfb7e4dda9214a0c26. Modified: pkg/pompExamples/man/budmoth.Rd =================================================================== --- pkg/pompExamples/man/budmoth.Rd 2014-12-19 19:36:45 UTC (rev 1031) +++ pkg/pompExamples/man/budmoth.Rd 2014-12-19 19:36:50 UTC (rev 1032) @@ -43,12 +43,10 @@ } \examples{ ## three regimes, high and low noise regimes for parasitism and tritrophic -\dontrun{ bm <- pompExample(budmoth,envir=NULL) plot(bm$food) plot(bm$para1) plot(bm$para2) plot(bm$tri) } -} \keyword{models} Modified: pkg/pompExamples/man/parus.Rd =================================================================== --- pkg/pompExamples/man/parus.Rd 2014-12-19 19:36:45 UTC (rev 1031) +++ pkg/pompExamples/man/parus.Rd 2014-12-19 19:36:50 UTC (rev 1032) @@ -31,7 +31,6 @@ \deqn{\mathrm{pop}_{t} \sim \mathrm{Lognormal}(\log(N_t),\theta).} } \examples{ -\dontrun{ pompExample(parus,proc="Ricker",meas="negbin") plot(parus) plot(simulate(parus)) @@ -39,5 +38,4 @@ pompExample(parus,proc="Gompertz",meas="lognormal") plot(simulate(parus)) } -} \keyword{models,datasets} From noreply at r-forge.r-project.org Fri Dec 19 20:36:55 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 19 Dec 2014 20:36:55 +0100 (CET) Subject: [Pomp-commits] r1033 - pkg/pompExamples Message-ID: <20141219193655.A52A6186509@r-forge.r-project.org> Author: kingaa Date: 2014-12-19 20:36:55 +0100 (Fri, 19 Dec 2014) New Revision: 1033 Modified: pkg/pompExamples/DESCRIPTION Log: - update pomp dependency to 0.56-1 Modified: pkg/pompExamples/DESCRIPTION =================================================================== --- pkg/pompExamples/DESCRIPTION 2014-12-19 19:36:50 UTC (rev 1032) +++ pkg/pompExamples/DESCRIPTION 2014-12-19 19:36:55 UTC (rev 1033) @@ -2,7 +2,7 @@ Type: Package Title: Additional pomp examples Version: 0.24-1 -Date: 2014-12-17 +Date: 2014-12-19 Maintainer: Aaron A. King Authors at R: c(person(given=c("Aaron","A."),family="King",role=c("aut","cre"), email="kingaa at umich.edu"), @@ -16,7 +16,7 @@ person(given=c("Helen"),family="Wearing",role=c("ctb"))) URL: http://pomp.r-forge.r-project.org Description: More 'pomp' examples. -Depends: R(>= 3.0.0), stats, graphics, pomp(>= 0.49-1) +Depends: R(>= 3.0.0), stats, graphics, pomp(>= 0.56-1) License: GPL (>= 2) LazyData: false BuildVignettes: true From noreply at r-forge.r-project.org Mon Dec 22 13:03:38 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 22 Dec 2014 13:03:38 +0100 (CET) Subject: [Pomp-commits] r1034 - pkg/pompExamples Message-ID: <20141222120338.7380618734D@r-forge.r-project.org> Author: kingaa Date: 2014-12-22 13:03:33 +0100 (Mon, 22 Dec 2014) New Revision: 1034 Modified: pkg/pompExamples/DESCRIPTION Log: - bump Modified: pkg/pompExamples/DESCRIPTION =================================================================== --- pkg/pompExamples/DESCRIPTION 2014-12-19 19:36:55 UTC (rev 1033) +++ pkg/pompExamples/DESCRIPTION 2014-12-22 12:03:33 UTC (rev 1034) @@ -2,7 +2,7 @@ Type: Package Title: Additional pomp examples Version: 0.24-1 -Date: 2014-12-19 +Date: 2014-12-22 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 Wed Dec 24 19:26:53 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 24 Dec 2014 19:26:53 +0100 (CET) Subject: [Pomp-commits] r1035 - in pkg/pompExamples: . inst/examples src Message-ID: <20141224182653.34D581873CA@r-forge.r-project.org> Author: kingaa Date: 2014-12-24 19:26:52 +0100 (Wed, 24 Dec 2014) New Revision: 1035 Modified: pkg/pompExamples/DESCRIPTION pkg/pompExamples/inst/examples/bbp.R pkg/pompExamples/src/bbp.c Log: - bombay plague example now uses codes compiled into package Modified: pkg/pompExamples/DESCRIPTION =================================================================== --- pkg/pompExamples/DESCRIPTION 2014-12-22 12:03:33 UTC (rev 1034) +++ pkg/pompExamples/DESCRIPTION 2014-12-24 18:26:52 UTC (rev 1035) @@ -2,7 +2,7 @@ Type: Package Title: Additional pomp examples Version: 0.24-1 -Date: 2014-12-22 +Date: 2014-12-24 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/examples/bbp.R =================================================================== --- pkg/pompExamples/inst/examples/bbp.R 2014-12-22 12:03:33 UTC (rev 1034) +++ pkg/pompExamples/inst/examples/bbp.R 2014-12-24 18:26:52 UTC (rev 1035) @@ -48,37 +48,43 @@ beta=2,delta=1.5,y0=0.0004,theta=54, sigma=0.02, mu=0,gamma=0.2,ratio=10000 - ), + ), rprocess=euler.sim( - step.fun=Csnippet(" - double X = exp(x); - double Y = exp(y); - double dx, dy, dn, dW, ito; - dx = (mu*(1.0/X-1)+(delta-beta)*Y)*dt; - dy = (beta*X+delta*(Y-1)-gamma-mu)*dt; - dn = -delta*Y*dt; - dW = rnorm(0,sigma*sqrt(dt)); - ito = 0.5*sigma*sigma*dt; - x += dx - beta*Y*(dW-beta*Y*ito); - y += dy + beta*X*(dW+beta*X*ito); - n += dn; - " - ), + step.fun="_bbp_stepfn", + PACKAGE="pompExamples", +### step.fun=Csnippet(" +### double X = exp(x); +### double Y = exp(y); +### double dx, dy, dn, dW, ito; +### dx = (mu*(1.0/X-1)+(delta-beta)*Y)*dt; +### dy = (beta*X+delta*(Y-1)-gamma-mu)*dt; +### dn = -delta*Y*dt; +### dW = rnorm(0,sigma*sqrt(dt)); +### ito = 0.5*sigma*sigma*dt; +### x += dx - beta*Y*(dW-beta*Y*ito); +### y += dy + beta*X*(dW+beta*X*ito); +### n += dn; +### " +### ), delta.t=1/24/7 ), - skeleton=Csnippet(" - double X = exp(x); - double Y = exp(y); - Dx = mu*(1.0/X-1)+(delta-beta)*Y; - Dy = beta*X+delta*(Y-1)-gamma-mu; - Dn = -delta*Y; - " - ), + skeleton="_bbp_skelfn", +### skeleton=Csnippet(" +### double X = exp(x); +### double Y = exp(y); +### Dx = mu*(1.0/X-1)+(delta-beta)*Y; +### Dy = beta*X+delta*(Y-1)-gamma-mu; +### Dn = -delta*Y; +### " +### ), skeleton.type="vectorfield", paramnames=c("beta","delta","mu","gamma","sigma","theta","ratio"), statenames=c("x","y","n"), - rmeasure=Csnippet("deaths=rnbinom_mu(theta,ratio*exp(y));"), - dmeasure=Csnippet("lik=dnbinom_mu(deaths,theta,ratio*exp(y),give_log);"), + rmeasure="_bbp_rmeasure", + dmeasure="_bbp_dmeasure", + PACKAGE="pompExamples", +### rmeasure=Csnippet("deaths=rnbinom_mu(theta,ratio*exp(y));"), +### dmeasure=Csnippet("lik=dnbinom_mu(deaths,theta,ratio*exp(y),give_log);"), logvar=c("beta","delta","ratio","sigma","theta","mu"), logitvar=c("y0"), parameter.inv.transform=function (params, logvar, logitvar, ...) { Modified: pkg/pompExamples/src/bbp.c =================================================================== --- pkg/pompExamples/src/bbp.c 2014-12-22 12:03:33 UTC (rev 1034) +++ pkg/pompExamples/src/bbp.c 2014-12-24 18:26:52 UTC (rev 1035) @@ -1,8 +1,7 @@ -/* pomp model file: _bombay_plague */ +/* pomp model file: _bbp */ #include #include - #define Beta (__p[__parindex[0]]) #define delta (__p[__parindex[1]]) @@ -27,57 +26,57 @@ #define Tratio (__pt[__parindex[6]]) #define lik (__lik[0]) -void _bombay_plague_rmeasure (double *__y, double *__x, double *__p, int *__obsindex, int *__stateindex, int *__parindex, int *__covindex, int __ncovars, double *__covars, double t) +void _bbp_rmeasure (double *__y, double *__x, double *__p, int *__obsindex, int *__stateindex, int *__parindex, int *__covindex, int __ncovars, double *__covars, double t) { - deaths=rnbinom_mu(theta,ratio*exp(y)); + deaths=rnbinom_mu(theta,ratio*exp(y)); } -void _bombay_plague_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) +void _bbp_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) { - lik=dnbinom_mu(deaths,theta,ratio*exp(y),give_log); + lik=dnbinom_mu(deaths,theta,ratio*exp(y),give_log); } -void _bombay_plague_stepfn (double *__x, const double *__p, const int *__stateindex, const int *__parindex, const int *__covindex, int __covdim, const double *__covars, double t, double dt) +void _bbp_stepfn (double *__x, const double *__p, const int *__stateindex, const int *__parindex, const int *__covindex, int __covdim, const double *__covars, double t, double dt) { - double X = exp(x); - double Y = exp(y); - double dx, dy, dn, dW, ito; - dx = (mu*(1.0/X-1)+(delta-Beta)*Y)*dt; - dy = (Beta*X+delta*(Y-1)-gamma-mu)*dt; - dn = -delta*Y*dt; - dW = rnorm(0,sigma*sqrt(dt)); - ito = 0.5*sigma*sigma*dt; - x += dx - Beta*Y*(dW-Beta*Y*ito); - y += dy + Beta*X*(dW+Beta*X*ito); - n += dn; + double X = exp(x); + double Y = exp(y); + double dx, dy, dn, dW, ito; + dx = (mu*(1.0/X-1)+(delta-Beta)*Y)*dt; + dy = (Beta*X+delta*(Y-1)-gamma-mu)*dt; + dn = -delta*Y*dt; + dW = rnorm(0,sigma*sqrt(dt)); + ito = 0.5*sigma*sigma*dt; + x += dx - Beta*Y*(dW-Beta*Y*ito); + y += dy + Beta*X*(dW+Beta*X*ito); + n += dn; } -void _bombay_plague_skelfn (double *__f, double *__x, double *__p, int *__stateindex, int *__parindex, int *__covindex, int __ncovars, double *__covars, double t) +void _bbp_skelfn (double *__f, double *__x, double *__p, int *__stateindex, int *__parindex, int *__covindex, int __ncovars, double *__covars, double t) { - double X = exp(x); - double Y = exp(y); - Dx = mu*(1.0/X-1)+(delta-Beta)*Y; - Dy = Beta*X+delta*(Y-1)-gamma-mu; - Dn = -delta*Y; + double X = exp(x); + double Y = exp(y); + Dx = mu*(1.0/X-1)+(delta-Beta)*Y; + Dy = Beta*X+delta*(Y-1)-gamma-mu; + Dn = -delta*Y; } -void _bombay_plague_rprior (double *__p, int *__parindex) +void _bbp_rprior (double *__p, int *__parindex) { - error("'rprior' not defined"); + error("'rprior' not defined"); } -void _bombay_plague_dprior (double *__lik, double *__p, int give_log, int *__parindex) +void _bbp_dprior (double *__lik, double *__p, int give_log, int *__parindex) { - error("'dprior' not defined"); + error("'dprior' not defined"); } #undef Beta From noreply at r-forge.r-project.org Wed Dec 24 21:15:54 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 24 Dec 2014 21:15:54 +0100 (CET) Subject: [Pomp-commits] r1036 - pkg/pompExamples/src Message-ID: <20141224201554.15D0518762D@r-forge.r-project.org> Author: kingaa Date: 2014-12-24 21:15:53 +0100 (Wed, 24 Dec 2014) New Revision: 1036 Modified: pkg/pompExamples/src/budmoth.c pkg/pompExamples/src/parus.c Log: - change included files in these examples Modified: pkg/pompExamples/src/budmoth.c =================================================================== --- pkg/pompExamples/src/budmoth.c 2014-12-24 18:26:52 UTC (rev 1035) +++ pkg/pompExamples/src/budmoth.c 2014-12-24 20:15:53 UTC (rev 1036) @@ -3,15 +3,8 @@ #include #include #include +#include -static inline double expit (double x) { - return 1.0/(1.0 + exp(-x)); -} - -static inline double logit (double x) { - return log(x/(1-x)); -} - #define ALPHA (p[parindex[0]]) #define SIGALPHA (p[parindex[1]]) #define GAM (p[parindex[2]]) Modified: pkg/pompExamples/src/parus.c =================================================================== --- pkg/pompExamples/src/parus.c 2014-12-24 18:26:52 UTC (rev 1035) +++ pkg/pompExamples/src/parus.c 2014-12-24 20:15:53 UTC (rev 1036) @@ -1,9 +1,8 @@ // dear emacs, please treat this as -*- C++ -*- #include +#include -#include "pomp.h" - #define R (p[parindex[0]]) // growth rate #define K (p[parindex[1]]) // carrying capacity #define SIGMA (p[parindex[2]]) // process noise level From noreply at r-forge.r-project.org Wed Dec 31 13:36:42 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 31 Dec 2014 13:36:42 +0100 (CET) Subject: [Pomp-commits] r1037 - pkg/pompExamples Message-ID: <20141231123642.6B68918779E@r-forge.r-project.org> Author: kingaa Date: 2014-12-31 13:36:42 +0100 (Wed, 31 Dec 2014) New Revision: 1037 Modified: pkg/pompExamples/DESCRIPTION Log: - bump Modified: pkg/pompExamples/DESCRIPTION =================================================================== --- pkg/pompExamples/DESCRIPTION 2014-12-24 20:15:53 UTC (rev 1036) +++ pkg/pompExamples/DESCRIPTION 2014-12-31 12:36:42 UTC (rev 1037) @@ -2,7 +2,7 @@ Type: Package Title: Additional pomp examples Version: 0.24-1 -Date: 2014-12-24 +Date: 2014-12-31 Maintainer: Aaron A. King Authors at R: c(person(given=c("Aaron","A."),family="King",role=c("aut","cre"), email="kingaa at umich.edu"),