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: Stabilizing and Truncating Weights | |
| # Description: When using weights, for example IPTW, it is often helpful to | |
| # stabilize and/or truncate them. This code is meant to demonstrate how we | |
| # can do that, and why. | |
| # 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: Checking Propensity Scores and Covariates | |
| # Description: This script demonstrates that sometimes there can appear to be overlap when checking only the propensity score, | |
| # however upon checking the covariates overlap, there is a lack of overlap. | |
| # 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: Strength of Confounders When Choosing a Data Source | |
| # Description: When using real-world data, an important aspect is choosing the | |
| # dataset to use. Not all variables are always available in each data source. | |
| # For example, eletronic health records vs claims data vs registry data each | |
| # have strengths and benefits (one of which, is the variables available) | |
| # 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: Adjusting for Predictor Variable | |
| # Description: Directed acyclic graphs (DAGs) are fantastic for variable selection. | |
| # Sometimes there are variable that it's not clear if we should include or not. | |
| # This code demonstrates one example: a variable that causes one of the confounders | |
| # and the outcome. | |
| # Both bias and relative increase in precision are explored for this situation. | |
| # Inverse probability weighting, estimating the average treatment effect, is | |
| # used. When adjusting for the predictor, it is only included in the outcome model |
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: What to Do If Lack of Overlap? | |
| # Description: This code creates a figure where there is a lack of overlap | |
| # due to leaving out a confounder. | |
| # 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: Collider and confounder - adjust or not adjust? (Butterfly bias) | |
| # Description: Understanding if we should adjust for a variable that is | |
| # both a collider and a confounder. For this example, we will use a DAG that has | |
| # butterfly bias (a specific type of M-bias) | |
| # The idea for this code was to keep the situation simple to start. It can be built upon | |
| # rather easily. A few things to try altering would be the strength of the causal relationships, | |
| # continuous vs binary vs TTE variables, more/less variables, etc. |
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: Adjusting for Mediator ---- | |
| # Description: This code demonstrates how adjusting for a mediator doesn't | |
| # estimate the total causal effect. | |
| # Setup ---- | |
| library(tidyverse) # ol' faithful | |
| library(ggdag) # for drawing DAGs | |
| library(broom) # tidying model outputs |
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: Checking Balance After IPTW: SMDs & Plots | |
| # Description: This code demonstrates how standardized mean differences (SMDs) | |
| # can be a useful tool to check for balance but may not show the entire picture. | |
| # Setup ---- | |
| #... Packages ---- | |
| 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 Sample Size Required Using Precision ----- | |
| # Description: Sample sizes are primarly based upon an assumed power. For some studies, | |
| # such as observational studies with large samples, there isn't an issue with power. However, | |
| # there may be a need to understand the required sample size (i.e., how much data to request from vendor, etc) | |
| # In these situations, precision can be used instead! | |
| # 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
| # Doubly Robust Estimation ---- | |
| # Description: Doubly robust estimation can be helpful for estimating | |
| # causal effects. This code is demonstrating how there is reduced bias | |
| # compared to IPTW only or using the outcome model only | |
| # Setup ---- | |
| #... Packages ---- |