Skip to content

Instantly share code, notes, and snippets.

View fdabl's full-sized avatar

Fabian Dablander fdabl

View GitHub Profile
@fdabl
fdabl / variable-selection-comparison.R
Last active January 19, 2023 10:32
Implements three ways to do Bayesian variable selection. For context, see https://fdabl.github.io/r/Spike-and-Slab.html
library('doParallel')
registerDoParallel(cores = 4)
#' Spike-and-Slab Regression using Gibbs Sampling for p > 1 predictors
#'
#' @param y: vector of responses
#' @param X: matrix of predictor values
#' @param nr_samples: indicates number of samples drawn
#' @param a1: parameter a1 of Gamma prior on variance sigma2e
@fdabl
fdabl / gist:dc7bba8dfb331587efed0a9ad2851c20
Created October 18, 2024 13:07
Estimating the risk of getting infected with Covid at an ADE party
library(ggplot2)
library(RColorBrewer)
# Roughly estimates the number of Covid infectious people at an ADE party(N = 900)
# Main uncertainties:
# (1) Number of people infectious
# (2) Number of people a single infectious person infects (R_eff)
#
# For (1), we rely on the number of positive tests from last week. This was 1.5%. Generally, this is an underestimate
# of the true number. Similarly, many people are coming to ADE abroad. We use a distribution over different values below.
@fdabl
fdabl / gist:11382ed858b0d3ca505809af1a98c88c
Created October 18, 2024 13:08
Estimating the risk of getting infected with Covid at an ADE party
library(ggplot2)
library(RColorBrewer)
# Roughly estimates the number of Covid infectious people at an ADE party(N = 900)
# Main uncertainties:
# (1) Number of people infectious
# (2) Number of people a single infectious person infects (R_eff)
#
# For (1), we rely on the number of positive tests from last week. This was 1.5%. Generally, this is an underestimate
# of the true number. Similarly, many people are coming to ADE abroad. We use a distribution over different values below.
@fdabl
fdabl / gist:4eeece12dda8ab81b3b91f39d61758e3
Created October 18, 2024 13:10
Estimating the risk of getting infected with Covid at an ADE party
library(ggplot2)
library(RColorBrewer)
# Roughly estimates the number of Covid infectious people at an ADE party(N = 900)
# Main uncertainties:
# (1) Number of people infectious
# (2) Number of people a single infectious person infects (R_eff)
#
# For (1), we rely on the number of positive tests from last week. This was 1.5%. Generally, this is an underestimate
# of the true number. Similarly, many people are coming to ADE abroad. We use a distribution over different values below.
@fdabl
fdabl / covid_party.R
Created October 18, 2024 13:10
Estimating the risk of getting infected with Covid at an ADE party
library(ggplot2)
library(RColorBrewer)
# Roughly estimates the number of Covid infectious people at an ADE party(N = 900)
# Main uncertainties:
# (1) Number of people infectious
# (2) Number of people a single infectious person infects (R_eff)
#
# For (1), we rely on the number of positive tests from last week. This was 1.5%. Generally, this is an underestimate
# of the true number. Similarly, many people are coming to ADE abroad. We use a distribution over different values below.
@fdabl
fdabl / covid_party.R
Created October 18, 2024 13:13
Estimating the risk of getting infected with Covid at an ADE party
library(ggplot2)
library(RColorBrewer)
# Roughly estimates the risk of getting Covid by attending an ADE party(N = 900)
# Main uncertainties:
# (1) Number of people infectious
# (2) Number of people a single infectious person infects (R_eff)
#
# For (1), we rely on the number of positive tests from last week. This was 1.5%. Generally, this is an underestimate
# of the true number. Similarly, many people are coming to ADE abroad. We use a distribution over different values below.
@fdabl
fdabl / covid_party.R
Created October 18, 2024 13:13
Estimating the risk of getting infected with Covid at an ADE party
library(ggplot2)
library(RColorBrewer)
# Roughly estimates the risk of getting Covid by attending an ADE party(N = 900)
# Main uncertainties:
# (1) Number of people infectious
# (2) Number of people a single infectious person infects (R_eff)
#
# For (1), we rely on the number of positive tests from last week. This was 1.5%. Generally, this is an underestimate
# of the true number. Similarly, many people are coming to ADE abroad. We use a distribution over different values below.