[Pomp-commits] r1217 - in www: content vignettes

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Jun 18 11:28:45 CEST 2015


Author: kingaa
Date: 2015-06-18 11:28:44 +0200 (Thu, 18 Jun 2015)
New Revision: 1217

Added:
   www/vignettes/bbp.Rmd
   www/vignettes/bbp.html
Modified:
   www/content/NEWS.html
   www/vignettes/getting_started.R
   www/vignettes/getting_started.Rmd
   www/vignettes/getting_started.html
   www/vignettes/pomp.pdf
Log:
- update

Modified: www/content/NEWS.html
===================================================================
--- www/content/NEWS.html	2015-06-17 23:26:32 UTC (rev 1216)
+++ www/content/NEWS.html	2015-06-18 09:28:44 UTC (rev 1217)
@@ -7,12 +7,12 @@
 
 <h2>News for package ‘pomp’</h2>
 
-<h3>Changes in <span class="pkg">pomp</span> version 0.68-1</h3>
+<h3>Changes in <span class="pkg">pomp</span> version 0.68-2</h3>
 
 
 <ul>
 <li><p> When using <code>Csnippet</code>s, by default, the C codes and shared-object files are stored in the R session's temporary directory.
-One can override this behavior by setting the global <code>pomp.file.dir</code> option.
+One can override this behavior by setting the global <code>pomp.cache</code> option.
 </p>
 </li></ul>
 

Added: www/vignettes/bbp.Rmd
===================================================================
--- www/vignettes/bbp.Rmd	                        (rev 0)
+++ www/vignettes/bbp.Rmd	2015-06-18 09:28:44 UTC (rev 1217)
@@ -0,0 +1,91 @@
+%\VignetteIndexEntry{Bombay plague example}
+%\VignetteEngine{knitr::knitr}
+
+# Analysis of a Bombay plague outbreak  
+***Aaron A. King***
+
+```{r setup,include=FALSE}
+require(pomp)
+require(plyr)
+require(reshape2)
+options(stringsAsFactors=FALSE,keep.source=TRUE,encoding="UTF-8")
+
+require(ggplot2)
+theme_set(theme_bw())
+
+require(knitr)
+opts_knit$set(out.format="html")
+opts_chunk$set(
+  progress=TRUE,
+  prompt=FALSE,tidy=FALSE,highlight=TRUE,
+  strip.white=TRUE,
+  warning=FALSE,message=FALSE,error=FALSE,
+  echo=TRUE,cache=FALSE,
+  results='markup',
+  fig.show='asis',
+  fig.height=5,fig.width=10,
+  dpi=100
+  )
+
+require(pompExamples)
+set.seed(864919428L)
+```
+
+First, a little function to cache the results of expensive computations.
+
+```{r bake}
+bake <- function (file, expr) {
+  if (file.exists(file)) {
+    readRDS(file)
+    } else {
+      val <- eval(expr)
+      saveRDS(val,file=file)
+      val
+      }
+  }
+```
+
+## Plague in Bombay
+
+Let's look at an historical outbreak of plague in Bombay in 1905--1906 [@Kermack1927].
+Download and plot the data by doing
+
+```{r bombay-plague}
+require(plyr)
+require(reshape2)
+require(ggplot2)
+options(stringsAsFactors=FALSE)
+pompExample(bbp)
+ggplot(data=as.data.frame(bbp),mapping=aes(x=time,y=deaths))+
+  geom_line()+geom_point(size=2)+
+#   scale_x_date()+
+  labs(y="plague deaths",title="plague outbreak on the island of Bombay")
+```
+
+These human deaths were the visible effect of an outbreak of plague in the rat population.
+We'll model this outbreak in the rats using a simple compartmental model and assume that human mortality is proportional to the fraction of the rat population that's infected.
+Because the disease has a high mortality rate, we will not be able to make the assumption we made before of constant population size.
+Let's let $S$, $I$, and $R$ refer to the number of rats susceptible to infection, infected and infectious, and recovered.
+Then these *state variables* change according to the system of differential equations:
+$$\frac{dS}{dt} = \mu\,N-\frac{\beta\,S\,I}{N}-\mu\,S$$
+$$\frac{dI}{dt} = \frac{\beta\,S\,I}{N}-\gamma\,I-\delta\,I-\mu\,I$$
+$$\frac{dR}{dt} = \gamma\,I-\mu\,R$$
+In these equations, $\beta$ is the transmission rate; $\gamma$, the recovery rate; and $\delta$, the disease-induced mortality rate.
+$N$ is the total population size ($N=S+I+R$), so that the risk of infection a susceptible faces is proportional to the \emph{prevalence} (the fraction of the population that is infected).
+This assumption is based, in turn, upon the assumption that the population of fleas is sufficiently large, and flea-bites sufficiently numerous and random, that transmission between rates is effectively direct.
+Finally, we've assumed in the above that the per capita birth rate, $\mu$, is equal to the natural mortality rate, and that neither of these things changes appreciably over the course of the outbreak.
+
+A little bit of thought allows us to simplify these equations considerably.
+First, we note that $R$, the number of recovered rats, is of no interest to us, since these rats do not affect human mortality and have no effect on the infection process (i.e., they are absent from the first two of \cref{eq:rat-model1})
+number of variables in these equations by letting $S=X\,N$ and $I=Y\,N$; $X$ and $Y$ are, respectively the fractions of rats susceptible to, and infected by the plague bacterium, *Yersinia pestis*.
+These substitutions transform \cref{eq:rat-model1} into
+$$\frac{dX}{dt} = \mu\,(1-X)-(\beta-\delta)\,X\,Y$$
+$$\frac{dY}{dt} = \beta\,X\,Y+\delta\,Y^2-(\delta+\gamma+\mu)\,Y$$
+$$\frac{dN}{dt} = -\delta\,Y\,N$$
+These equations can be integrated using `deSolve`, but numerical problems arise when the values of $X$ or $Y$ get too close to $0$.
+We can avoid these problems by log-transforming the variables, letting $x=\log{X}$, $y=\log{Y}$, and $n=\log{N}$.
+Then we have the equivalent DE
+$$\frac{dx}{dt} = \mu\,(e^{-x}-1)-(\beta-\delta)\,e^y$$
+$$\frac{dy}{dt} = \beta\,e^x+\delta\,e^y-(\delta+\gamma+\mu)$$
+$$\frac{dn}{dt} = -\delta\,e^y$$
+

Added: www/vignettes/bbp.html
===================================================================
--- www/vignettes/bbp.html	                        (rev 0)
+++ www/vignettes/bbp.html	2015-06-18 09:28:44 UTC (rev 1217)
@@ -0,0 +1,121 @@
+<!DOCTYPE html>
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+<head>
+
+<meta charset="utf-8">
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta name="generator" content="pandoc" />
+
+<meta name="author" content />
+
+
+<title></title>
+
[TRUNCATED]

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


More information about the pomp-commits mailing list