--- title: "sirPLUS models" date: "Last updated: 23 March 2020" output: BiocStyle::html_document: toc: true toc_float: true vignette: > %\VignetteIndexEntry{sirPLUS models} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) ``` ## Backgrouund on the SEIQHRF (SIR + extra compartments) model Testing implementation of SEIQHRF (see [Tim Churches"'" blog post](https://timchurches.github.io/blog/posts/2020-03-18-modelling-the-effects-of-public-health-interventions-on-covid-19-transmission-part-2/) in an R package. | Compartment | Functional definition | |-------------|-----------------------------------------------------------------------------------| | S | Susceptible individuals | | E | Exposed **and** infected, not yet symptomatic but potentially infectious | | I | Infected, symptomatic **and** infectious | | Q | Infectious, but (self-)isolated | | H | Requiring hospitalisation (would normally be hospitalised if capacity available) | | R | Recovered, immune from further infection | | F | Case fatality (death due to COVID-19, not other causes) | ```{r Load package} library(earlyR, lib.loc = '/mnt/mcfiles/rlyu/Software/R/3.6/Rlib') library(epitrix, lib.loc = '/mnt/mcfiles/rlyu/Software/R/3.6/Rlib') devtools::load_all(".") ``` ## Simulate baseline model ```{r simulate baselines} control <- set.control() param <- set.param() init <- set.init(s.num = 10000, i.num = 10, q.num = 9, h.num = 1) baseline_sim <- simulate(param, init, control) ``` ## Inspect baseline simulations ```{r baseline sims} times <- get_times(baseline_sim) times %>% filter(duration <= 30) %>% ggplot(aes(x = duration)) + geom_bar() + facet_grid(period_type ~ ., scales = "free_y") + labs(title = "Duration frequency distributions", subtitle = "Baseline simulation") ``` ```{r viz prevalence} baseline_plot_df <- baseline_sim$df %>% # use only the prevalence columns select(time, s.num, e.num, i.num, q.num, h.num, r.num, f.num) %>% # examine only the first 100 days since it is all over by # then using the default parameters filter(time <= 100) %>% pivot_longer(-c(time), names_to = "compartment", values_to = "count") # define a standard set of colours to represent compartments compcols <- c(s.num = "yellow", e.num = "orange", i.num = "red", q.num = "cyan", h.num = "magenta", r.num = "lightgreen", f.num = "black") complabels <- c(s.num = "Susceptible", e.num = "Infected/asymptomatic", i.num = "Infected/infectious", q.num = "Self-isolated", h.num = "Requires hospitalisation", r.num = "Recovered", f.num = "Case fatality") baseline_plot_df %>% ggplot(aes(x = time, y = count, colour = compartment)) + geom_line(size = 2, alpha = 0.7) + scale_colour_manual(values = compcols, labels = complabels) + theme_dark() + labs(title = "Baseline simulation", x = "Days since beginning of epidemic", y = "Prevalence (persons)") ``` ## Experiment 1