Practical R example – back door versus front door
Let’s consider a corporate scenario where we are interested in investigating the causal effect of gender on remuneration. We will consider both back door and front door adjustments using R. In real-world corporate settings, this analysis can be complex due to various factors, such as job role, seniority, education, work experience, and potential unmeasured confounders, such as negotiation skills or networking.
Synthetic data
Here is the R code to create a synthetic dataset; let’s name it corp_data
and add relevant columns such as gender
, remuneration
, promotion_opportunities
, performance_rating
, department
, work_experience
, education
, and job_role
:
# Load necessary library library(dplyr) # Set seed for reproducibility set.seed(123) # Generate synthetic data n <- 5000 # Number of observations corp_data <- data.frame( gender = sample(c("Male", "Female"), n, replace =...