[Pomp-commits] r1042 - in pkg/pompExamples: . inst/examples tests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Jan 2 15:04:39 CET 2015


Author: kingaa
Date: 2015-01-02 15:04:38 +0100 (Fri, 02 Jan 2015)
New Revision: 1042

Added:
   pkg/pompExamples/tests/bbp.R
   pkg/pompExamples/tests/bbp.Rout.save
   pkg/pompExamples/tests/ebola.R
   pkg/pompExamples/tests/ebola.Rout.save
   pkg/pompExamples/tests/parus.R
   pkg/pompExamples/tests/parus.Rout.save
Removed:
   pkg/pompExamples/tests/examples.R
Modified:
   pkg/pompExamples/DESCRIPTION
   pkg/pompExamples/inst/examples/ebola.R
   pkg/pompExamples/tests/budmoth.Rout.save
   pkg/pompExamples/tests/pertussis.Rout.save
Log:
- fix ebola example
- rearrange tests directory

Modified: pkg/pompExamples/DESCRIPTION
===================================================================
--- pkg/pompExamples/DESCRIPTION	2015-01-02 02:39:51 UTC (rev 1041)
+++ pkg/pompExamples/DESCRIPTION	2015-01-02 14:04:38 UTC (rev 1042)
@@ -1,8 +1,8 @@
 Package: pompExamples
 Type: Package
 Title: Additional pomp examples
-Version: 0.25-2
-Date: 2015-01-01
+Version: 0.25-3
+Date: 2015-01-02
 Maintainer: Aaron A. King <kingaa at umich.edu>
 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/ebola.R
===================================================================
--- pkg/pompExamples/inst/examples/ebola.R	2015-01-02 02:39:51 UTC (rev 1041)
+++ pkg/pompExamples/inst/examples/ebola.R	2015-01-02 14:04:38 UTC (rev 1042)
@@ -54,6 +54,7 @@
 mutate(dat,deaths=NA) -> dat
 
 ebolaModel <- function (country=c("Guinea", "SierraLeone", "Liberia", "WestAfrica"),
+                        data = NULL,
                         timestep = 0.01, nstageE = 3L,
                         type = c("raw","cum"), na.rm = FALSE, least.sq = FALSE) {
 
@@ -77,14 +78,18 @@
              S_0=1-index_case,E_0=index_case/2-5e-9,
              I_0=index_case/2-5e-9,R_0=1e-8)
 
