Skip to content

Instantly share code, notes, and snippets.


Sam Abbott seabbs

View GitHub Profile
seabbs / explore-covid-19-data-truncation
Last active Nov 23, 2020
Explores Covid-19 data truncation in England (i.e when data is updated in later releases) using an experimental model in EpiNow2. By default looks at test positive cases but this can be updated by changing the selected variable in line 27.
View explore-covid-19-data-truncation
# Note: estimate_truncation is experimental so use this for exploratory purposes
# only and/or with a high level of interpretation
# Packages ----------------------------------------------------------------
# install packages
# install.packages(c("data.table", "purrr", "remotes", "EpiNow2"))
# remotes::install_github("epiforecasts/covidregionaldata")
seabbs / epinow2-covid-rt-national
Last active Nov 23, 2020
Example of using EpiNow2 to estimate the Rt of Covid-19 in last 3 months for a country in the ECDC dataset. See the documentation for more details and examples of producing estimates for subregional areas:
View epinow2-covid-rt-national
# packages
# install.packages(c("data.table", "remotes", "EpiNow2"))
# remotes::install_github("epiforecasts/covidregionaldata")
# target country (must be present in ECDC data)
country <- "france"
cd /home/azureuser/covid-rt-estimates
git add --all
git commit -m "update estimates"
git push
cd /home/azureuser/
git clone
cd covid-rt-estimates
sudo bash bin/ "build"
sudo bash bin/
while [ ! -f "$FILE" ]; do
seabbs / change_with_rw_padding
Last active Aug 21, 2020
Evaluates Rt over two fixed time points with Rt assumed to vary based on a random walk in-between the two time points and after a period of time.
View change_with_rw_padding
# Get example case counts
reported_cases <- EpiNow2::example_confirmed[1:60]
# Add a dummy breakpoint (used only when optionally estimating breakpoints)
reported_cases <- reported_cases[, breakpoint := data.table::fifelse((date >= as.Date("2020-03-16") & date <= as.Date("2020-03-29")) | date >= as.Date("2020-04-11"),
1, 0)]
# Set up example generation time
seabbs /
Last active Aug 14, 2020
Set up an instance of EpiNow2 on a clean server with an interactive Rstudio server at localhost:8787 (username/login: epinow2)
sudo apt-get update
sudo apt-get install -y
sudo docker login
sudo docker pull
sudo docker tag epinow2
seabbs /
Last active Aug 17, 2020
Update Rt estimates on a remote server over SSH. Run with: sudo bash server-public-ip
# Get rid of the older update script
# Get the new update script
curl --fail >
# Run the update script
bash ~/.ssh/id_rsa azureuser@$1 github-username-here github-pat-here
seabbs /
Created Jul 2, 2020
Deploy GitHub pages from the docs folder to gh-pages
git subtree split --squash --prefix docs -b gh-pages
git push -f origin gh-pages:gh-pages
git branch -D gh-pages
seabbs / simulate-cases
Created May 29, 2020
Simulates cases by date of report from input Rt and initial case seed
View simulate-cases
#1. Input a vector of Rt estimates, and vector to initialise cases, and a generation time
initial_cases <- 100
initial_date <- as.Date("2020-03-01")
rts <- c(rep(2, 20), (2 - 1:15 * 0.1), rep(0.5, 10))
## Simulating cases
seabbs / memory-leak
Created May 11, 2020
Test memory leak
View memory-leak
# Packages -----------------------------------------------------------------
require(data.table, quietly = TRUE)
require(future, quietly = TRUE)
## Require for data and nowcasting
# require(EpiNow, quietly = TRUE)
# require(NCoVUtils, quietly = TRUE)
## Required for forecasting
# require(future.apply, quietly = TRUE)
You can’t perform that action at this time.