[Pomp-commits] r834 - in pkg/pomp: . R man tests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Mar 10 23:24:43 CET 2013


Author: kingaa
Date: 2013-03-10 23:24:43 +0100 (Sun, 10 Mar 2013)
New Revision: 834

Modified:
   pkg/pomp/DESCRIPTION
   pkg/pomp/R/mif.R
   pkg/pomp/man/mif.Rd
   pkg/pomp/tests/ou2-mif2.R
   pkg/pomp/tests/ou2-mif2.Rout.save
Log:
- default for mif method 'mif2' is now ic.lag=length(time(object))


Modified: pkg/pomp/DESCRIPTION
===================================================================
--- pkg/pomp/DESCRIPTION	2013-03-10 21:00:05 UTC (rev 833)
+++ pkg/pomp/DESCRIPTION	2013-03-10 22:24:43 UTC (rev 834)
@@ -1,8 +1,8 @@
 Package: pomp
 Type: Package
 Title: Statistical inference for partially observed Markov processes
-Version: 0.44-1
-Date: 2013-02-26
+Version: 0.44-2
+Date: 2013-03-11
 Author: Aaron A. King, Edward L. Ionides, Carles Breto, Steve Ellner, Bruce Kendall, Helen Wearing, Matthew J. Ferrari, Michael Lavine, Daniel C. Reuman
 Maintainer: Aaron A. King <kingaa at umich.edu>
 URL: http://pomp.r-forge.r-project.org

Modified: pkg/pomp/R/mif.R
===================================================================
--- pkg/pomp/R/mif.R	2013-03-10 21:00:05 UTC (rev 833)
+++ pkg/pomp/R/mif.R	2013-03-10 22:24:43 UTC (rev 834)
@@ -89,11 +89,11 @@
                           particles,
                           rw.sd,
                           Np, var.factor, ic.lag,
-                          cooling.type, cooling.fraction, cooling.factor, 
+                          cooling.type, cooling.fraction, cooling.factor,
                           method,
                           tol, max.fail,
                           verbose, transform, .ndone = 0L,
