-
Notifications
You must be signed in to change notification settings - Fork 6
/
02_EpiLPS_infections.R
45 lines (36 loc) · 1.11 KB
/
02_EpiLPS_infections.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
library(EpiLPS)
url <- "https://raw.githubusercontent.com/cmilando/RtEval/main/all_data.RDS"
all_data <- readRDS(url(url))
case_choice <- "daily_infections"
# discrete dist
si_spec <- Idist(probs = all_data$serial$Px)
# incidence
incidence = all_data$cases$daily_infections
#
LPSfit <- estimR(incidence = incidence, si = si_spec$pvec)
#
plot_data <- data.frame(
package = "EpiLPS",
date = all_data$cases$day,
Rt_median = LPSfit$RLPS$Rq0.50,
Rt_lb = LPSfit$RLPS$Rq0.025,
Rt_ub = LPSfit$RLPS$Rq0.975
)
library(tidyverse)
as_tibble(plot_data) %>%
ggplot() +
geom_hline(yintercept = 1, linetype = "11") +
# *******
# this is the true r(t), back-calculated
geom_line(aes(x = Day, y = Rt_calc), data = all_data$rt) +
# *******
geom_ribbon(aes(x = date, ymin = Rt_lb, ymax = Rt_ub, fill = package), alpha = 0.25) +
geom_line(aes(x = date, y = Rt_median, color = package)) +
coord_cartesian(ylim = c(0, 5)) +
xlab("Days") +
ylab("Rt") +
theme(
axis.text = element_text(size = 10),
axis.title = element_text(size = 14)
)
saveRDS(plot_data, "plot_objects/plot_data_EpiLPS_infections.RDS")