[Pomp-commits] r1179 - pkg/pomp pkg/pomp/R pkg/pomp/tests www/vignettes

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Jun 4 21:39:18 CEST 2015


Author: kingaa
Date: 2015-06-04 21:39:17 +0200 (Thu, 04 Jun 2015)
New Revision: 1179

Modified:
   pkg/pomp/DESCRIPTION
   pkg/pomp/R/mif2.R
   pkg/pomp/tests/ou2-mif2.R
   pkg/pomp/tests/ou2-mif2.Rout.save
   www/vignettes/mif2.R
   www/vignettes/mif2.Rmd
   www/vignettes/mif2.html
   www/vignettes/pomp.pdf
Log:
- fix bug in 'rw.sd'
- update 'mif2' vignette

Modified: pkg/pomp/DESCRIPTION
===================================================================
--- pkg/pomp/DESCRIPTION	2015-06-04 18:07:50 UTC (rev 1178)
+++ pkg/pomp/DESCRIPTION	2015-06-04 19:39:17 UTC (rev 1179)
@@ -1,7 +1,7 @@
 Package: pomp
 Type: Package
 Title: Statistical Inference for Partially Observed Markov Processes
-Version: 0.66-2
+Version: 0.66-3
 Date: 2015-06-04
 Authors at R: c(person(given=c("Aaron","A."),family="King",
 		role=c("aut","cre"),email="kingaa at umich.edu"),

Modified: pkg/pomp/R/mif2.R
===================================================================
--- pkg/pomp/R/mif2.R	2015-06-04 18:07:50 UTC (rev 1178)
+++ pkg/pomp/R/mif2.R	2015-06-04 19:39:17 UTC (rev 1179)
@@ -18,10 +18,13 @@
   sds <- lapply(rw.sd,eval,envir=list(time=time,ivp=ivp))
   for (n in names(sds)) {
     len <- length(sds[[n]])
-    if (len!=1 && len!=length(time))
+    if (len==1) {
+      sds[[n]] <- rep(sds[[n]],length(time))
+    } else if (len!=length(time)) {
       stop(sQuote("mif2")," error: ",sQuote("rw.sd")," spec for parameter ",
            sQuote(n)," does not evaluate to a vector of the correct length (",
            length(time),")",call.=FALSE)
+    }
   }
   do.call(rbind,sds)
 }

Modified: pkg/pomp/tests/ou2-mif2.R
===================================================================
--- pkg/pomp/tests/ou2-mif2.R	2015-06-04 18:07:50 UTC (rev 1178)
+++ pkg/pomp/tests/ou2-mif2.R	2015-06-04 19:39:17 UTC (rev 1179)
@@ -107,17 +107,17 @@
 guess1[c('x1.0','x2.0','alpha.2','alpha.3')] <- 0.5*guess1[c('x1.0','x2.0','alpha.2','alpha.3')]
 guess2[c('x1.0','x2.0','alpha.2','alpha.3')] <- 1.5*guess1[c('x1.0','x2.0','alpha.2','alpha.3')]
 
-m1 <- pomp:::mif2(ou2,Nmif=100,start=guess1,Np=1000,
-                  cooling.type="hyperbolic",cooling.fraction.50=0.05,
-                  rw.sd=pomp:::rw.sd(
-                    x1.0=ivp(0.5),x2.0=ivp(0.5),
-                    alpha.2=0.1,alpha.3=0.1))
+m1 <- mif2(ou2,Nmif=100,start=guess1,Np=1000,
+           cooling.type="hyperbolic",cooling.fraction.50=0.05,
+           rw.sd=rw.sd(
+             x1.0=ivp(0.5),x2.0=ivp(0.5),
+             alpha.2=0.1,alpha.3=0.1))
 
-m2 <- pomp:::mif2(ou2,Nmif=100,start=guess2,Np=1000,
-                  cooling.type="hyperbolic",cooling.fraction.50=0.05,
-                  rw.sd=pomp:::rw.sd(
-                    x1.0=ivp(0.5),x2.0=ivp(0.5),
-                    alpha.2=0.1,alpha.3=0.1))
+m2 <- mif2(ou2,Nmif=100,start=guess2,Np=1000,
+           cooling.type="hyperbolic",cooling.fraction.50=0.05,
+           rw.sd=rw.sd(
+             x1.0=ivp(0.5),x2.0=ivp(0.5),
+             alpha.2=0.1,alpha.3=0.1))
 
 plot(c(m1,m2))
 
