Skip to content

Instantly share code, notes, and snippets.

View battenr's full-sized avatar

Ryan Batten battenr

View GitHub Profile
# Title: Plotting Distributions for PS Methods
# Description: An example of plotting the distributions before and after
# IPTW of two confounders.
# Setup ----
#... Libraries ----
library(tidyverse) # ol faithful
@battenr
battenr / collider_bias.R
Last active April 23, 2024 17:52
Proving Collider Bias
# Title: Conditioning on a Collider
# Description: Directed acyclic graphs (DAGs) are a great tool that can be
# used to guide variable selection. Colliders, a variable where two arrowheads meet,
# should not be adjusted for since they can induce bias. This code aims to prove
# and quantify the bias using a simple example.
# Setup ----
#... Libraries ----
@battenr
battenr / demo_clt.R
Created April 11, 2024 16:49
Demonstrating the Central Limit Theorem
# Title: Demonstration of the Central Limit Theorem
# Description: The purpose of this script is to simulate data for three different
# distributions (normal, logistic and poisson) for four different sample sizes.
# Each of these is then plotted to demonstrate how the sampling distribution
# changes with increasing sizes of the sample.
# Setup ----
@battenr
battenr / prob_of_censor
Created April 8, 2024 13:38
Calculating Probability of Censoring
# Title: Calculating Probability of Censoring
# Description: Inverse probability of censoring weighting (IPCW) can be used to remove the potential selection bias
# caused by censoring. There are different ways to calculate the probability of censoring. The goal of this code was
# to examine whether the two methods produced the same result.
# Setup ----
#... Libraries