This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Binomial confidence intervals for proportions | |
#' | |
#' This function uses `binom.test` to derive estimates of the confidence interval | |
#' for proportions. | |
#' | |
#' @param k number of successes | |
#' | |
#' @param n number of trials | |
#' | |
#' @param conf confidence level (1 - alpha), defaults to 0.95 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Source: color palettes come from https://personal.sron.nl/~pault/#sec:qualitative | |
## They exclude 'grey', which will be reserved for missing data. | |
col_vibrant <- c( | |
"#0077BB", | |
"#33BBEE", | |
"#009988", | |
"#EE7733", | |
"#CC3311", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Calculate force of infection | |
#' | |
#' This function calculates the force of infection at time t+1, generated by | |
#' cases with onset at time 1, 2, ..., t, with reproduction numbers R_1, R_2, | |
#' ..., R_t. Calculations use matrices where independent simulations are stored | |
#' as separate columns. | |
#' | |
#' @param w a `numeric` containing numbers representing the PMF of the serial | |
#' interval, starting at day 1, i.e. one day after symptom onset; the vector |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(outbreaks) | |
library(tidyverse) | |
make_linelist <- function(x, date, interval = 1L, date_start = NULL, date_stop = NULL) { | |
## TODO: add tests on inputs | |
x <- tibble::as_tibble(x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Project bed occupancy from admissions | |
#' | |
#' This projects bed occupancy using admission incidence stored as a | |
#' `projections` object, and a distribution of length of stay (los). This is a | |
#' wrapper around `simulate_occupancy`, which essentially applies this function | |
#' to different admission trajectories and collects outputs into a single | |
#' `projections` object. | |
#' | |
#' @param x a `projections` object storing forecast of daily admissions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Simulator for projecting bed occupancy | |
#' | |
#' This function predits bed occupancy from admission data (dates, and numbers | |
#' of admissions on these days). Duration of hospitalisation is provided by a | |
#' function returning `integer` values for the number of days in hospital. | |
#' | |
#' @param dates A vector of dates, ideally as `Date` but `integer` should work too. | |
#' | |
#' @param n_admissions An `integer` vector giving the number of admissions | |
#' predicted for each date in `dates`. |