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
# load required packages | |
library(EpiNow2) | |
library(future.apply) | |
library(purrr) | |
library(data.table) | |
warning("This gist is depreciated. Please use the following development repository: https://github.com/seabbs/regional-secondary.git") | |
# extract priors from a posterior and update fitting args | |
extract_secondary_priors <- function(posterior) { |
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
# set number of cores to use fitting the model | |
# no benefit on runtime if cores > chains which is set to 4 by default | |
options(mc.cores = 4) | |
# Packages ---------------------------------------------------------------- | |
# install.packages(c("data.table", "remotes", "ggplot2")) | |
# remotes::install_github("epiforecasts/EpiNow2") | |
# remotes::install_github("epiforecasts/covidregionaldata") | |
library(data.table) | |
library(ggplot2) |
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
# Load packages | |
library(epinowcast) | |
library(data.table) | |
library(ggplot2) | |
# Load and filter germany hospitalisations | |
nat_germany_hosp <- germany_covid19_hosp[location == "DE"][age_group %in% "00+"] | |
nat_germany_hosp <- enw_filter_report_dates( | |
nat_germany_hosp, | |
latest_date = "2021-10-01" |
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
# If we receive X-Forwarded-Proto, pass it through; otherwise, pass along the | |
# scheme used to connect to this server | |
map $http_x_forwarded_proto $proxy_x_forwarded_proto { | |
default $http_x_forwarded_proto; | |
'' $scheme; | |
} | |
# If we receive X-Forwarded-Port, pass it through; otherwise, pass along the | |
# server port the client connected to | |
map $http_x_forwarded_port $proxy_x_forwarded_port { | |
default $http_x_forwarded_port; |
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
#' Disease Model, with Vaccination, Data Based Population Demographics and Ageing as a Pomp Object | |
#' | |
#' @param df A data frame of data to be passed to the pomp model. | |
#' @param t0 An integer value denoting the starting time for the model, this may be negative. | |
#' @param nstageA The number of age compartments to model. | |
#' @param timestep Value indicating the timestep over which to solve the model. | |
#' @param time The variable to use the time parameter from the data. | |
#' @param covars Additional data to use within the model. | |
#' @param tcovar A character string indicating the time variable in covar. | |
#' @param obsnames A character string of the observable variables. |
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
# packages | |
# install.packages(c("data.table", "remotes", "EpiNow2")) | |
library(data.table) | |
library(EpiNow2) | |
library(covidregionaldata) | |
# target country (must be present in ECDC data) | |
country <- "france" | |
# set number of cores to use fitting the model |
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
# Load packages | |
library(brms) | |
library(cmdstanr) | |
library(data.table) # here we use the development version of data.table install it with data.table::update_dev_pkg | |
library(purrr) | |
# Set up parallel cores | |
options(mc.cores = 4) | |
# Simulate some truncated and truncation data |
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
functions{ | |
#include functions/ct_trajectory.stan | |
#include functions/truncated_normal_rng.stan | |
#include functions/censor.stan | |
} | |
data { | |
int P; // number of patients | |
int N; // number of tests | |
real c_lod; // Ct value at limit of detection |
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(data.table) | |
library(snakecase) | |
library(ggplot2) | |
# make a convolution matrix | |
convolution_matrix <- function(vec1, vec2) { | |
lvec1 <- length(vec1) | |
lvec2 <- length(vec2) | |
conv <- matrix(0, nrow = lvec1, ncol = lvec1) | |
for (s in 1:lvec1) { |
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
# packages | |
# install.packages(c("data.table", "remotes", "EpiNow2")) | |
# remotes::install_github("epiforecasts/EpiNow2") | |
# remotes::install_github("epiforecasts/covidregionaldata") | |
library(data.table) | |
library(EpiNow2) | |
library(covidregionaldata) | |
# target country (must be supported in covidregionaldata) | |
country <- "uk" # harder to fit "india" |
NewerOlder