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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Jan 2 03:39:52 CET 2015


Author: kingaa
Date: 2015-01-02 03:39:51 +0100 (Fri, 02 Jan 2015)
New Revision: 1041

Modified:
   pkg/pompExamples/DESCRIPTION
   pkg/pompExamples/inst/examples/ebola.R
Log:
- fix bug

Modified: pkg/pompExamples/DESCRIPTION
===================================================================
--- pkg/pompExamples/DESCRIPTION	2015-01-01 23:13:41 UTC (rev 1040)
+++ pkg/pompExamples/DESCRIPTION	2015-01-02 02:39:51 UTC (rev 1041)
@@ -1,7 +1,7 @@
 Package: pompExamples
 Type: Package
 Title: Additional pomp examples
-Version: 0.25-1
+Version: 0.25-2
 Date: 2015-01-01
 Maintainer: Aaron A. King <kingaa at umich.edu>
 Authors at R: c(person(given=c("Aaron","A."),family="King",role=c("aut","cre"),

Modified: pkg/pompExamples/inst/examples/ebola.R
===================================================================
--- pkg/pompExamples/inst/examples/ebola.R	2015-01-01 23:13:41 UTC (rev 1040)
+++ pkg/pompExamples/inst/examples/ebola.R	2015-01-02 02:39:51 UTC (rev 1041)
@@ -3,7 +3,7 @@
 require(reshape2)
 
 WHO.situation.report.Oct.1 <- '
-Week,Guinea,Liberia,SierraLeone
+week,Guinea,Liberia,SierraLeone
 1,2.244,,
 2,2.244,,
 3,0.073,,
@@ -50,7 +50,6 @@
 populations["WestAfrica"] <- sum(populations)
 
 dat <- read.csv(text=WHO.situation.report.Oct.1,stringsAsFactors=FALSE)
-rename(dat,c(Week="week")) -> dat
 dat <- melt(dat,id="week",variable.name="country",value.name="cases")
 mutate(dat,deaths=NA) -> dat
 
@@ -78,7 +77,14 @@
              S_0=1-index_case,E_0=index_case/2-5e-9,
              I_0=index_case/2-5e-9,R_0=1e-8)
 
-  dat <- subset(dat,country==ctry,select=-country)
+  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)
+  }
+
   if (na.rm) {
     dat <- mutate(subset(dat,!is.na(cases)),week=week-min(week)+1)
   }
@@ -86,8 +92,6 @@
     dat <- mutate(dat,cases=cumsum(cases),deaths=cumsum(deaths))
   }
 
-  print(dat)
-
   ## Create the pomp object
   pomp(
        data=dat,
@@ -99,7 +103,7 @@
        zeronames=if (type=="raw") c("N_EI","N_IR") else character(0),
        paramnames=c("N","R0","alpha","gamma","rho","k","cfr",
          "S_0","E_0","I_0","R_0"),
-       nstageE=nstageE,
+       nstageE=as.integer(nstageE),
        PACKAGE="pompExamples",
        dmeasure=if (least.sq) "_ebola_dObsLS" else "_ebola_dObs",
        rmeasure=if (least.sq) "_ebola_rObsLS" else "_ebola_rObs",



More information about the pomp-commits mailing list