[Pomp-commits] r666 - in pkg/pompExamples: . data inst/data-R inst/doc man tests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Apr 17 23:37:51 CEST 2012


Author: kingaa
Date: 2012-04-17 23:37:50 +0200 (Tue, 17 Apr 2012)
New Revision: 666

Removed:
   pkg/pompExamples/inst/data-R/budmoth-params.csv
   pkg/pompExamples/inst/data-R/pertussis-params.csv
Modified:
   pkg/pompExamples/.Rinstignore
   pkg/pompExamples/DESCRIPTION
   pkg/pompExamples/NAMESPACE
   pkg/pompExamples/data/budmoth.sim.rda
   pkg/pompExamples/data/pertussis.sim.rda
   pkg/pompExamples/inst/data-R/budmoth-simdata.rda
   pkg/pompExamples/inst/data-R/budmoth.sim.R
   pkg/pompExamples/inst/data-R/pertussis-simdata.rda
   pkg/pompExamples/inst/data-R/pertussis.sim.R
   pkg/pompExamples/inst/doc/budmoth-model-slices.rda
   pkg/pompExamples/inst/doc/budmoth-model-true-loglik.rda
   pkg/pompExamples/inst/doc/budmoth-model.Rnw
   pkg/pompExamples/inst/doc/budmoth-model.pdf
   pkg/pompExamples/inst/doc/pertussis-model.Rnw
   pkg/pompExamples/inst/doc/pertussis-model.pdf
   pkg/pompExamples/man/budmoth.Rd
   pkg/pompExamples/tests/budmoth.R
   pkg/pompExamples/tests/pertussis.R
Log:
- fix loads of bugs


Modified: pkg/pompExamples/.Rinstignore
===================================================================
--- pkg/pompExamples/.Rinstignore	2012-04-17 20:53:41 UTC (rev 665)
+++ pkg/pompExamples/.Rinstignore	2012-04-17 21:37:50 UTC (rev 666)
@@ -1,2 +1,3 @@
 inst/doc/Makefile
-inst/doc/fullnat.bst
+inst/data-R/Makefile
+inst/doc/(.+?)\.bst$

Modified: pkg/pompExamples/DESCRIPTION
===================================================================
--- pkg/pompExamples/DESCRIPTION	2012-04-17 20:53:41 UTC (rev 665)
+++ pkg/pompExamples/DESCRIPTION	2012-04-17 21:37:50 UTC (rev 666)
@@ -10,3 +10,4 @@
 License: GPL (>= 2)
 LazyLoad: true
 LazyData: false
+BuildVignettes: no

Modified: pkg/pompExamples/NAMESPACE
===================================================================
--- pkg/pompExamples/NAMESPACE	2012-04-17 20:53:41 UTC (rev 665)
+++ pkg/pompExamples/NAMESPACE	2012-04-17 21:37:50 UTC (rev 666)
@@ -1,11 +1,2 @@
-useDynLib(pomp.devel)
+useDynLib(pompExamples)
 importFrom(pomp)
-export(
-       logit,
-       expit,
-       rlogitnorm,
-       dlogitnorm,
-       mult.norm.ts,
-       spsainb,
-       sainb
-       )

Modified: pkg/pompExamples/data/budmoth.sim.rda
===================================================================
(Binary files differ)

Modified: pkg/pompExamples/data/pertussis.sim.rda
===================================================================
(Binary files differ)

Deleted: pkg/pompExamples/inst/data-R/budmoth-params.csv
===================================================================
--- pkg/pompExamples/inst/data-R/budmoth-params.csv	2012-04-17 20:53:41 UTC (rev 665)
+++ pkg/pompExamples/inst/data-R/budmoth-params.csv	2012-04-17 21:37:50 UTC (rev 666)
@@ -1,5 +0,0 @@
-"seed";"alpha";"sig.alpha";"gam";"lambda";"sig.lambda";"g";"delta";"a";"sig.a";"w";"beta0";"beta1";"u";"sigQobs";"sigNobs";"sigSobs";"Q.0";"N.0";"S.0"
-"tri.1";1691699385.71224;0.5;0.1;50;22;0.25;0.08;10;1.7;0.1;0.15;0;35;0.9;0.03;0.5;0.1;0.96;0.02;0.22
-"para.1";1116757478.97997;0.5;0.1;50;22;0.25;0.08;0.5;1.7;0.1;0.15;0;35;0.9;0.03;0.5;0.1;0.96;0.02;0.22
-"food.1";1054866677.50879;0.5;0.1;20;5;0.25;0.02;10;1;0.1;0;0;35;0.9;0.03;0.5;0.1;0.96;0.02;0.22
-"para.2";1361101458.86619;0.5;0.1;50;10;5;0.08;0.5;1.7;1;0.15;0;35;0.9;0.03;0.5;0.1;0.96;0.02;0.22

