[Pomp-commits] r1048 - in pkg/pomp: . R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Jan 9 14:03:04 CET 2015


Author: kingaa
Date: 2015-01-09 14:03:03 +0100 (Fri, 09 Jan 2015)
New Revision: 1048

Modified:
   pkg/pomp/DESCRIPTION
   pkg/pomp/R/simulate-pomp.R
Log:
- fix bug with 'simulate' when 'include.data=TRUE'

Modified: pkg/pomp/DESCRIPTION
===================================================================
--- pkg/pomp/DESCRIPTION	2015-01-07 10:54:29 UTC (rev 1047)
+++ pkg/pomp/DESCRIPTION	2015-01-09 13:03:03 UTC (rev 1048)
@@ -1,8 +1,8 @@
 Package: pomp
 Type: Package
 Title: Statistical Inference for Partially Observed Markov Processes
-Version: 0.58-2
-Date: 2015-01-07
+Version: 0.58-3
+Date: 2015-01-09
 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/simulate-pomp.R
===================================================================
--- pkg/pomp/R/simulate-pomp.R	2015-01-07 10:54:29 UTC (rev 1047)
+++ pkg/pomp/R/simulate-pomp.R	2015-01-09 13:03:03 UTC (rev 1048)
@@ -79,7 +79,7 @@
                       as.data.frame(t(retval$obs)),
                       as.data.frame(t(retval$states))
                       )
-      retval$sim <- factor(seq_len(nsim))
+      retval$sim <- as.character(seq_len(nsim))
       retval$time <- rep(times,each=nsim)
       retval <- retval[order(retval$sim,retval$time),]
     } else if (obs || states) {
@@ -90,7 +90,7 @@
       dim(retval) <- c(dm[1L],prod(dm[-1L]))
       rownames(retval) <- nm
       retval <- as.data.frame(t(retval))
-      retval$sim <- factor(seq_len(nsim))
+      retval$sim <- as.character(seq_len(nsim))
       retval$time <- rep(times,each=nsim)
       retval <- retval[order(retval$sim,retval$time),]
     } else {
@@ -105,18 +105,22 @@
                          }
                          )
         retval <- do.call(rbind,retval)
-        retval$sim <- factor(retval$sim)
+        retval$sim <- as.character(retval$sim)
       } else {
         retval <- as.data.frame(retval)
-        retval$sim <- factor(1)
+        retval$sim <- "1"
       }
     }
 
     if (include.data) {
       od <- as.data.frame(object)
-      retval <- merge(od,retval,sort=FALSE)
+      od$sim <- "data"
+      od <- od[names(retval)]
+      retval <- rbind(od,retval)
     }
-    
+
+    retval$sim <- factor(retval$sim)
+
   }
 
   retval



More information about the pomp-commits mailing list