[Pomp-commits] r282 - in pkg: R inst inst/doc man tests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Jul 2 18:33:50 CEST 2010


Author: kingaa
Date: 2010-07-02 18:33:50 +0200 (Fri, 02 Jul 2010)
New Revision: 282

Modified:
   pkg/R/mif.R
   pkg/R/pomp-methods.R
   pkg/inst/ChangeLog
   pkg/inst/doc/advanced_topics_in_pomp.pdf
   pkg/inst/doc/intro_to_pomp.Rnw
   pkg/inst/doc/intro_to_pomp.pdf
   pkg/inst/doc/pomp.bib
   pkg/man/pomp-methods.Rd
   pkg/man/simulate-pomp.Rd
   pkg/tests/rw2.R
   pkg/tests/rw2.Rout.save
Log:
- add warning in 'coef<-' where parameter values might unintentionally be mismatched
- redefine some of the generics using standardGeneric()
- change 'include.t0' argument in 'time<-()' to 't0' to match 'time()'
- improve documentation of 'simulate' method slightly
- add Bhadra article to pomp.bib


Modified: pkg/R/mif.R
===================================================================
--- pkg/R/mif.R	2010-06-30 21:57:15 UTC (rev 281)
+++ pkg/R/mif.R	2010-07-02 16:33:50 UTC (rev 282)
@@ -270,7 +270,7 @@
 
   }
 
