This file contains hidden or 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
| # Title: Model Diagnostics - Generalized Linear Model (GLM) | |
| # Description: Demonstrating how we can explore model diagnostics | |
| # using simulated data. For this specific use case, we are going | |
| # to explore diagnostics for a generalized linear model (glm). | |
| # Setup ---- | |
| #... Libraries ---- |
This file contains hidden or 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
| # Title: Average Treatment Effects (ATE) vs Individual Treatment Effects (ITE) | |
| # Description: Demonstrating how it's important to distinguish between individual treatment effects | |
| # and the average treatment effect. | |
| # Setup ---- | |
| #... Libraries ---- | |
| library(tidyverse) # ol faithful |
This file contains hidden or 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
| # Title: Splines for Causal Inference | |
| # Description: Demonstrating how splines are helpful for causal inference. | |
| # Specifically, they are helpful when we have a non-linear relationship. | |
| # The goal with causal inference is to block backdoor paths. To do this, we | |
| # adjust for confounders. We need to model the relationship between the | |
| # confounder and exposure, between confounder and outcome or both. | |
| # Sometimes these relationships are non-linear. So what do we do? |
This file contains hidden or 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
| # Title: Stepwise Selection is a Bad Idea for Causal Inference | |
| # Description: Demonstrating how using stepwise selection can lead to | |
| # a biased estimate when the goal is causal inference | |
| # Setup ---- | |
| #... Libraries ---- | |
| library(tidyverse) # ol' faithful |
This file contains hidden or 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
| # Title: Estimating Survival Curves Using IP Weights | |
| # Description: Demonstrating how we can create survival curves with inverse | |
| # probability weights for causal inference. | |
| # Notes: Used the book Causal Inference: What If by Hernan & Robins and accompanying | |
| # R code for guidance. Thanks to everyone involved for making it freely available! | |
| # Setup ---- |
This file contains hidden or 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
| # Title: Same Method, Different Answers - Causal Estimands | |
| # Description: Demonstrating how you can use the same method (IPW), but end up with | |
| # different answers. Each of them is valid, but each answer is for | |
| # a different question. | |
| # This code simulates data for two study designs: | |
| # - An RCT | |
| # - An observational study (RWE) |
This file contains hidden or 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
| # Title: Different Methods of Modelling Survival Data | |
| # Description: There are a wide variety of methods than can be used, however | |
| # we need to be careful about what assumptions we are making. | |
| # The goal of this code is to demonstrate how survival curves can look | |
| # different depending on different methods. | |
| # This code simulates data based on a Weibull distribution, then | |
| # attempts to fit different models to the data, highlighting how |
This file contains hidden or 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
| # Title: Confounding as a Pathway | |
| # Description: Confounding is sometimes mixed with the term confounder. This | |
| # code demonstrates how we can adjust for either variable on a confounding pathway | |
| # to reduce bias (assuming there are no colliders) | |
| # Setup ---- | |
| #... Libraries ---- |
This file contains hidden or 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
| # Title: Demonstrating Bootstrapping Using a Visual (gif) | |
| # Description: Demonstrating how bootstrapping works, repeatedly resampling then | |
| # calculating the statistic of interest. | |
| # Note: ChatGPT was used to assist with creating this code | |
| # Setup ---- | |
| #... Packages ---- |
This file contains hidden or 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
| # Title: Descendant of a Collider - To adjust or not adjust? | |
| # Description: Should we adjust for a variable that is a descendant of a collider? | |
| # It is commonly accepted that we should not, since it will increase bias. | |
| # The goal of this code is to test that through simulation. | |
| # Setup ---- | |
| #... Libraries ---- |