-                          paramMatrix,
+                          paramMatrix = NULL,
                           .getnativesymbolinfo = TRUE) {
   
   gnsi <- as.logical(.getnativesymbolinfo)
@@ -123,9 +123,6 @@
   if (length(rw.names) == 0)
     stop("mif error: ",sQuote("rw.sd")," must have one positive entry for each parameter to be estimated",call.=FALSE)
   
-  if (missing(pars)) stop("mif error: ",sQuote("pars")," must be specified",call.=FALSE)
-  if (missing(ivps)) stop("mif error: ",sQuote("ivps")," must be specified",call.=FALSE)
-  
   if (
       !is.character(pars) ||
       !is.character(ivps) ||
@@ -163,11 +160,8 @@
   rw.sd <- rw.sd[c(pars,ivps)]
   rw.names <- names(rw.sd)
   
-  if (missing(particles))
-    stop("mif error: ",sQuote("particles")," must be specified",call.=FALSE)
-  
   ntimes <- length(time(object))
-  if (missing(Np)) stop("mif error: ",sQuote("Np")," must be specified",call.=FALSE)
+  if (is.null(Np)) stop("mif error: ",sQuote("Np")," must be specified",call.=FALSE)
   if (is.function(Np)) {
     Np <- try(
               vapply(seq.int(from=0,to=ntimes,by=1),Np,numeric(1)),
@@ -186,7 +180,6 @@
     stop(sQuote("Np")," must be a number, a vector of numbers, or a function")
   Np <- as.integer(Np)
   
-  if (missing(ic.lag)) stop("mif error: ",sQuote("ic.lag")," must be specified",call.=FALSE)
   ic.lag <- as.integer(ic.lag)
   if ((length(ic.lag)!=1)||(ic.lag<1))
     stop("mif error: ",sQuote("ic.lag")," must be a positive integer",call.=FALSE)
@@ -289,7 +282,7 @@
     pfp <- obj
   }
   
-  have.parmat <- !(missing(paramMatrix) || length(paramMatrix)==0)
+  have.parmat <- !(is.null(paramMatrix) || length(paramMatrix)==0)
 
   for (n in seq_len(Nmif)) { ## iterate the filtering
 
@@ -416,14 +409,19 @@
             if (missing(start)) start <- coef(object)
             if (missing(rw.sd))
               stop("mif error: ",sQuote("rw.sd")," must be specified",call.=FALSE)
+            if (missing(ic.lag) && length(ivps)>0) {
+              if (method=="mif2")
+                ic.lag <- length(time(object)) # default mif2 behavior
+              else
+                stop("mif error: ",sQuote("ic.lag")," must be specified if ",sQuote("ivps"),
+                     " are",call.=FALSE)
+            }
             if (missing(pars)) {
               rw.names <- names(rw.sd)[rw.sd>0]
               pars <- rw.names[!(rw.names%in%ivps)]
             }
             if (missing(Np))
               stop("mif error: ",sQuote("Np")," must be specified",call.=FALSE)
-            if (missing(ic.lag) && length(ivps)>0)
-              stop("mif error: ",sQuote("ic.lag")," must be specified if ",sQuote("ivps")," are",call.=FALSE)
             if (missing(var.factor))
               stop("mif error: ",sQuote("var.factor")," must be specified",call.=FALSE)
 

Modified: pkg/pomp/man/mif.Rd
===================================================================
--- pkg/pomp/man/mif.Rd	2013-03-10 21:00:05 UTC (rev 833)
+++ pkg/pomp/man/mif.Rd	2013-03-10 22:24:43 UTC (rev 834)
@@ -81,6 +81,7 @@
     The \code{mif} update for initial-value parameters consists of replacing them by their filtering mean at time \code{times[ic.lag]}, where \code{times=time(object)}.
     It makes no sense to set \code{ic.lag>length(times)};
     if it is so set, \code{ic.lag} is set to \code{length(times)} with a warning.
+    For \code{method='mif2'}, the default is \code{ic.lag=length(times)}.
   }
   \item{var.factor}{
     a positive number;

Modified: pkg/pomp/tests/ou2-mif2.R
===================================================================
--- pkg/pomp/tests/ou2-mif2.R	2013-03-10 21:00:05 UTC (rev 833)
+++ pkg/pomp/tests/ou2-mif2.R	2013-03-10 22:24:43 UTC (rev 834)
@@ -76,9 +76,26 @@
              )  
 mif2b <- continue(mif2b,Nmif=50)
 
+mif2c <- mif(ou2,Nmif=50,start=guess1,
+             pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'),
+             rw.sd=c(
+               x1.0=0.5,x2.0=.5,
+               alpha.2=0.1,alpha.3=0.1),
+             transform=F,
+             Np=1000,
+             var.factor=1,
+             cooling.type="hyperbolic",
+             cooling.fraction=0.05,
+             max.fail=100,
+             method="mif2"
+             )  
+mif2c <- continue(mif2c,Nmif=50)
+
 compare.mif(list(mif1b,mif2b))
 
 compare.mif(list(mif1a,mif1b))
 compare.mif(list(mif2a,mif2b))
 
+compare.mif(list(mif1b,mif2c))
+
 dev.off()

Modified: pkg/pomp/tests/ou2-mif2.Rout.save
===================================================================
--- pkg/pomp/tests/ou2-mif2.Rout.save	2013-03-10 21:00:05 UTC (rev 833)
+++ pkg/pomp/tests/ou2-mif2.Rout.save	2013-03-10 22:24:43 UTC (rev 834)
@@ -1,6 +1,6 @@
 
-R version 2.15.2 (2012-10-26) -- "Trick or Treat"
-Copyright (C) 2012 The R Foundation for Statistical Computing
+R version 2.15.3 (2013-03-01) -- "Security Blanket"
+Copyright (C) 2013 The R Foundation for Statistical Computing
 ISBN 3-900051-07-0
 Platform: x86_64-unknown-linux-gnu (64-bit)
 
@@ -102,15 +102,32 @@
 See '?mif' for instructions on specifying the cooling schedule. 
 > mif2b <- continue(mif2b,Nmif=50)
 > 
+> mif2c <- mif(ou2,Nmif=50,start=guess1,
++              pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'),
++              rw.sd=c(
++                x1.0=0.5,x2.0=.5,
++                alpha.2=0.1,alpha.3=0.1),
++              transform=F,
++              Np=1000,
++              var.factor=1,
++              cooling.type="hyperbolic",
++              cooling.fraction=0.05,
++              max.fail=100,
++              method="mif2"
++              )  
+> mif2c <- continue(mif2c,Nmif=50)
+> 
 > compare.mif(list(mif1b,mif2b))
 > 
 > compare.mif(list(mif1a,mif1b))
 > compare.mif(list(mif2a,mif2b))
 > 
+> compare.mif(list(mif1b,mif2c))
+> 
 > dev.off()
 null device 
           1 
 > 
 > proc.time()
    user  system elapsed 
- 42.138   0.064  42.548 
+ 49.343   0.076  49.753 



More information about the pomp-commits mailing list