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: Propensity Score Plots Using IP Weighting ---- | |
| # Description: This code shows how different patients will receive different weights | |
| # depending upon the causal estimand when using IP weighting. This code focuses on | |
| # three estimands: ATE, ATT and ATU. | |
| # Note: thanks to Andrew Heiss' blog for the inspiration for these plots and making his code 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: M-Estimation After IPTW ---- | |
| # Description: Demonstrating M-estimation after IPTW. | |
| # Showing how it can be helpful, and comparing to if we didn't use anything | |
| # (in this case using the SEs from GLM) | |
| # Note: code in this script was largely inspiried by Ross et al. (2024). | |
| # The code supplied in that paper was used to create this code | |
| # (the authors used a binary outcome, while this code uses a continuous outcome) |
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: Understanding Diagnostic Plots Through Simulation ---- | |
| # This code uses an example to demonstrate how we can use simulation to | |
| # better understand diagnostic plots. For this specific example, we will use the | |
| # posterior predictive check | |
| # Note: using default priors, etc. for this example | |
| # 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: Table 2 Fallacy ---- | |
| # Description: Demonstrating the table 2 fallacy using a simple example. | |
| # This is based on the DAG that is shown in a corresponding LinkedIn post. | |
| # 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: Time-Varying Confounding (MSM vs IPTW) | |
| # Description: Demonstrating how marginal structural models provide | |
| # less biased estimates compared to using IPTW at baseline only, when | |
| # there is time-varying confounding. | |
| # 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: Matching vs Weighting | |
| # Description: Demonstrating how matching and weighting can estimate | |
| # different things. IPTW can also estimate ATT. The goal is to demonstrate how they | |
| # may give different answers | |
| # Setup ---- | |
| #... Library ---- |
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: Doubly Robust Estimation | |
| # Description: Demonstrating how doubly robust estimation can be | |
| # a useful tool, but has limitations. Specifically by looking at three different | |
| # scenarios and the resulting bias. | |
| # This script has three examples: | |
| # 1. Both models correctly specified | |
| # 2. One of the models correctly specified | |
| # 3. Neither model correctly specified. |
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: Ordered Beta Regression | |
| # Description: This code is to demonstrate using ordered beta regression. | |
| # This method can be particularly helpful for continuous data with upper/lower bounds. | |
| # For more information recommend reading Kubinec (2022) | |
| # 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: Plotting Different Priors | |
| # Description: Choosing an appropriate prior is a key part of any Bayesian analysis. | |
| # This code shows different priors to try and highlight which one(s) might | |
| # be reasonable. | |
| # Setup ---- | |
| #... Packages ---- |