@@ -125,4 +125,12 @@
       mle2=c(coef(m2),loglik=logLik(pfilter(m1,Np=1000))),
       truth=c(coef(ou2),loglik=logLik(pfilter(m1,Np=1000))))
 
+m3 <- mif2(ou2,Nmif=3,start=guess1,Np=200,
+           cooling.fraction=0.2,
+           rw.sd=rw.sd(
+             x1.0=c(0.5,rep(0.2,99)),
+             x2.0=ivp(0.5),
+             alpha.2=if (time==1) 0.2 else 0.1,
+             alpha.3=0.2*(time<10)))
+
 dev.off()

Modified: pkg/pomp/tests/ou2-mif2.Rout.save
===================================================================
--- pkg/pomp/tests/ou2-mif2.Rout.save	2015-06-04 18:07:50 UTC (rev 1178)
+++ pkg/pomp/tests/ou2-mif2.Rout.save	2015-06-04 19:39:17 UTC (rev 1179)
@@ -138,17 +138,17 @@
 > guess1[c('x1.0','x2.0','alpha.2','alpha.3')] <- 0.5*guess1[c('x1.0','x2.0','alpha.2','alpha.3')]
 > guess2[c('x1.0','x2.0','alpha.2','alpha.3')] <- 1.5*guess1[c('x1.0','x2.0','alpha.2','alpha.3')]
 > 
-> m1 <- pomp:::mif2(ou2,Nmif=100,start=guess1,Np=1000,
-+                   cooling.type="hyperbolic",cooling.fraction.50=0.05,
-+                   rw.sd=pomp:::rw.sd(
-+                     x1.0=ivp(0.5),x2.0=ivp(0.5),
-+                     alpha.2=0.1,alpha.3=0.1))
+> m1 <- mif2(ou2,Nmif=100,start=guess1,Np=1000,
++            cooling.type="hyperbolic",cooling.fraction.50=0.05,
++            rw.sd=rw.sd(
++              x1.0=ivp(0.5),x2.0=ivp(0.5),
++              alpha.2=0.1,alpha.3=0.1))
 > 
-> m2 <- pomp:::mif2(ou2,Nmif=100,start=guess2,Np=1000,
-+                   cooling.type="hyperbolic",cooling.fraction.50=0.05,
-+                   rw.sd=pomp:::rw.sd(
-+                     x1.0=ivp(0.5),x2.0=ivp(0.5),
-+                     alpha.2=0.1,alpha.3=0.1))
+> m2 <- mif2(ou2,Nmif=100,start=guess2,Np=1000,
++            cooling.type="hyperbolic",cooling.fraction.50=0.05,
++            rw.sd=rw.sd(
++              x1.0=ivp(0.5),x2.0=ivp(0.5),
++              alpha.2=0.1,alpha.3=0.1))
 > 
 > plot(c(m1,m2))
 > 
@@ -164,10 +164,21 @@
 mle2  -2.696841 3.157511 -482.3154
 truth -3.000000 4.000000 -481.9939
 > 
+> m3 <- mif2(ou2,Nmif=3,start=guess1,Np=200,
++            cooling.fraction=0.2,
++            rw.sd=rw.sd(
++              x1.0=c(0.5,rep(0.2,99)),
++              x2.0=ivp(0.5),
++              alpha.2=if (time==1) 0.2 else 0.1,
++              alpha.3=0.2*(time<10)))
+Warning message:
+In if (time == 1) 0.2 else 0.1 :
+  the condition has length > 1 and only the first element will be used
+> 
 > dev.off()
 null device 
           1 
 > 
 > proc.time()
    user  system elapsed 
- 70.828   0.064  71.333 
+ 69.328   0.052  69.748 

Modified: www/vignettes/mif2.R
===================================================================
--- www/vignettes/mif2.R	2015-06-04 18:07:50 UTC (rev 1178)
+++ www/vignettes/mif2.R	2015-06-04 19:39:17 UTC (rev 1179)
@@ -5,7 +5,7 @@
 require(magrittr)
 theme_set(theme_bw())
 require(pomp)
