[Pomp-commits] r1043 - in pkg/pomp: . R inst man

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


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

Modified:
   pkg/pomp/DESCRIPTION
   pkg/pomp/R/simulate-pomp.R
   pkg/pomp/inst/NEWS
   pkg/pomp/inst/NEWS.Rd
   pkg/pomp/man/simulate-pomp.Rd
Log:
- new 'include.data' argument to 'simulate'

Modified: pkg/pomp/DESCRIPTION
===================================================================
--- pkg/pomp/DESCRIPTION	2015-01-02 14:04:38 UTC (rev 1042)
+++ pkg/pomp/DESCRIPTION	2015-01-02 14:04:49 UTC (rev 1043)
@@ -1,8 +1,8 @@
 Package: pomp
 Type: Package
 Title: Statistical Inference for Partially Observed Markov Processes
-Version: 0.56-2
-Date: 2015-01-01
+Version: 0.57-1
+Date: 2015-01-02
 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-02 14:04:38 UTC (rev 1042)
+++ pkg/pomp/R/simulate-pomp.R	2015-01-02 14:04:49 UTC (rev 1043)
@@ -3,6 +3,7 @@
 simulate.internal <- function (object, nsim = 1, seed = NULL, params,
                                states = FALSE, obs = FALSE,
                                times, t0, as.data.frame = FALSE,
+                               include.data = FALSE,
                                .getnativesymbolinfo = TRUE, ...) {
 
   if (missing(times))
@@ -18,6 +19,7 @@
   obs <- as.logical(obs)
   states <- as.logical(states)
   as.data.frame <- as.logical(as.data.frame)
+  include.data <- as.logical(include.data)
 
   if (missing(params))
     params <- coef(object)
@@ -109,6 +111,11 @@
         retval$sim <- factor(1)
       }
     }
+
+    if (include.data) {
+      od <- as.data.frame(object)
+      retval <- merge(od,retval,sort=FALSE)
+    }
     
   }
 
@@ -119,8 +126,9 @@
           "simulate",
           signature=signature(object="pomp"),
           definition=function (object, nsim = 1, seed = NULL, params,
-                               states = FALSE, obs = FALSE,
-                               times, t0, as.data.frame = FALSE, ...)
+            states = FALSE, obs = FALSE,
+            times, t0, as.data.frame = FALSE, include.data = FALSE,
+            ...)
           simulate.internal(
                             object=object,
                             nsim=nsim,
@@ -131,6 +139,7 @@
                             times=times,
                             t0=t0,
                             as.data.frame=as.data.frame,
+                            include.data=include.data,
                             ...
                             )
           )

Modified: pkg/pomp/inst/NEWS
===================================================================
--- pkg/pomp/inst/NEWS	2015-01-02 14:04:38 UTC (rev 1042)
+++ pkg/pomp/inst/NEWS	2015-01-02 14:04:49 UTC (rev 1043)
@@ -1,5 +1,12 @@
 _N_e_w_s _f_o_r _p_a_c_k_a_g_e '_p_o_m_p'
 
+_C_h_a_n_g_e_s _i_n '_p_o_m_p' _v_e_r_s_i_o_n _0._5_7-_1:
+
+        • ‘simulate’ has a new argument, ‘include.data’, that when used
+          in conjuncion with ‘as.data.frame=TRUE’ will include the
+          actual data in the resulting data frame along with the
+          simulations.
+
 _C_h_a_n_g_e_s _i_n '_p_o_m_p' _v_e_r_s_i_o_n _0._5_6-_1:
 
         • Revamped the ‘pompExample’ function.  A search path for

Modified: pkg/pomp/inst/NEWS.Rd
===================================================================
--- pkg/pomp/inst/NEWS.Rd	2015-01-02 14:04:38 UTC (rev 1042)
+++ pkg/pomp/inst/NEWS.Rd	2015-01-02 14:04:49 UTC (rev 1043)
@@ -1,5 +1,10 @@
 \name{NEWS}
 \title{News for package `pomp'}
+\section{Changes in \pkg{pomp} version 0.57-1}{
+  \itemize{
+    \item \code{simulate} has a new argument, \code{include.data}, that when used in conjuncion with \code{as.data.frame=TRUE} will include the actual data in the resulting data frame along with the simulations.
+  }
+}
 \section{Changes in \pkg{pomp} version 0.56-1}{
   \itemize{
     \item Revamped the \code{pompExample} function.

Modified: pkg/pomp/man/simulate-pomp.Rd
===================================================================
--- pkg/pomp/man/simulate-pomp.Rd	2015-01-02 14:04:38 UTC (rev 1042)
+++ pkg/pomp/man/simulate-pomp.Rd	2015-01-02 14:04:49 UTC (rev 1043)
@@ -9,7 +9,7 @@
 \usage{
 \S4method{simulate}{pomp}(object, nsim = 1, seed = NULL, params,
          states = FALSE, obs = FALSE, times, t0,
-         as.data.frame = FALSE, \dots)
+         as.data.frame = FALSE, include.data = FALSE, \dots)
 }
 \arguments{
   \item{object}{An object of class \code{pomp}.}
@@ -34,8 +34,11 @@
     \code{t0} specifies the start time (the time at which the initial conditions hold).
     The default for \code{times} is is \code{times=time(object,t0=FALSE)} and \code{t0=timezero(object)}, respectively.
   }
-  \item{as.data.frame}{
-    logical; if \code{TRUE}, return the result as a data-frame.
+  \item{as.data.frame, include.data}{
+    logical; if \code{as.data.frame=TRUE}, the results are returned as a data-frame.
+    A factor variable, \sQuote{sim}, distinguishes one simulation from another.
+    If, in addition, \code{include.data=TRUE}, the original data are included as an additional \sQuote{simulation}.
+    If \code{as.data.frame=FALSE}, \code{include.data} is ignored.
   }
   \item{\dots}{further arguments that are currently ignored.}
 }
@@ -64,6 +67,8 @@
 pompExample(ou2)
 x <- simulate(ou2,seed=3495485,nsim=10)
 x <- simulate(ou2,seed=3495485,nsim=10,states=TRUE,obs=TRUE)
+x <- simulate(ou2,seed=3495485,nsim=10,obs=TRUE,
+              as.data.frame=TRUE,include.data=TRUE)
 }
 \author{Aaron A. King \email{kingaa at umich dot edu}}
 \seealso{\link{pomp}}



More information about the pomp-commits mailing list