-  if (ctry=="WestAfrica") {
-    dat <- ddply(dat,~week,summarize,
-                 cases=sum(cases,na.rm=TRUE),
-                 deaths=sum(deaths,na.rm=TRUE))
+  if (is.null(data)) {
+    if (ctry=="WestAfrica") {
+      dat <- ddply(dat,~week,summarize,
+                   cases=sum(cases,na.rm=TRUE),
+                   deaths=sum(deaths,na.rm=TRUE))
+    } else {
+      dat <- subset(dat,country==ctry,select=-country)
+    }
   } else {
-    dat <- subset(dat,country==ctry,select=-country)
+    dat <- data
   }
-
+    
   if (na.rm) {
     dat <- mutate(subset(dat,!is.na(cases)),week=week-min(week)+1)
   }

Added: pkg/pompExamples/tests/bbp.R
===================================================================
--- pkg/pompExamples/tests/bbp.R	                        (rev 0)
+++ pkg/pompExamples/tests/bbp.R	2015-01-02 14:04:38 UTC (rev 1042)
@@ -0,0 +1,7 @@
+library(pompExamples)
+
+set.seed(47575684L)
+
+pompExample(bbp)
+pf <- pfilter(simulate(bbp),Np=100,max.fail=Inf)
+tj <- trajectory(bbp)

Added: pkg/pompExamples/tests/bbp.Rout.save
===================================================================
--- pkg/pompExamples/tests/bbp.Rout.save	                        (rev 0)
+++ pkg/pompExamples/tests/bbp.Rout.save	2015-01-02 14:04:38 UTC (rev 1042)
@@ -0,0 +1,33 @@
+
+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
+> 
+> set.seed(47575684L)
+> 
+> pompExample(bbp)
+newly created pomp object(s):
+ bbp 
+> pf <- pfilter(simulate(bbp),Np=100,max.fail=Inf)
+> tj <- trajectory(bbp)
+> 
+> proc.time()
+   user  system elapsed 
+  0.573   0.038   0.597 

Modified: pkg/pompExamples/tests/budmoth.Rout.save
===================================================================
--- pkg/pompExamples/tests/budmoth.Rout.save	2015-01-02 02:39:51 UTC (rev 1041)
+++ pkg/pompExamples/tests/budmoth.Rout.save	2015-01-02 14:04:38 UTC (rev 1042)
@@ -127,4 +127,4 @@
 > 
 > proc.time()
    user  system elapsed 
-  0.649   0.033   0.670 
+  0.614   0.056   0.652 

Added: pkg/pompExamples/tests/ebola.R
===================================================================
--- pkg/pompExamples/tests/ebola.R	                        (rev 0)
+++ pkg/pompExamples/tests/ebola.R	2015-01-02 14:04:38 UTC (rev 1042)
@@ -0,0 +1,15 @@
+library(pompExamples)
+
+set.seed(47575684L)
+
+pompExample(ebola)
+ebolaModel(country="Guinea") -> po
+pf <- pfilter(simulate(po),Np=100)
+tj <- trajectory(po)
+
+ebolaModel(country="SierraLeone",na.rm=TRUE,type='cum') -> po
+pf <- pfilter(simulate(po),Np=100)
+tj <- trajectory(po)
+dd <- simulate(po,as.data.frame=TRUE,obs=TRUE)
+dd$week <- dd$time
+po <- ebolaModel(data=subset(dd,select=c(week,cases,deaths)))

Added: pkg/pompExamples/tests/ebola.Rout.save
===================================================================
--- pkg/pompExamples/tests/ebola.Rout.save	                        (rev 0)
+++ pkg/pompExamples/tests/ebola.Rout.save	2015-01-02 14:04:38 UTC (rev 1042)
@@ -0,0 +1,43 @@
+
+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
+> 
+> set.seed(47575684L)
+> 
+> pompExample(ebola)
+Loading required package: plyr
+Loading required package: reshape2
+newly created pomp object(s):
+ ebolaModel 
+> ebolaModel(country="Guinea") -> po
+> pf <- pfilter(simulate(po),Np=100)
+> tj <- trajectory(po)
+> 
+> ebolaModel(country="SierraLeone",na.rm=TRUE,type='cum') -> po
+> pf <- pfilter(simulate(po),Np=100)
+> tj <- trajectory(po)
+> dd <- simulate(po,as.data.frame=TRUE,obs=TRUE)
+> dd$week <- dd$time
+> po <- ebolaModel(data=subset(dd,select=c(week,cases,deaths)))
+> 
+> proc.time()
+   user  system elapsed 
+  1.100   0.034   1.119 

Deleted: pkg/pompExamples/tests/examples.R
===================================================================
--- pkg/pompExamples/tests/examples.R	2015-01-02 02:39:51 UTC (rev 1041)
+++ pkg/pompExamples/tests/examples.R	2015-01-02 14:04:38 UTC (rev 1042)
@@ -1,33 +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)
-
-pompExample(ebola)
-ebolaModel(country="Guinea") -> po
-pf <- pfilter(simulate(po),Np=100)
-tj <- trajectory(po)
-
-ebolaModel(country="SierraLeone",na.rm=TRUE,type='cum') -> po
-pf <- pfilter(simulate(po),Np=100)
-tj <- trajectory(po)

Copied: pkg/pompExamples/tests/parus.R (from rev 1041, pkg/pompExamples/tests/examples.R)
===================================================================
--- pkg/pompExamples/tests/parus.R	                        (rev 0)
+++ pkg/pompExamples/tests/parus.R	2015-01-02 14:04:38 UTC (rev 1042)
@@ -0,0 +1,20 @@
+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)

Added: pkg/pompExamples/tests/parus.Rout.save
===================================================================
--- pkg/pompExamples/tests/parus.Rout.save	                        (rev 0)
+++ pkg/pompExamples/tests/parus.Rout.save	2015-01-02 14:04:38 UTC (rev 1042)
@@ -0,0 +1,44 @@
+
+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
+> 
+> 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)
+> 
+> proc.time()
+   user  system elapsed 
+  0.572   0.037   0.596 

Modified: pkg/pompExamples/tests/pertussis.Rout.save
===================================================================
--- pkg/pompExamples/tests/pertussis.Rout.save	2015-01-02 02:39:51 UTC (rev 1041)
+++ pkg/pompExamples/tests/pertussis.Rout.save	2015-01-02 14:04:38 UTC (rev 1042)
@@ -168,4 +168,4 @@
 > 
 > proc.time()
    user  system elapsed 
- 23.494   0.034  23.544 
+ 23.697   0.033  23.738 



More information about the pomp-commits mailing list