-stopifnot(packageVersion("pomp")>="0.63-1")
+stopifnot(packageVersion("pomp")>="0.66-2")
 options(
   keep.source=TRUE,
   stringsAsFactors=FALSE,
@@ -40,17 +40,14 @@
       meanlog=log(theta.guess[estpars]),
       sdlog=1
       )
-    m1 <- mif(
+    m1 <- mif2(
       gompertz,
       Nmif=50,
-      method="mif2",
       start=theta.guess,
       transform=TRUE,
-      rw.sd=c(r=0.02,sigma=0.02,tau=0.05),
-      Np=2000,
-      var.factor=2,
-      cooling.type="hyperbolic",
-      cooling.fraction=0.95
+      rw.sd=rw.sd(r=0.02,sigma=0.02,tau=0.05),
+      cooling.fraction.50=0.95,
+      Np=2000
       )
     m1 <- continue(m1,Nmif=50,cooling.fraction=0.8)
     m1 <- continue(m1,Nmif=50,cooling.fraction=0.6)

Modified: www/vignettes/mif2.Rmd
===================================================================
--- www/vignettes/mif2.Rmd	2015-06-04 18:07:50 UTC (rev 1178)
+++ www/vignettes/mif2.Rmd	2015-06-04 19:39:17 UTC (rev 1179)
@@ -48,7 +48,7 @@
 require(magrittr)
 theme_set(theme_bw())
 require(pomp)
-stopifnot(packageVersion("pomp")>="0.65-1")
+stopifnot(packageVersion("pomp")>="0.66-2")
 options(
   keep.source=TRUE,
   stringsAsFactors=FALSE,
@@ -60,12 +60,12 @@
 
 Iterated filtering is a technique for maximizing the likelihood obtained by filtering.
 In `pomp`, it is the particle filter that is iterated.
-Iterated filtering is implemented in the `mif` function.
+The iterated filtering of @Ionides2006 is implemented in the `mif` function.
 @Ionides2015 describe an improvement on the original [@Ionides2006] algorithm.
-This "IF2" algorithm is currently implemented by setting the `method="mif2"` option in `mif`.
+This "IF2" algorithm is implemented in the `mif2` function.
 
-Let's use IF2 to obtain an approximate MLE for the data in the Gompertz model example provided with `pomp`.
-We'll initialize the algorithm at several starting points around `theta.true` and just estimate the parameters $r$, $\tau$, and $\sigma$:
+The following constructs the Gompertz example that is provided with `pomp` (see `?gompertz`) and extracts the parameters at which the data were generated.
+
 ```{r gompertz-init,cache=FALSE}
 require(pomp)
 pompExample(gompertz)
@@ -73,8 +73,8 @@
 theta.true <- theta
 ```
 
-Note that we've set `transform=TRUE` in the above.
-This means that the likelihood maximization is done on the estimation scale (see the section above on Parameter Transformations).
+Let's use IF2 to obtain an approximate MLE for these data.
+We'll initialize the algorithm at several starting points around `theta.true` and just estimate the parameters $r$, $\tau$, and $\sigma$:
 
 ```{r gompertz-multi-mif2-eval,results='hide'}
 require(foreach)
@@ -96,17 +96,14 @@
       meanlog=log(theta.guess[estpars]),
       sdlog=1
       )
-    m1 <- mif(
+    m1 <- mif2(
       gompertz,
       Nmif=50,
-      method="mif2",
       start=theta.guess,
       transform=TRUE,
-      rw.sd=c(r=0.02,sigma=0.02,tau=0.05),
-      Np=2000,
-      var.factor=2,
-      cooling.type="hyperbolic",
-      cooling.fraction=0.95
+      rw.sd=rw.sd(r=0.02,sigma=0.02,tau=0.05),
+      cooling.fraction.50=0.95,
+      Np=2000
       )
     m1 <- continue(m1,Nmif=50,cooling.fraction=0.8)
     m1 <- continue(m1,Nmif=50,cooling.fraction=0.6)
@@ -115,6 +112,15 @@
     list(mif=m1,ll=ll)
     }
 ```
+
+Note that we've set `transform=TRUE` in the above to search for the MLE with the parameters transformed to enforce their positivity.
+See the `pomp` documentation (`?pomp`) and the section on Parameter Transformations in the [Getting Started vignette](http://pomp.r-forge.r-project.org/vignettes/getting_started.html)).
+
+Each of the `r length(mf)` `mif2` runs ends up at a different point estimate.
+We focus on that with the highest estimated likelihood, having evaluated the likelihood several times to reduce the Monte Carlo error in the likelihood evaluation.
+The particle filter produces an unbiased estimate of the likelihood; 
+therefore, we will average the likelihoods, not the log likelihoods.
+
 ```{r gompertz-post-mif2}
 loglik.true <- replicate(n=10,logLik(pfilter(gompertz,Np=10000)))
 loglik.true <- logmeanexp(loglik.true,se=TRUE)
@@ -129,15 +135,8 @@
   ) -> results.table
 ```
 
-Each of the `r length(mf)` `mif` runs ends up at a different place.
-In this case (but by no means in every case), we can average across these parameter estimates to get an approximate maximum likelihood estimate.
-We'll evaluate the likelihood several times at this estimate to get an idea of the Monte Carlo error in our likelihood estimate.
-The particle filter produces an unbiased estimate of the likelihood;
-therefore, we'll average the likelihoods, not the log likelihoods.
-
-
 Convergence plots can be used to help diagnose convergence of the iterated filtering algorithm.
-The following shows part of the output of `plot(mf)`.
+Something like the following can be obtained by executing `plot(mf)`.
 
 ```{r mif2-plot,echo=FALSE,cache=FALSE,fig.height=6}
 op <- par(mfrow=c(4,1),mar=c(3,3,0,0),mgp=c(2,1,0),bty='l')
@@ -156,5 +155,6 @@
 ```{r first-mif-results-table,echo=FALSE,cache=FALSE}
 print(results.table)
 ```
+The fact that the likelihood at the putative MLE is higher than it is at the truth is evidence that this parameter is actually close to the true MLE.
 
 ## References

Modified: www/vignettes/mif2.html
===================================================================
--- www/vignettes/mif2.html	2015-06-04 18:07:50 UTC (rev 1178)
+++ www/vignettes/mif2.html	2015-06-04 19:39:17 UTC (rev 1179)
@@ -67,16 +67,16 @@
 
 
 <p>Licensed under the <a href="http://creativecommons.org/licenses/by-nc/3.0">Creative Commons attribution-noncommercial license</a>. Please share and remix noncommercially, mentioning its origin.<br /><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFgAAAAfCAYAAABjyArgAAAACXBIWXMAAAsTAAALEwEAm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ozGvyvTh5M/JHYrPZyh4xm81GBn47QBL34uR2YoK88bs3Vq0FhJAlz433KsVfDrfSZzClwirfUS8OHDxAdyGk6AiuXrm65Lb9HmEPnM5Gutd25cpVnA2eXf0iUUSD10JzF2KUOq5GmKXi1q3bGtAVOIWazTbDboQx3QiT36r/48n01BR+3RvG6Mjo2qzCC6bsWpmG5UzCUs9dE4J12dW4C03NTdj2zDZ83Wo153A11+rTbBZ3bt/BjWs31ozYL1qD18MGl0XwY1mFiSCEPMEwzGePqViHAIMQ5n8DAFb/49reYmyHAAAAAElFTkSuQmCC" alt="CC-BY_NC" /></p>
-<p>This document was produced using <code>pomp</code> version 0.65.1.</p>
-<p>Iterated filtering is a technique for maximizing the likelihood obtained by filtering. In <code>pomp</code>, it is the particle filter that is iterated. Iterated filtering is implemented in the <code>mif</code> function. <span class="citation">Ionides et al. (2015)</span> describe an improvement on the original <span class="citation">(Ionides et al. 2006)</span> algorithm. This “IF2” algorithm is currently implemented by setting the <code>method="mif2"</code> option in <code>mif</code>.</p>
-<p>Let’s use IF2 to obtain an approximate MLE for the data in the Gompertz model example provided with <code>pomp</code>. We’ll initialize the algorithm at several starting points around <code>theta.true</code> and just estimate the parameters <span class="math">\(r\)</span>, <span class="math">\(\tau\)</span>, and <span class="math">\(\sigma\)</span>:</p>
+<p>This document was produced using <code>pomp</code> version 0.66.3.</p>
+<p>Iterated filtering is a technique for maximizing the likelihood obtained by filtering. In <code>pomp</code>, it is the particle filter that is iterated. The iterated filtering of <span class="citation">Ionides et al. (2006)</span> is implemented in the <code>mif</code> function. <span class="citation">Ionides et al. (2015)</span> describe an improvement on the original <span class="citation">(Ionides et al. 2006)</span> algorithm. This “IF2” algorithm is implemented in the <code>mif2</code> function.</p>
+<p>The following constructs the Gompertz example that is provided with <code>pomp</code> (see <code>?gompertz</code>) and extracts the parameters at which the data were generated.</p>
 <pre class="r"><code>require(pomp)
 pompExample(gompertz)</code></pre>
 <pre><code>## newly created object(s):
 ##  gompertz</code></pre>
 <pre class="r"><code>theta <- coef(gompertz)
 theta.true <- theta</code></pre>
-<p>Note that we’ve set <code>transform=TRUE</code> in the above. This means that the likelihood maximization is done on the estimation scale (see the section above on Parameter Transformations).</p>
+<p>Let’s use IF2 to obtain an approximate MLE for these data. We’ll initialize the algorithm at several starting points around <code>theta.true</code> and just estimate the parameters <span class="math">\(r\)</span>, <span class="math">\(\tau\)</span>, and <span class="math">\(\sigma\)</span>:</p>
 <pre class="r"><code>require(foreach)
 require(doMC)
 registerDoMC()
@@ -96,17 +96,14 @@
       meanlog=log(theta.guess[estpars]),
       sdlog=1
       )
-    m1 <- mif(
+    m1 <- mif2(
       gompertz,
       Nmif=50,
-      method="mif2",
       start=theta.guess,
       transform=TRUE,
-      rw.sd=c(r=0.02,sigma=0.02,tau=0.05),
-      Np=2000,
-      var.factor=2,
-      cooling.type="hyperbolic",
-      cooling.fraction=0.95
+      rw.sd=rw.sd(r=0.02,sigma=0.02,tau=0.05),
+      cooling.fraction.50=0.95,
+      Np=2000
       )
     m1 <- continue(m1,Nmif=50,cooling.fraction=0.8)
     m1 <- continue(m1,Nmif=50,cooling.fraction=0.6)
@@ -114,6 +111,8 @@
     ll <- replicate(n=10,logLik(pfilter(m1,Np=10000)))
     list(mif=m1,ll=ll)
     }</code></pre>
+<p>Note that we’ve set <code>transform=TRUE</code> in the above to search for the MLE with the parameters transformed to enforce their positivity. See the <code>pomp</code> documentation (<code>?pomp</code>) and the section on Parameter Transformations in the <a href="http://pomp.r-forge.r-project.org/vignettes/getting_started.html">Getting Started vignette</a>).</p>
+<p>Each of the 10 <code>mif2</code> runs ends up at a different point estimate. We focus on that with the highest estimated likelihood, having evaluated the likelihood several times to reduce the Monte Carlo error in the likelihood evaluation. The particle filter produces an unbiased estimate of the likelihood; therefore, we will average the likelihoods, not the log likelihoods.</p>
 <pre class="r"><code>loglik.true <- replicate(n=10,logLik(pfilter(gompertz,Np=10000)))
 loglik.true <- logmeanexp(loglik.true,se=TRUE)
 theta.mif <- t(sapply(mf,function(x)coef(x$mif)))
@@ -125,13 +124,13 @@
   mle=c(signif(theta.mif[estpars],3),loglik=round(loglik.mif,2)),
   truth=c(signif(theta.true[estpars],3),loglik=round(loglik.true,2))
   ) -> results.table</code></pre>
-<p>Each of the 10 <code>mif</code> runs ends up at a different place. In this case (but by no means in every case), we can average across these parameter estimates to get an approximate maximum likelihood estimate. We’ll evaluate the likelihood several times at this estimate to get an idea of the Monte Carlo error in our likelihood estimate. The particle filter produces an unbiased estimate of the likelihood; therefore, we’ll average the likelihoods, not the log likelihoods.</p>
-<p>Convergence plots can be used to help diagnose convergence of the iterated filtering algorithm. The following shows part of the output of <code>plot(mf)</code>.</p>
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/pomp -r 1179


More information about the pomp-commits mailing list