Implements bidirectional two-stage least squares (Bi-TSLS) estimation for identifying bidirectional causal effects between two variables in the presence of unmeasured confounding. The method uses proxy variables (negative control exposure and outcome) along with at least one covariate to handle confounding.
A simple R package for estimating bidirectional causal effects using proxy variables.
# Install from GitHub
# install.packages("devtools")
devtools::install_github("Fhoneysuckle/BiTSLS")
The Bi_TSLS() function estimates bidirectional causal effects between X and Y:
library(BiTSLS)
# Prepare your data with required variables
data <- data.frame(
X = ..., # Treatment variable
Y = ..., # Outcome variable
Z = ..., # Negative control exposure
W = ..., # Negative control outcome
# Additional covariates (At least one covariate)
)
# Run the estimation
result <- Bi_TSLS(data)
# View results
print(result) # Effect of X on Y and Y on X
Your data must contain:
X: Treatment/exposure variable (numeric)Y: Outcome variable (numeric)Z: Negative control exposure (numeric)W: Negative control outcome (numeric)You can test sensitivity to violations of the proxy structural conditions:
# With sensitivity parameters
result <- Bi_TSLS(data, R_w = 0.1, R_z = -0.1)
MIT License