-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFigure8.Rmd
More file actions
101 lines (79 loc) · 2.06 KB
/
Figure8.Rmd
File metadata and controls
101 lines (79 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
---
title: "Figure 8"
subtitle: "A Probabilistic Synthesis of Malaria Epidemiology: Exposure, Infection, Parasite Densities, and Detection"
date: "`r format(Sys.time(), '%B %d, %Y')`"
author: John M. Henry, Austin R. Carter, Sean L. Wu, and David L. Smith
output:
html_document
---
***
[Home](Memory.html) |
[Fig 4](Figure4.html) |
[Fig 5](Figure5.html) |
[Fig 6](Figure6.html) |
[Fig 7](Figure7.html) |
[Fig 8](Figure8.html) |
[Fig 9](Figure9.html) |
[Fig 10](Figure10.html)
***
# {.tabset}
## $\odot$

## Setup
```{r}
library(ramp.falciparum)
library(viridisLite)
library(knitr)
```
```{r}
foiP3 = list(hbar = 1,
agePar = par_type2Age(),
seasonPar = par_sinSeason(),
trendPar = par_flatTrend())
```
## Figure 8
```{r}
aa = seq(5, 5*365, by = 5)
```
This runs the code and saves it into a file.
```{r, eval=F}
meanP = sapply(aa, moments_clone_density, FoIpar=foiP3, hhat=5/365)
meanB = sapply(aa, moments_parasite_density, FoIpar=foiP3, hhat=5/365)
write.table(data.frame(P=meanP, B=meanB), "PB.txt")
```
To save time, we simply read it in.
```{r}
PB = read.table("PB.txt")
meanP = PB$P
meanB = PB$B
PB1 = read.table("PB1.txt")
meanP1 = PB1$P
meanB1 = PB1$B
PB2 = read.table("PB2.txt")
meanP2 = PB2$P
meanB2 = PB2$B
```
```{r}
pFmu = par_Fmu_base()
solve_dAoYda(5/365, foiP3, Amax=5*365, dt=5) -> hybrid
tm = hybrid$time
approxP = Fmu(hybrid$x, 0, pFmu)
approxB = Fmu(hybrid$y, 0, pFmu)
plot(aa, meanB, type = "l", ylim = c(0, 13), col = "darkred",
xlab = "a - Cohort Age",
ylab = expression(list(xi, paste(log[10], " Parasite Densities"))))
#lines(tm, approxB, col = "salmon3", lwd=2)
lines(aa, meanP, type = "l", ylim = c(0, 13), col = "darkblue")
lines(tm, approxP, col = "cyan4")
mtext("Expected Densities Exactly vs. Hybrid Model Predictions", 3, 1, at=365)
```
## Remake
```{r purl Figure 8, eval=F}
print("Making Figure 8")
purl("Figure8.Rmd", "Figure8.R")
```
```{r source Figure 8, eval=F}
png("Figure8.png", height=360, width=540)
source("Figure8.R")
invisible(dev.off(dev.cur()))
```