This repository has been archived by the owner on Jul 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
8b_plot_pmf_s.R
52 lines (46 loc) · 1.47 KB
/
8b_plot_pmf_s.R
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
## plot: serial interval distribution ##########################################
# plot name
file_plot <- paste0("figure/8b_pmf_s",
"_N", N,
"_f", flat_TRUE,
"_e", epsilonH_TRUE,
"_d", delta_TRUE,
"_R", distr_r,
"_S", distr_s)
# save as eps
setEPS()
print( name_file <- paste0(file_plot, ".eps") )
postscript(name_file, width = 11, height = 8.5)
source("3b_pmf_s.R") # serial interval distribution
# # observed data
# plot(prop.table(table(tauiSS)),
# xlim = c(0, max(tauiSS)),
# xlab = "Days",
# ylab = "Probability",
# col = "black", lwd = 10)
# preallocate
pmf_temp = matrix(rep(NA, nrow(samples)*(max(tauiSS, 22)+1)), ncol = max(tauiSS, 22)+1)
colnames(pmf_temp) = 0:max(tauiSS, 22)
# calculation
for (n in 1:nrow(samples)) { # all samples
thetaSS = c(samples$thetaSS1[n], samples$thetaSS2[n])
pmf_temp[n, ] = pmf_s(tau = 0:max(tauiSS, 22), thetaSS)
}
# estimated pmf
boxplot(pmf_temp,
# col = rgb(1, 1, 1, alpha = 0),
# border = "red",
# outcol = "darkgray",
outline = F,
lwd = 2,
cex = 0.5,
cex.axis = 1.5,
cex.lab = 2,
xlab = "",
ylab = "",
xlim = c(0, max(tauiSS, 22)),
at = 0:max(tauiSS, 22))
title(xlab = "Serial interval", line = 2.5, cex.lab = 2)
title(ylab = "Probability", line = 2.5, cex.lab = 2)
# save as eps
dev.off()