[Pomp-commits] r945 - in pkg/pompExamples: . R inst vignettes
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu May 1 15:46:28 CEST 2014
Author: kingaa
Date: 2014-05-01 15:46:27 +0200 (Thu, 01 May 2014)
New Revision: 945
Added:
pkg/pompExamples/inst/NEWS.Rd
Removed:
pkg/pompExamples/data/
pkg/pompExamples/inst/ChangeLog
pkg/pompExamples/inst/NEWS
Modified:
pkg/pompExamples/DESCRIPTION
pkg/pompExamples/R/pertussis.R
pkg/pompExamples/vignettes/budmoth-model.Rnw
pkg/pompExamples/vignettes/pertussis-model.Rnw
Log:
- fix vignettes to work with new structure
- fix pertussis models to work with pomp v. 0.50
- remove 'data' directory (finally)
Modified: pkg/pompExamples/DESCRIPTION
===================================================================
--- pkg/pompExamples/DESCRIPTION 2014-05-01 13:44:49 UTC (rev 944)
+++ pkg/pompExamples/DESCRIPTION 2014-05-01 13:46:27 UTC (rev 945)
@@ -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.45-4)
+Depends: R(>= 3.0.0), stats, graphics, pomp(>= 0.49-1)
Suggests: Rmpi,mpifarm,plyr,reshape2,ggplot2,xtable
License: GPL (>= 2)
LazyData: false
Modified: pkg/pompExamples/R/pertussis.R
===================================================================
--- pkg/pompExamples/R/pertussis.R 2014-05-01 13:44:49 UTC (rev 944)
+++ pkg/pompExamples/R/pertussis.R 2014-05-01 13:46:27 UTC (rev 945)
@@ -103,9 +103,10 @@
dmeasure = "negbin_dmeasure",
parameter.inv.transform="pertussis_par_untrans",
parameter.transform="pertussis_par_trans",
- initializer = function (params, t0, statenames, comp.names, ivps, ...) {
- states <- numeric(length(statenames))
- names(states) <- statenames
+ varnames=c("S","E","I","R1","R2","cases","W","err","simpop"),
+ initializer = function (params, t0, varnames, comp.names, ivps, ...) {
+ states <- numeric(length(varnames))
+ names(states) <- varnames
## translate fractions into initial conditions
frac <- params[ivps]
states[comp.names] <- round(params['popsize']*frac/sum(frac))
Deleted: pkg/pompExamples/inst/ChangeLog
===================================================================
--- pkg/pompExamples/inst/ChangeLog 2014-05-01 13:44:49 UTC (rev 944)
+++ pkg/pompExamples/inst/ChangeLog 2014-05-01 13:46:27 UTC (rev 945)
@@ -1,102 +0,0 @@
-2012-05-14 kingaa
-
- * [r723] DESCRIPTION, R, R/version.R: - add 'version'
- * [r720] DESCRIPTION, inst/doc/budmoth-model-slices.rda,
- inst/doc/budmoth-model-true-loglik.rda,
- inst/doc/budmoth-model.pdf,
- inst/doc/pertussis-model-true-loglik.rda,
- inst/doc/pertussis-model.Rnw, inst/doc/pertussis-model.pdf: -
- update vignettes
- * [r719] DESCRIPTION, data/pertussis.sim.rda, tests/pertussis.R,
- tests/pertussis.Rout.save: - update 'pertussis.sim'
-
-2012-05-12 kingaa
-
- * [r718] DESCRIPTION:
- * [r717] inst/ChangeLog, inst/data-R/pertussis.sim.R,
- src/pertussis.c: - move parameter transformations into C for the
- pertussis example
-
-2012-05-08 kingaa
-
- * [r712] DESCRIPTION, tests/pertussis.Rout.save: - bring unit tests
- up to date
- * [r710] DESCRIPTION: - update version number
- * [r709] inst/doc/budmoth-model.pdf, inst/doc/pertussis-model.pdf:
- - update vignettes
- * [r708] data/budmoth.sim.rda, data/pertussis.sim.rda: - update for
- compatibility with pomp version 0.42-2
-
-2012-04-21 kingaa
-
- * [r672] inst/ChangeLog: - add ChangeLog
- * [r671] DESCRIPTION, data/budmoth.sim.rda, data/pertussis.sim.rda,
- inst/NEWS, inst/data-R/budmoth.sim.R,
- inst/doc/budmoth-model-slices.rda,
- inst/doc/budmoth-model-true-loglik.rda,
- inst/doc/pertussis-model-true-loglik.rda, src/budmoth.c,
- tests/budmoth.Rout.save: - changed the budmoth model t0 to -1.
- The data are changed as well.
-
-2012-04-18 kingaa
-
- * [r669] inst/doc/budmoth-model-slices.rda,
- inst/doc/budmoth-model-true-loglik.rda,
- inst/doc/pertussis-model-true-loglik.rda, src/budmoth.c: - remove
- finiteness checks from budmoth model
- * [r668] .Rbuildignore, .Rinstignore, data/pertussis.sim.rda,
- inst/data-R/budmoth-params.rda, inst/data-R/budmoth.sim.R,
- inst/data-R/pertussis-params.rda, inst/data-R/pertussis.sim.R,
- inst/doc/budmoth-model-slices.rda,
- inst/doc/budmoth-model-true-loglik.rda,
- inst/doc/budmoth-model.pdf,
- inst/doc/pertussis-model-true-loglik.rda,
- inst/doc/pertussis-model.Rnw, inst/doc/pertussis-model.pdf,
- src/pertussis.c, tests/pertussis.R, tests/pertussis.Rout.save: -
- drop V from pertussis model
- - drop finiteness checks in pertussis model
- * [r667] .Rinstignore, DESCRIPTION, data/budmoth.sim.rda,
- data/pertussis.sim.rda, inst/data-R/budmoth-params.rda,
- inst/data-R/budmoth-simdata.rda, inst/data-R/budmoth.sim.R,
- inst/data-R/pertussis-params.rda,
- inst/data-R/pertussis-simdata.rda, inst/data-R/pertussis.sim.R,
- inst/doc/budmoth-model-slices.rda,
- inst/doc/budmoth-model-true-loglik.rda,
- inst/doc/budmoth-model.Rnw, inst/doc/budmoth-model.pdf,
- inst/doc/pertussis-model-true-loglik.rda,
- inst/doc/pertussis-model.Rnw, inst/doc/pertussis-model.pdf,
- tests/budmoth.Rout.save, tests/pertussis.R,
- tests/pertussis.Rout.save: - new datasets
- - revert dependence to R>2.14.2
- - add log likelihood calculation to pertussis vignette
- - true parameters are included with pomps
-
-2012-04-17 kingaa
-
- * [r666] .Rinstignore, DESCRIPTION, NAMESPACE,
- data/budmoth.sim.rda, data/pertussis.sim.rda,
- inst/data-R/budmoth-params.csv, inst/data-R/budmoth-simdata.rda,
- inst/data-R/budmoth.sim.R, inst/data-R/pertussis-params.csv,
- inst/data-R/pertussis-simdata.rda, inst/data-R/pertussis.sim.R,
- inst/doc/budmoth-model-slices.rda,
- inst/doc/budmoth-model-true-loglik.rda,
- inst/doc/budmoth-model.Rnw, inst/doc/budmoth-model.pdf,
- inst/doc/pertussis-model.Rnw, inst/doc/pertussis-model.pdf,
- man/budmoth.Rd, tests/budmoth.R, tests/pertussis.R: - fix loads
- of bugs
- * [r665] ., .Rbuildignore, .Rinstignore, DESCRIPTION, NAMESPACE,
- data, data/budmoth.sim.rda, data/pertussis.sim.rda, inst,
- inst/GPL, inst/LICENSE, inst/data-R, inst/data-R/Makefile,
- inst/data-R/budmoth-params.csv, inst/data-R/budmoth-simdata.rda,
- inst/data-R/budmoth.sim.R, inst/data-R/pertussis-params.csv,
- inst/data-R/pertussis-simdata.rda, inst/data-R/pertussis.sim.R,
- inst/doc, inst/doc/Makefile, inst/doc/budmoth-model-slices.rda,
- inst/doc/budmoth-model-true-loglik.rda,
- inst/doc/budmoth-model.Rnw, inst/doc/budmoth-model.pdf,
- inst/doc/fullnat.bst, inst/doc/pertussis-model.Rnw,
- inst/doc/pertussis-model.pdf, inst/doc/pomp.bib, man,
- man/budmoth.Rd, man/pertussis.Rd, src, src/budmoth.c,
- src/pertussis.c, tests, tests/budmoth.R, tests/budmoth.Rout.save,
- tests/pertussis.R, tests/pertussis.Rout.save: - add pompExamples
- package
-
Deleted: pkg/pompExamples/inst/NEWS
===================================================================
--- pkg/pompExamples/inst/NEWS 2014-05-01 13:44:49 UTC (rev 944)
+++ pkg/pompExamples/inst/NEWS 2014-05-01 13:46:27 UTC (rev 945)
@@ -1,12 +0,0 @@
-NEWS
-0.22-1
- o The pomp objects are no longer accessed using 'data'.
- Instead, 'pertussis.sim' and 'budmoth.sim' are functions that return the pomp objects.
-
-0.21-1
- o Changed t0 for the budmoth model from 0 to -1.
- The data are different as well.
-
-0.20-1
- o Ported these examples from 'pomp.devel'.
- The data are not identical to those in 'pomp.devel', however.
Copied: pkg/pompExamples/inst/NEWS.Rd (from rev 892, pkg/pompExamples/inst/NEWS)
===================================================================
--- pkg/pompExamples/inst/NEWS.Rd (rev 0)
+++ pkg/pompExamples/inst/NEWS.Rd 2014-05-01 13:46:27 UTC (rev 945)
@@ -0,0 +1,25 @@
+\name{NEWS}
+\title{News for Package 'pompExamples'}
+\section{Changes in \pkg{pompExamples} version 0.23-2}{
+ \itemize{
+ \item Update for use with \pkg{pomp} version 0.50.
+ }
+}
+\section{Changes in \pkg{pompExamples} version 0.22-1}{
+ \itemize{
+ \item The pomp objects are no longer accessed using \code{data}.
+ Instead, \code{pertussis.sim} and \code{budmoth.sim} are functions that return the pomp objects.
+ }
+}
+\section{Changes in \pkg{pompExamples} version 0.21-1}{
+ \itemize{
+ \item Changed \code{t0} for the budmoth model from 0 to -1.
+ The data are different as well.
+ }
+}
+\section{Changes in \pkg{pompExamples} version 0.20-1}{
+ \itemize{
+ \item Ported these examples from \pkg{pomp.devel}.
+ The data are not identical to those in \pkg{pomp.devel}, however.
+ }
+}
Modified: pkg/pompExamples/vignettes/budmoth-model.Rnw
===================================================================
--- pkg/pompExamples/vignettes/budmoth-model.Rnw 2014-05-01 13:44:49 UTC (rev 944)
+++ pkg/pompExamples/vignettes/budmoth-model.Rnw 2014-05-01 13:46:27 UTC (rev 945)
@@ -97,17 +97,27 @@
This model is implemented in the package and can be loaded with the command
<<>>=
-data(budmoth.sim)
+
+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(budmoth.sim)
+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(budmoth.sim)} imulated data sets of length \Sexpr{diff(range(time(budmoth.sim[[1]])))+1} years.
+In total, there are \Sexpr{length(bmPomps)} imulated data sets of length \Sexpr{diff(range(time(bmPomps[[1]])))+1} years.
<<echo=F>>=
-for (q in names(budmoth.sim)) {
- time(budmoth.sim[[q]]) <- 1:60
+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.
@@ -116,11 +126,11 @@
and the likelihood is computed via \verb+budmoth_dmeasure+.
Finally, the state process is initialized by
<<echo=F>>=
-budmoth.sim[[1]]@initializer
+bmPomps[[1]]@initializer
@
The parameters at which the simulated data are generated can be extracted via
<<true-params>>=
-true.pars <- sapply(budmoth.sim[c("food","para1","para2","tri")],coef)
+true.pars <- sapply(bmPomps[c("food","para1","para2","tri")],coef)
@
and are displayed in Table~\ref{tab:sim-params}.
@@ -161,8 +171,13 @@
require(plyr)
require(reshape2)
require(ggplot2)
-data(budmoth.sim)
-x <- ldply(budmoth.sim,as.data.frame)
+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"))
@@ -180,9 +195,14 @@
require(mpifarm)
require(pompExamples)
-data(budmoth.sim)
+bmPomps <- list(
+ tri=budmoth.sim(tri),
+ food=budmoth.sim(food),
+ para1=budmoth.sim(para1),
+ para2=budmoth.sim(para2)
+ )
-ncpus <- length(budmoth.sim)
+ncpus <- length(bmPomps)
nrep <- 10 ### number of particle filters to run
Np <- 10000 ### number of particles
@@ -199,13 +219,13 @@
dlply(
expand.grid(
seed=seeds,
- dataset=names(budmoth.sim)
+ dataset=names(bmPomps)
),
~dataset+seed
)
},
common=list(
- pomps=budmoth.sim,
+ pomps=bmPomps,
Np=Np
),
main={
@@ -303,16 +323,21 @@
Np <- 1000 ### number of particles per filter
slice.length <- 100 ### number of points per slice
-data(budmoth.sim)
+bmPomps <- list(
+ tri=budmoth.sim(tri),
+ food=budmoth.sim(food),
+ para1=budmoth.sim(para1),
+ para2=budmoth.sim(para2)
+ )
-true.pars <- sapply(budmoth.sim,coef)
+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(
- budmoth.sim,
+ bmPomps,
function (po) {
center <- coef(po)
ranges <- lapply(
@@ -347,7 +372,7 @@
for (j in seq_len(nrow(slices))) {
ds <- slices$dataset[j]
sl <- slices$slice[j]
- paramnames <- names(coef(budmoth.sim[[ds]]))
+ paramnames <- names(coef(bmPomps[[ds]]))
for (k in seq_len(nrep)) {
s <- s+1
joblist[[s]] <- list(
@@ -361,7 +386,7 @@
joblist
},
common=list(
- pomps=budmoth.sim,
+ pomps=bmPomps,
Np=Np,
estnames=estnames
),
Modified: pkg/pompExamples/vignettes/pertussis-model.Rnw
===================================================================
--- pkg/pompExamples/vignettes/pertussis-model.Rnw 2014-05-01 13:44:49 UTC (rev 944)
+++ pkg/pompExamples/vignettes/pertussis-model.Rnw 2014-05-01 13:46:27 UTC (rev 945)
@@ -280,11 +280,21 @@
The model above is implemented in the package and can be loaded with the command
<<>>=
-data(pertussis.sim)
+pertussis.sim()
+pertPomps <- list(
+ SEIR.small=pertussis.sim(SEIR.small),
+ SEIR.big=pertussis.sim(SEIR.big),
+ SEIRS.small=pertussis.sim(SEIRS.small),
+ SEIRS.big=pertussis.sim(SEIRS.big),
+ SEIRR.small=pertussis.sim(SEIRR.small),
+ SEIRR.big=pertussis.sim(SEIRR.big),
+ full.small=pertussis.sim(full.small),
+ full.big=pertussis.sim(full.big)
+ )
@
-The object thereby loaded contains a named length-\Sexpr{length(pertussis.sim)} list of pomp objects:
+The object thereby loaded contains a named length-\Sexpr{length(pertPomps)} list of pomp objects:
<<>>=
-names(pertussis.sim)
+names(pertPomps)
@
There are three submodels (SEIR, SEIRS, SEIRR), representing a model with permanent immunity (SEIR), temporary immunity (SEIRS), and temporary immunity with boosting (SEIRR).
The model labeled \code{full} is SEIRR but with polarizing immunity ($\phi>0$) and environmental stochasticity $\sigma_{\zeta}>0$.
@@ -296,8 +306,17 @@
<<format-params,echo=F,eval=F>>=
require(pompExamples)
require(plyr)
-data(pertussis.sim)
-true.pars <- sapply(pertussis.sim,coef)
+pertPomps <- list(
+ SEIR.small=pertussis.sim(SEIR.small),
+ SEIR.big=pertussis.sim(SEIR.big),
+ SEIRS.small=pertussis.sim(SEIRS.small),
+ SEIRS.big=pertussis.sim(SEIRS.big),
+ SEIRR.small=pertussis.sim(SEIRR.small),
+ SEIRR.big=pertussis.sim(SEIRR.big),
+ full.small=pertussis.sim(full.small),
+ full.big=pertussis.sim(full.big)
+ )
+true.pars <- sapply(pertPomps,coef)
params <- as.data.frame(true.pars)
params$name <- rownames(params)
params$math <- ""
@@ -372,8 +391,17 @@
require(plyr)
require(reshape2)
require(pompExamples)
-data(pertussis.sim)
-x <- ldply(pertussis.sim,as.data.frame)
+pertPomps <- list(
+ SEIR.small=pertussis.sim(SEIR.small),
+ SEIR.big=pertussis.sim(SEIR.big),
+ SEIRS.small=pertussis.sim(SEIRS.small),
+ SEIRS.big=pertussis.sim(SEIRS.big),
+ SEIRR.small=pertussis.sim(SEIRR.small),
+ SEIRR.big=pertussis.sim(SEIRR.big),
+ full.small=pertussis.sim(full.small),
+ full.big=pertussis.sim(full.big)
+ )
+x <- ldply(pertPomps,as.data.frame)
x <- rename(x,c(.id="dataset"))
x <- melt(x,id.var=c("dataset","time"))
x <- subset(x,variable=="reports")
@@ -405,7 +433,16 @@
require(mpifarm)
require(pompExamples)
-data(pertussis.sim)
+pertPomps <- list(
+ SEIR.small=pertussis.sim(SEIR.small),
+ SEIR.big=pertussis.sim(SEIR.big),
+ SEIRS.small=pertussis.sim(SEIRS.small),
+ SEIRS.big=pertussis.sim(SEIRS.big),
+ SEIRR.small=pertussis.sim(SEIRR.small),
+ SEIRR.big=pertussis.sim(SEIRR.big),
+ full.small=pertussis.sim(full.small),
+ full.big=pertussis.sim(full.big)
+ )
ncpus <- as.integer(Sys.getenv("PBS_NP"))
@@ -424,13 +461,13 @@
dlply(
expand.grid(
seed=seeds,
- dataset=names(pertussis.sim)
+ dataset=names(pertPomps)
),
~dataset+seed
)
},
common=list(
- pomps=pertussis.sim,
+ pomps=pertPomps,
Np=Np
),
main={
@@ -590,8 +627,17 @@
<<wavelets,eval=F,echo=F,fig=T,clean=T>>=
require(pompExamples)
require(Rwave)
-data(pertussis.sim)
-x <- lapply(pertussis.sim,as,"data.frame")
+pertPomps <- list(
+ SEIR.small=pertussis.sim(SEIR.small),
+ SEIR.big=pertussis.sim(SEIR.big),
+ SEIRS.small=pertussis.sim(SEIRS.small),
+ SEIRS.big=pertussis.sim(SEIRS.big),
+ SEIRR.small=pertussis.sim(SEIRR.small),
+ SEIRR.big=pertussis.sim(SEIRR.big),
+ full.small=pertussis.sim(full.small),
+ full.big=pertussis.sim(full.big)
+ )
+x <- lapply(pertPomps,as,"data.frame")
x <- lapply(x,function(x)x[c("time","reports")])
for (n in names(x))
names(x[[n]])[2] <- n
More information about the pomp-commits
mailing list