Skip to content

Instantly share code, notes, and snippets.

@medewitt
medewitt / epinowcast-stan-help.md
Created December 11, 2023 14:23
Epinowcast hidden text for later development

Text once models can be pre-compiled

The first time you fit a model with {epinowcast} will be slow compared to future fits! This is normal as all of the Stan code is being compiled for the first time. Note that the compiled Stan binaries will live in your user package directory (or wherever you have defined your package libraries). Because of this package architecture

  • Each time you install a new version of {epinowcast} you will experience this longer compilation time the first time you fit a model.
# Purpose: This is just a play model to think about time spent on large and big grants/opportunities and
# overall likelihood of a successful result (undefined, just general feel).
# 2080 is the hours in a year if working 40 hours (because everyone does that...)
using JuMP
using Ipopt
model = Model(Ipopt.Optimizer)
p1 = .05 # Probability of winning grant 1
sx1 = .4 # Probability of successful work (class 1)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@medewitt
medewitt / risk-model.R
Created May 13, 2020 21:27
modelling-outbreak-risk
library(tidyverse)
n.sim <- 1000
lambda <- 8/45 # 8 nursing homes in 45 days
set.seed(336)
n.sim <- 1000
mu <- 20 # 20 hospitalizations mean
sigma <- 5 ## =/- 10 patients
sigma.sq <- sigma^2
@medewitt
medewitt / compartment-viz-functions.R
Created May 4, 2020 09:47
Visualize compartment summaries from odin
library(data.table)
library(tidyverse)
path_seirds_model <- system.file("examples/discrete_stochastic_seirds.R", package = "odin")
seirds_generator <- odin::odin(path_seirds_model)
x <- seirds_generator()
x_res <- as.data.frame(replicate(100, x$run(0:365)[, -1]))
@medewitt
medewitt / icl_model.R
Created April 28, 2020 10:42
wrapping Imperial College
#' Stan Model Base General
#'
#' @param dat the dat sent to the model
#' @param iter 2400
#' @param warmup 1000
#' @param chains 4
#' @param control default controls
#' @param ... Arguments passed to `rstan::sampling` (e.g. iter, chains).
#' @return An object of class `stanfit` returned by `rstan::sampling`
#' @export
@medewitt
medewitt / grow-sda2.sh
Created April 17, 2020 15:10
grow filesystem after re-partition on centos 7 box
sudo xfs_growfs -d /
@medewitt
medewitt / information.md
Created March 25, 2020 10:25
Contact Tracing and Severity

The Shenzhen CDC identified 391 SARS-CoV-2 cases from January 14 to February 12, 2020 and 1286 close contacts. We compare cases identified through symptomatic surveillance and contact tracing, and estimate the time from symptom onset to confirmation, isolation, and hospitalization. We estimate metrics of disease transmission and analyze factors influencing transmission risk.

Cases were older than the general population (mean age 45) and balanced between males (187) and females (204). Ninety-one percent had mild or moderate clinical severity at initial assessment. Three have died, 225 have recovered (median time to recovery is 21 days). Cases were isolated on average 4.6 days after developing symptoms; contact tracing reduced this by

@medewitt
medewitt / covid-mortality-rates.csv
Created March 21, 2020 21:29
covid-mortality rates
age_group pct_sympto_hospital pct_hosp_icu infection_fatality_ratio
0-9 0.00 0.05 0.00
10-19 0.00 0.05 0.00
20-29 0.01 0.05 0.00
30-39 0.03 0.05 0.00
40-49 0.05 0.06 0.00
50-59 0.10 0.12 0.01
60-69 0.17 0.27 0.02
70-79 0.24 0.43 0.05
80+ 0.27 0.71 0.09