-  coef(obj,names(theta)) <- theta
+  coef(obj,names(theta)) <- unname(theta)
 
   if (Nmif>0) {
     obj at Nmif <- as.integer(Nmif)

Modified: pkg/R/pomp-methods.R
===================================================================
--- pkg/R/pomp-methods.R	2010-06-30 21:57:15 UTC (rev 281)
+++ pkg/R/pomp-methods.R	2010-07-02 16:33:50 UTC (rev 282)
@@ -1,29 +1,21 @@
 ## this file contains some basic methods definitions
 
 ## functions to extract or call the components of a "pomp" object
-data.array <- function (object, ...)
-  stop("function ",sQuote("data.array")," is undefined for objects of class ",sQuote(class(object)))
-setGeneric('data.array')  
+setGeneric("data.array",function(object,...)standardGeneric("data.array"))
 
-"time<-" <- function (object, ..., value)
-  stop("function ",sQuote("time<-")," is undefined for objects of class ",sQuote(class(object)))
-setGeneric("time<-")  
+setGeneric("time<-",function(object,...,value)standardGeneric("time<-"))  
 
-"coef<-" <- function (object, pars, ..., value)
-  stop("function ",sQuote("coef<-")," is undefined for objects of class ",sQuote(class(object)))
-setGeneric("coef<-")
+setGeneric("coef<-",function(object,...,value)standardGeneric("coef<-"))
 
-states <- function (object, ...)
-  stop("function ",sQuote("states")," is undefined for objects of class ",sQuote(class(object)))
-setGeneric('states')
+setGeneric("states",function(object,...)standardGeneric("states"))
 
 ## 'coerce' method: allows for coercion of a "pomp" object to a data-frame
 setAs(
-      from='pomp',
-      to='data.frame',
+      from="pomp",
+      to="data.frame",
       def = function (from) {
         x <- as.data.frame(cbind(from at times,t(from at data)))
-        names(x) <- c('time',rownames(from at data))
+        names(x) <- c("time",rownames(from at data))
         if (length(from at states)>0) {
           nm <- names(x)
           x <- cbind(x,t(from at states[,-1,drop=FALSE]))
@@ -35,8 +27,8 @@
 
 ## a simple method to extract the data array
 setMethod(
-          'data.array',
-          'pomp',
+          "data.array",
+          "pomp",
           function (object, vars, ...) {
             if (missing(vars))
               vars <- seq(length=nrow(object at data))
@@ -46,8 +38,8 @@
 
 ## a simple method to extract the array of states
 setMethod(
-          'states',
-          'pomp',
+          "states",
+          "pomp",
           function (object, vars, ...) {
             if (missing(vars))
               vars <- seq(length=nrow(object at states))
@@ -68,7 +60,7 @@
 setMethod(
           "time<-",
           "pomp",
-          function (object, include.t0 = FALSE, ..., value) {
+          function (object, t0 = FALSE, ..., value) {
             if (!is.numeric(value))
               stop(sQuote("value")," must be a numeric vector",call.=TRUE)
             storage.mode(value) <- "double"
@@ -76,7 +68,7 @@
             tt <- object at times
             dd <- object at data
             ss <- object at states
-            if (include.t0) {
+            if (t0) {
               object at t0 <- value[1]
               object at times <- value[-1]
             } else {
@@ -112,8 +104,8 @@
 
 ## extract the coefficients
 setMethod(
-          'coef',
-          'pomp',
+          "coef",
+          "pomp",
           function (object, pars, ...) {
             if (missing(pars)) {
               pars <- names(object at params)
@@ -122,7 +114,7 @@
               if (any(excl)) {
                 stop(
                      "in ",sQuote("coef"),": name(s) ",
-                     paste(sapply(pars[excl],sQuote),collapse=','),
+                     paste(sapply(pars[excl],sQuote),collapse=","),
                      " correspond to no parameter(s)"
                      )
               }
@@ -133,8 +125,8 @@
 
 ## modify the coefficients
 setMethod(
-          'coef<-',
-          'pomp',
+          "coef<-",
+          "pomp",
           function (object, pars, ..., value) {
             if (length(object at params)==0) {
               if (missing(pars)) {
@@ -157,13 +149,15 @@
                 if (any(excl)) {
                   stop(
                        "in ",sQuote("coef<-"),": name(s) ",
-                       paste(sapply(pars[excl],sQuote),collapse=','),
+                       paste(sapply(pars[excl],sQuote),collapse=","),
                        " correspond to no parameter(s)"
                        )
                 }
               }
               if (length(pars)!=length(value))
                 stop("in ",sQuote("coef<-"),": ",sQuote("pars")," and ",sQuote("value")," must be of the same length")
+              if (!is.null(names(value)))
+                warning("in ",sQuote("coef<-"),": names of ",sQuote("value")," are being discarded",call.=FALSE)
               object at params[pars] <- as.numeric(value)
             }
             object
@@ -171,11 +165,11 @@
           )
 
 setMethod(
-          'print',
-          'pomp',
+          "print",
+          "pomp",
           function (x, ...) {
             cat("data and states:\n")
-            print(as(x,'data.frame'))
+            print(as(x,"data.frame"))
             cat("\ncall:\n")
             print(x at call)
             invisible(x)
@@ -183,8 +177,8 @@
           )
 
 setMethod(
-          'show',
-          'pomp',
+          "show",
+          "pomp",
           function (object) {
             print(object)
             cat("zero time, t0 = ",object at t0,"\n",sep="")

Modified: pkg/inst/ChangeLog
===================================================================
--- pkg/inst/ChangeLog	2010-06-30 21:57:15 UTC (rev 281)
+++ pkg/inst/ChangeLog	2010-07-02 16:33:50 UTC (rev 282)
@@ -1,5 +1,12 @@
 2010-06-30  kingaa
 
+	* [r281] DESCRIPTION, R/traj-match.R, R/trajmatch.R,
+	  man/mif-class.Rd, man/traj-match.Rd, man/trajmatch.Rd: - minor
+	  rearrangements of files
+	  - fix typo
+	* [r279] inst/doc/pomp.bib: - fix Andrieu et al. entry
+	* [r278] inst/ChangeLog, inst/doc/advanced_topics_in_pomp.pdf,
+	  inst/doc/intro_to_pomp.pdf: - vignettes and Changelog up to date
 	* [r275] DESCRIPTION, NAMESPACE, R/compare.pmcmc.R,
 	  R/pmcmc-methods.R, R/pmcmc.R, R/simulate-pomp.R, inst/NEWS,
 	  inst/doc/pomp.bib, man/pmcmc-class.Rd, man/pmcmc-methods.Rd,

Modified: pkg/inst/doc/advanced_topics_in_pomp.pdf
===================================================================
(Binary files differ)

Modified: pkg/inst/doc/intro_to_pomp.Rnw
===================================================================
--- pkg/inst/doc/intro_to_pomp.Rnw	2010-06-30 21:57:15 UTC (rev 281)
+++ pkg/inst/doc/intro_to_pomp.Rnw	2010-07-02 16:33:50 UTC (rev 282)
@@ -481,7 +481,7 @@
 The times can be changed using
 <<eval=F>>=
 time(ou2) <- 1:10
-time(ou2,include.t0=T) <- seq(from=0,to=10,by=1)
+time(ou2,t0=T) <- seq(from=0,to=10,by=1)
 @ 
 One can read and change parameters associated with the \pomp\ object using, e.g.,
 <<eval=F>>=

Modified: pkg/inst/doc/intro_to_pomp.pdf
===================================================================
(Binary files differ)

Modified: pkg/inst/doc/pomp.bib
===================================================================
--- pkg/inst/doc/pomp.bib	2010-06-30 21:57:15 UTC (rev 281)
+++ pkg/inst/doc/pomp.bib	2010-07-02 16:33:50 UTC (rev 282)
@@ -43,6 +43,20 @@
   timestamp = {2007.07.20}
 }
 
+ at ARTICLE{Bhadra2010,
+  author = {Bhadra, Anindya},
+  title = {Discussion of `Particle {M}arkov chain {M}onte {C}arlo methods' by
+	C.\ Andrieu, A.\ Doucet and R.\ Holenstein},
+  journal = {Journal of the Royal Statistical Society, Series B},
+  year = {2010},
+  volume = {72},
+  pages = {314--315},
+  doi = {10.1111/j.1467-9868.2009.00736.x},
+  textref = {Bhadra, A. (2010), Discussion of `Particle Markov chain Monte Carlo
+	methods' by C. Andrieu, A. Doucet and R. Holenstein, J. Roy. Stat.
+	Soc B 72:314-315}
+}
+
 @ARTICLE{Breto2009,
   author = {Carles Bret\'{o} and Daihai He and Edward L. Ionides and Aaron A.
 	King},

Modified: pkg/man/pomp-methods.Rd
===================================================================
--- pkg/man/pomp-methods.Rd	2010-06-30 21:57:15 UTC (rev 281)
+++ pkg/man/pomp-methods.Rd	2010-07-02 16:33:50 UTC (rev 282)
@@ -33,7 +33,7 @@
 \S4method{data.array}{pomp}(object, vars, \dots)
 \S4method{states}{pomp}(object, vars, \dots)
 \S4method{time}{pomp}(x, t0 = FALSE, \dots)
-\S4method{time}{pomp}(object, include.t0 = FALSE, \dots) <- value
+\S4method{time}{pomp}(object, t0 = FALSE, \dots) <- value
 \S4method{show}{pomp}(object)
 \S4method{as}{pomp}(object, class)
 \S4method{coerce}{pomp,data.frame}(from, to = "data.frame", strict = TRUE)
@@ -59,12 +59,9 @@
   }
   \item{t0}{
     logical;
-    if TRUE, the zero time is prepended to the time vector.
+    if TRUE on a call to \code{time}, the zero time is prepended to the time vector;
+    if TRUE on a call to \code{time<-}, the first element in \code{value} is taken to be the initial time.
   }
-  \item{include.t0}{
-    logical;
-    if TRUE, the first element in \code{value} is taken to be the initial time.
-  }
   \item{class}{
     character;
     name of the class to which \code{object} should be coerced.
@@ -136,7 +133,7 @@
     }
     \item{time<-}{
       \code{time(object) <- value} replaces the observation times slot (\code{times}) of \code{object} with \code{value}.
-      \code{time(object,include.t0 = TRUE) <- value} has the same effect, but the first element in \code{value} is taken to be the initial time.
+      \code{time(object,t0=TRUE) <- value} has the same effect, but the first element in \code{value} is taken to be the initial time.
       The second and subsequent elements of \code{value} are taken to be the observation times.
       Those data and states (if they exist) corresponding to the new times are retained.
     }

Modified: pkg/man/simulate-pomp.Rd
===================================================================
--- pkg/man/simulate-pomp.Rd	2010-06-30 21:57:15 UTC (rev 281)
+++ pkg/man/simulate-pomp.Rd	2010-07-02 16:33:50 UTC (rev 282)
@@ -17,7 +17,11 @@
     The number of simulations to perform.
     Note that the number of replicates will be \code{nsim} times \code{ncol(xstart)}.
   }
-  \item{seed}{optional; the random seed to use.}
+  \item{seed}{
+    optional; if set, the pseudorandom number generator (RNG) will be initialized with \code{seed}.
+    the random seed to use.
+    The RNG will be restored to its original state afterward.
+  }
   \item{params}{
     The parameters to use in simulating the model.
     If \code{params} is not given, then the contents of the \code{params} slot of \code{object} will be used, if they exist.

Modified: pkg/tests/rw2.R
===================================================================
--- pkg/tests/rw2.R	2010-06-30 21:57:15 UTC (rev 281)
+++ pkg/tests/rw2.R	2010-07-02 16:33:50 UTC (rev 282)
@@ -187,10 +187,10 @@
 try(
     time(rw2) <- c(0,5,10,15,12,20)
     )
-time(rw2,include.t0=TRUE) <- seq(-20,1000,by=20)
+time(rw2,t0=TRUE) <- seq(-20,1000,by=20)
 x <- simulate(rw2)
 time(rw2) <- c(0,20,25.8,50,60)
-time(rw2,include.t0=TRUE) <- c(0,20,25.8,50,60)
-time(rw2,include.t0=TRUE) <- c(0,0,20,25.8,50,60)
+time(rw2,t0=TRUE) <- c(0,20,25.8,50,60)
+time(rw2,t0=TRUE) <- c(0,0,20,25.8,50,60)
 time(rw2) <- c(0,20,25.8,50,60)
 

Modified: pkg/tests/rw2.Rout.save
===================================================================
--- pkg/tests/rw2.Rout.save	2010-06-30 21:57:15 UTC (rev 281)
+++ pkg/tests/rw2.Rout.save	2010-07-02 16:33:50 UTC (rev 282)
@@ -1,6 +1,6 @@
 
-R version 2.10.1 (2009-12-14)
-Copyright (C) 2009 The R Foundation for Statistical Computing
+R version 2.11.1 (2010-05-31)
+Copyright (C) 2010 The R Foundation for Statistical Computing
 ISBN 3-900051-07-0
 
 R is free software and comes with ABSOLUTELY NO WARRANTY.
@@ -16,9 +16,6 @@
 Type 'q()' to quit R.
 
 > library(pomp)
-Loading required package: deSolve
-Loading required package: subplex
-Loading required package: mvtnorm
 > 
 > set.seed(45768683)
 > 
@@ -258,7 +255,7 @@
     }
     y
 }
-<environment: 0x160cbd8>
+<environment: 0x2629720>
 measurement model density, dmeasure = 
 function (y, x, t, params, log, covars, ...) 
 {
@@ -271,7 +268,7 @@
         f
     else exp(f)
 }
-<environment: 0x160cbd8>
+<environment: 0x2629720>
 initializer = 
 function (params, t0, ...) 
 {
@@ -409,11 +406,11 @@
 +     )
 Error in .local(object, ..., value = value) : 
   the times specified must be an increasing sequence
-> time(rw2,include.t0=TRUE) <- seq(-20,1000,by=20)
+> time(rw2,t0=TRUE) <- seq(-20,1000,by=20)
 > x <- simulate(rw2)
 > time(rw2) <- c(0,20,25.8,50,60)
-> time(rw2,include.t0=TRUE) <- c(0,20,25.8,50,60)
-> time(rw2,include.t0=TRUE) <- c(0,0,20,25.8,50,60)
+> time(rw2,t0=TRUE) <- c(0,20,25.8,50,60)
+> time(rw2,t0=TRUE) <- c(0,0,20,25.8,50,60)
 > time(rw2) <- c(0,20,25.8,50,60)
 > 
 > 



More information about the pomp-commits mailing list