[Pomp-commits] r612 - in pkg: . R inst inst/doc

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Feb 14 20:24:37 CET 2012


Author: kingaa
Date: 2012-02-14 20:24:37 +0100 (Tue, 14 Feb 2012)
New Revision: 612

Modified:
   pkg/DESCRIPTION
   pkg/R/pomp-methods.R
   pkg/R/pomp.R
   pkg/inst/NEWS
   pkg/inst/doc/advanced_topics_in_pomp.pdf
   pkg/inst/doc/intro_to_pomp.pdf
Log:
- When a pomp object is updated using 'pomp', the 'params' slot will now be copied over (appropriately transformed).  Before, it was simply dropped.


Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION	2012-02-10 17:27:05 UTC (rev 611)
+++ pkg/DESCRIPTION	2012-02-14 19:24:37 UTC (rev 612)
@@ -1,7 +1,7 @@
 Package: pomp
 Type: Package
 Title: Statistical inference for partially observed Markov processes
-Version: 0.40-5
+Version: 0.40-6
 Date: $Date$
 Revision: $Rev$
 Author: Aaron A. King, Edward L. Ionides, Carles Breto, Steve Ellner, Bruce Kendall, Helen Wearing, Matthew J. Ferrari, Michael Lavine, Daniel C. Reuman

Modified: pkg/R/pomp-methods.R
===================================================================
--- pkg/R/pomp-methods.R	2012-02-10 17:27:05 UTC (rev 611)
+++ pkg/R/pomp-methods.R	2012-02-14 19:24:37 UTC (rev 612)
@@ -203,23 +203,27 @@
           "coef",
           "pomp",
           function (object, pars, transform = FALSE, ...) {
-            if (transform) 
-              params <- pomp.transform(object,params=object at params,dir="inverse")
-            else
-              params <- object at params
-            if (missing(pars))
-              pars <- names(params)
-            else {
-              excl <- setdiff(pars,names(params))
-              if (length(excl)>0) {
-                stop(
-                     "in ",sQuote("coef"),": name(s) ",
-                     paste(sQuote(excl),collapse=","),
-                     " correspond to no parameter(s)"
-                     )
+            if (length(object at params)>0) {
+              if (transform) 
+                params <- pomp.transform(object,params=object at params,dir="inverse")
+              else
+                params <- object at params
+              if (missing(pars))
+                pars <- names(params)
+              else {
+                excl <- setdiff(pars,names(params))
+                if (length(excl)>0) {
+                  stop(
+                       "in ",sQuote("coef"),": name(s) ",
+                       paste(sQuote(excl),collapse=","),
+                       " correspond to no parameter(s)"
+                       )
+                }
               }
+              params[pars]
+            } else {
+              numeric(0)
             }
-            params[pars]
           }
           )
 
@@ -229,14 +233,16 @@
           "pomp",
           function (object, pars, transform = FALSE, ..., value) {
             if (missing(pars)) {          ## replace the whole params slot with 'value'
-              if (transform) 
-                value <- pomp.transform(object,params=value,dir="forward")
-              pars <- names(value)
-              if (is.null(pars)) {
-                if (transform)
-                  stop(sQuote("parameter.transform(value)")," must be a named vector")
-                else
-                  stop(sQuote("value")," must be a named vector")
+              if (length(value)>0) {
+                if (transform) 
+                  value <- pomp.transform(object,params=value,dir="forward")
+                pars <- names(value)
+                if (is.null(pars)) {
+                  if (transform)
+                    stop(sQuote("parameter.transform(value)")," must be a named vector")
+                  else
+                    stop(sQuote("value")," must be a named vector")
+                }
               }
               object at params <- value
             } else { ## replace or append only the parameters named in 'pars'
@@ -246,8 +252,9 @@
                         " names of ",sQuote("value")," are being discarded",
                         call.=FALSE
                         )
-##              if (length(pars)!=length(value))
-##                stop(sQuote("pars")," and ",sQuote("value")," must be of equal length")
+###   comment these lines out because 'coef(obj,c("a","b")) <- 3' should be legal
+###              if (length(pars)!=length(value))
+###                stop(sQuote("pars")," and ",sQuote("value")," must be of equal length")
               if (length(object at params)==0) { ## no pre-existing 'params' slot
                 val <- numeric(length(pars))
                 names(val) <- pars

Modified: pkg/R/pomp.R
===================================================================
--- pkg/R/pomp.R	2012-02-10 17:27:05 UTC (rev 611)
+++ pkg/R/pomp.R	2012-02-14 19:24:37 UTC (rev 612)
@@ -526,6 +526,8 @@
             if (missing(skeleton)) skeleton <- data at skeleton
             if (missing(skelmap.delta.t)) skelmap.delta.t <- data at skelmap.delta.t
 
+            pars <- coef(data,transform=TRUE)
+
             if (missing(parameter.transform)) {
               if (missing(parameter.inv.transform)) {
                 par.trans <- data at par.trans
@@ -575,6 +577,10 @@
                            ),
                       userdata
                       )
-                    )
+                    ) -> retval
+
+            coef(retval,transform=TRUE) <- pars            
+
+            retval
           }
           )

Modified: pkg/inst/NEWS
===================================================================
--- pkg/inst/NEWS	2012-02-10 17:27:05 UTC (rev 611)
+++ pkg/inst/NEWS	2012-02-14 19:24:37 UTC (rev 612)
@@ -1,5 +1,8 @@
 NEWS
 0.40-5
+     o	When a pomp object is updated using 'pomp', the 'params' slot will now be copied over (appropriately transformed).
+     	Before, it was simply dropped.
+
      o	More informative error messages when dimension of state space or data space disagree internally.
 
      o	The 'weighted' argument to 'mif' and 'continue' is now deprecated in favor of a new argument 'method'.

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

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



More information about the pomp-commits mailing list