Modified: pkg/pompExamples/inst/data-R/budmoth-simdata.rda
===================================================================
(Binary files differ)

Modified: pkg/pompExamples/inst/data-R/budmoth.sim.R
===================================================================
--- pkg/pompExamples/inst/data-R/budmoth.sim.R	2012-04-17 20:53:41 UTC (rev 665)
+++ pkg/pompExamples/inst/data-R/budmoth.sim.R	2012-04-17 21:37:50 UTC (rev 666)
@@ -1,31 +1,30 @@
-require(pomp.devel)
+require(pompExamples)
 
-params <- read.csv("budmoth-params.csv",sep=";")
-datasets <- rownames(params)
-params <- params[!(names(params)%in%c("seed"))]
-
 load("budmoth-simdata.rda")
 
+datasets <- rownames(params)
+params <- subset(params,select=-seed)
+
 budmoth.sim <- list()
 for (d in datasets) {
   po <- pomp(
-             data=subset(budmoth.sim.data,dataset==d,select=c(time,Qobs,Nobs,Sobs)),
+             data=subset(simdata,dataset==d,select=c(time,Qobs,Nobs,Sobs)),
              time="time",
              t0=0,
              rprocess=euler.sim(
                step.fun="budmoth_map",
                delta.t=1,
-               PACKAGE="pomp.devel"
+               PACKAGE="pompExamples"
                ),
              dprocess=onestep.dens(
                dens.fun="budmoth_density",
-               PACKAGE="pomp.devel"
+               PACKAGE="pompExamples"
                ),
              rmeasure="budmoth_rmeasure",
              dmeasure="budmoth_dmeasure",
              skeleton.type="map",
              skeleton="budmoth_skeleton",
-             PACKAGE="pomp.devel",
+             PACKAGE="pompExamples",
              paramnames=c(
                "alpha","sig.alpha","gam","lambda","sig.lambda",
                "g","delta","a","sig.a",

Deleted: pkg/pompExamples/inst/data-R/pertussis-params.csv
===================================================================
--- pkg/pompExamples/inst/data-R/pertussis-params.csv	2012-04-17 20:53:41 UTC (rev 665)
+++ pkg/pompExamples/inst/data-R/pertussis-params.csv	2012-04-17 21:37:50 UTC (rev 666)
@@ -1,9 +0,0 @@
-model;pop;seed;birthrate;deathrate;mean.beta;ampl.beta;imports;sigma;gamma;alpha.1;alpha.2;alpha.ratio;report.prob;boost.prob;polar.prob;vacc.prob;foi.mod;popsize;noise.sigma;tau;S.0;E.0;I.0;R1.0;R2.0;V.0
-SEIR;small;1489450081;0.02;0.02;450;0.15;10;46;26;0;0.1;1;0.3;0;0;0;0;500000;0;0.01;0.1;0.01;0.01;0.88;0;0
-SEIR;big;1385639311;0.02;0.02;450;0.15;10;46;26;0;0.1;1;0.3;0;0;0;0;5000000;0;0.01;0.1;0.01;0.01;0.88;0;0
-SEIRS;small;181048726;0.02;0.02;150;0.15;10;46;26;0.1;0.1;1;0.1;0;0;0;0;500000;0;0.01;0.1;0.01;0.01;0.88;0;0
-SEIRS;big;497318207;0.02;0.02;150;0.15;10;46;26;0.1;0.1;1;0.1;0;0;0;0;5000000;0;0.01;0.1;0.01;0.01;0.88;0;0
-SEIRR;small;1952854080;0.02;0.02;150;0.15;10;46;26;0.1;0.1;1;0.11;0.75;0;0;0.5;500000;0;0.01;0.1;0.01;0.01;0.88;0;0
-SEIRR;big;949351093;0.02;0.02;150;0.15;10;46;26;0.1;0.1;1;0.11;0.75;0;0;0.5;5000000;0;0.01;0.1;0.01;0.01;0.88;0;0
-full;small;744725040.5;0.02;0.02;150;0.15;10;46;26;0.1;0.1;1;0.1;0.75;0.1;0;0.5;500000;0.01;0.01;0.1;0.01;0.01;0.88;0;0
-full;big;1532950814;0.02;0.02;150;0.15;10;46;26;0.1;0.1;1;0.1;0.75;0.1;0;0.5;5000000;0.01;0.01;0.1;0.01;0.01;0.88;0;0

Modified: pkg/pompExamples/inst/data-R/pertussis-simdata.rda
===================================================================
(Binary files differ)

Modified: pkg/pompExamples/inst/data-R/pertussis.sim.R
===================================================================
--- pkg/pompExamples/inst/data-R/pertussis.sim.R	2012-04-17 20:53:41 UTC (rev 665)
+++ pkg/pompExamples/inst/data-R/pertussis.sim.R	2012-04-17 21:37:50 UTC (rev 666)
@@ -3,29 +3,27 @@
 ## and states.  Simulations from the process model are approximated using
 ## an Euler approximation.
 
-require(pomp.devel)
+require(pompExamples)
 
-params <- read.csv("pertussis-params.csv",sep=";")
-datasets <- with(params,paste(model,pop,sep="."))
-params <- params[!(names(params)%in%c("model","pop","seed"))]
-rownames(params) <- datasets
-
 load("pertussis-simdata.rda")
 
+datasets <- rownames(params)
+params <- subset(params,select=-c(model,pop,seed))
+
 pertussis.sim <- list()
 for (d in datasets) {
   po <- pomp(
-             data=subset(pertussis.sim.data,dataset==d,select=c(time,reports)),
+             data=subset(simdata,dataset==d,select=c(time,reports)),
              times="time",
              t0=-1/52,
              rprocess = euler.sim(
                step.fun="pertussis_sveirr_EM",
-               delta.t=1/52/7,      # Euler stepsize
-               PACKAGE="pomp.devel"
+               delta.t=1/52/7,          # Euler stepsize
+               PACKAGE="pompExamples"
                ),
              skeleton.type="vectorfield",
              skeleton="pertussis_sveirr_skel",
-             PACKAGE="pomp.devel", # name of the dynamically loadable library where the C functions are
+             PACKAGE="pompExamples",
              paramnames=c(
                "birthrate","deathrate","mean.beta","ampl.beta",
                "imports","sigma","gamma","alpha.1","alpha.2","alpha.ratio",

Modified: pkg/pompExamples/inst/doc/budmoth-model-slices.rda
===================================================================
(Binary files differ)

Modified: pkg/pompExamples/inst/doc/budmoth-model-true-loglik.rda
===================================================================
(Binary files differ)

Modified: pkg/pompExamples/inst/doc/budmoth-model.Rnw
===================================================================
--- pkg/pompExamples/inst/doc/budmoth-model.Rnw	2012-04-17 20:53:41 UTC (rev 665)
+++ pkg/pompExamples/inst/doc/budmoth-model.Rnw	2012-04-17 21:37:50 UTC (rev 666)
@@ -35,7 +35,7 @@
 \maketitle
 
 <<options,echo=F,results=hide>>=
-require(pomp.devel)
+require(pompExamples)
 require(xtable)
 glop <- options(keep.source=TRUE,width=60,continue=" ",prompt=" ")
 options(
@@ -68,7 +68,7 @@
 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{pomp.devel}.
+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}
@@ -120,7 +120,7 @@
 @ 
 The parameters at which the simulated data are generated can be extracted via
 <<true-params>>=
-true.pars <- sapply(budmoth.sim[c("food.1","para.1","para.2","tri.1")],coef)
+true.pars <- sapply(budmoth.sim[c("food","para1","para2","tri")],coef)
 @ 
 and are displayed in Table~\ref{tab:sim-params}.
 
@@ -136,8 +136,8 @@
                                                                        "$\\beta_{0}$","$\\beta_{1}$",
                                                                        "$u$","$\\sigma_{Q}$","$\\sigma_{N}$","$\\sigma_{S}$",
                                                                        "$Q_{0}$","$N_{0}$","$S_{0}$")
-params <- params[c("math","name","food.1","para.1","para.2","tri.1")]
-names(params) <- c("parameter","R name","food.1","para.1","para.2","tri.1")
+params <- params[c("math","name","food","para1","para2","tri")]
+names(params) <- c("parameter","R name","food","para1","para2","tri")
 print(
       xtable(
              params,
@@ -157,7 +157,7 @@
 
 \begin{figure}
 <<data-plot,fig=T,height=6,width=8,pdf=T,png=F,echo=F>>=
-require(pomp.devel)
+require(pompExamples)
 require(plyr)
 require(reshape)
 require(ggplot2)
@@ -177,7 +177,7 @@
 <<true-loglik-calc,echo=F,eval=F>>=
 require(Rmpi)
 require(mpifarm)
-require(pomp.devel)
+require(pompExamples)
 
 data(budmoth.sim)
 
@@ -192,27 +192,23 @@
 
 mpi.farmer(
            chunk=5,
-           seeds=as.integer(floor(runif(n=10000,1,2^31))),
+           seeds=as.integer(floor(runif(n=nrep,1,2^31))),
            jobs={
-             joblist <- vector(mode='list',length=nrep*length(budmoth.sim))
-             k <- 0
-             for (q in names(budmoth.sim)) {
-               for (r in seq_len(nrep)) {
-                 k <- k+1
-                 joblist[[k]] <- list(
-                                      seed=seeds[k],
-                                      dataset=q
-                                      )
-               }
-             }
-             joblist
+             require(plyr)
+             dlply(
+                   expand.grid(
+                               seed=seeds,
+                               dataset=names(budmoth.sim)
+                               ),
+                   ~dataset+seed
+                   )
            },
            common=list(
              pomps=budmoth.sim,
              Np=Np
              ),
            main={
-             require(pomp.devel)
+             require(pompExamples)
              save.seed <- .Random.seed
              set.seed(seed)
              tic <- Sys.time()
@@ -298,7 +294,7 @@
 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}.
 <<slices-calc,eval=F,echo=F>>=
-require(pomp.devel)
+require(pompExamples)
 require(Rmpi)
 require(mpifarm)
 
@@ -312,7 +308,8 @@
 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"))
+##ncpus <- as.integer(Sys.getenv("PBS_NP"))
+ncpus <- 6
 
 slices <- lapply(
                  budmoth.sim,
@@ -369,7 +366,7 @@
              estnames=estnames
              ),
            main={
-             require(pomp.devel)
+             require(pompExamples)
              po <- pomps[[dataset]]
              save.seed <- .Random.seed
              set.seed(seed)

Modified: pkg/pompExamples/inst/doc/budmoth-model.pdf
===================================================================
(Binary files differ)

Modified: pkg/pompExamples/inst/doc/pertussis-model.Rnw
===================================================================
--- pkg/pompExamples/inst/doc/pertussis-model.Rnw	2012-04-17 20:53:41 UTC (rev 665)
+++ pkg/pompExamples/inst/doc/pertussis-model.Rnw	2012-04-17 21:37:50 UTC (rev 666)
@@ -59,7 +59,7 @@
 \begin{document}
 
 <<options,echo=F,results=hide>>=
-require(pomp.devel)
+require(pompExamples)
 require(xtable)
 .glop <- options(keep.source=TRUE,width=60,continue=" ",prompt=" ")
 on.exit(options(.glop))
@@ -305,7 +305,7 @@
 Details on the implementation of this algorithm are given in \citet[][Box~1]{He2010}.
 
 <<format-params,echo=F,eval=F>>=
-require(pomp.devel)
+require(pompExamples)
 require(plyr)
 data(pertussis.sim)
 true.pars <- sapply(pertussis.sim,coef)
@@ -528,7 +528,7 @@
 \end{document}
 
 <<wavelets,eval=F,echo=F,fig=T,clean=T>>=
-require(pomp.devel)
+require(pompExamples)
 require(Rwave)
 data(pertussis.sim)
 x <- lapply(pertussis.sim,as,"data.frame")

Modified: pkg/pompExamples/inst/doc/pertussis-model.pdf
===================================================================
(Binary files differ)

Modified: pkg/pompExamples/man/budmoth.Rd
===================================================================
--- pkg/pompExamples/man/budmoth.Rd	2012-04-17 20:53:41 UTC (rev 665)
+++ pkg/pompExamples/man/budmoth.Rd	2012-04-17 21:37:50 UTC (rev 666)
@@ -1,29 +1,22 @@
 \name{budmoth}
-\alias{budmoth.eng}
 \alias{budmoth.sim}
 \docType{data}
 \title{Larch budmoth model POMPs with real and simulated data.}
 \description{
-  \code{budmoth.eng} is a \code{pomp} object containing the larch budmoth model, budmoth density, parasitism rate, and food quality (needle-length) data from the Engadine valley of Switzerland.
-  \code{budmoth.sim} is a list of \code{pomp} objects:
-  each encodes the larch budmoth model and contains simulated data.
-  Three parameter regimes are represented, with a number of replicates for each.
+  \code{budmoth.sim} is a list of \code{pomp} objects containing the larch budmoth model, budmoth density, parasitism rate, and food quality (needle-length) simulated data.
+  Four parameter regimes are represented.
 }
 \usage{
-data(budmoth.eng)
 data(budmoth.sim)
 }
 \examples{
-data(budmoth.eng)
-plot(budmoth.eng)
-
 data(budmoth.sim)
 names(budmoth.sim)
 ## three regimes, high and low noise regimes for parasitism and tritrophic
-plot(budmoth.sim[["food.1"]])
-plot(budmoth.sim[["para.1"]])
-plot(budmoth.sim[["para.2"]])
-plot(budmoth.sim[["tri.1"]])
+plot(budmoth.sim[["food"]])
+plot(budmoth.sim[["para1"]])
+plot(budmoth.sim[["para2"]])
+plot(budmoth.sim[["tri"]])
 }
 \seealso{the vignettes}
 \keyword{datasets}

Modified: pkg/pompExamples/tests/budmoth.R
===================================================================
--- pkg/pompExamples/tests/budmoth.R	2012-04-17 20:53:41 UTC (rev 665)
+++ pkg/pompExamples/tests/budmoth.R	2012-04-17 21:37:50 UTC (rev 666)
@@ -1,4 +1,4 @@
-require(pomp.devel)
+require(pompExamples)
 
 data(budmoth.sim)
 
@@ -6,3 +6,12 @@
 x <- lapply(budmoth.sim,as,"data.frame")
 
 print(lapply(x,tail))
+
+y <- simulate(budmoth.sim$food,seed=3434996L,as.data.frame=TRUE)
+tail(y)
+
+z <- trajectory(budmoth.sim$tri,as.data.frame=TRUE)
+tail(z)
+
+pf <- pfilter(budmoth.sim$food,seed=34348885L,Np=1000)
+logLik(pf)

Modified: pkg/pompExamples/tests/pertussis.R
===================================================================
--- pkg/pompExamples/tests/pertussis.R	2012-04-17 20:53:41 UTC (rev 665)
+++ pkg/pompExamples/tests/pertussis.R	2012-04-17 21:37:50 UTC (rev 666)
@@ -1,8 +1,20 @@
-require(pomp.devel)
+require(pompExamples)
 
 data(pertussis.sim)
 
 names(pertussis.sim)
-x <- lapply(pertussis.sim,as,"data.frame")
+x <- lapply(pertussis.sim,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)
+
+x <- simulate(pertussis.sim$full.small,seed=395885L,times=100,states=TRUE)[1:6,,1]
+coef(pertussis.sim$full.small,paste0(names(x),".0")) <- x/sum(x)
+
+pf <- pfilter(pertussis.sim$full.small,seed=3445886L,Np=1000)
+logLik(pf)



More information about the pomp-commits mailing list