iv.diagnosis | R Documentation |
Diagnostics of instrumental variable analysis
iv.diagnosis(Y, D, Z, X)
iv.diagnosis.plot(output, bias.ratio = TRUE, base_size = 15, text_size = 5)
Y |
A numeric vector of outcomes. |
D |
A vector of endogenous variables. |
Z |
A vector of instruments. |
X |
A vector, matrix or data frame of (exogenous) covariates. |
output |
Output from |
bias.ratio |
Add bias ratios (text) to the plot? |
base_size |
size of the axis labels |
text_size |
size of the text (bias ratios) |
a list or data frame
Mean of X under Z = 1 (reported if Z is binary)
Mean of X under Z = 0 (reported if Z is binary)
OLS coefficient of X ~ Z (reported if Z is not binary)
Standard error of OLS coefficient (reported if Z is not binary)
p-value of the independence of Z and X (Fisher's test if both are binary, logistic regression if Z is binary, linear regression if Z is continuous)
Standardized difference (reported if Z is binary)
Bias ratio
Amplification of bias ratio
Bias of OLS
Bias of two stage least squares)
iv.diagnosis.plot()
: IV diagnostic plot
Qingyuan Zhao
Baiocchi, M., Cheng, J., & Small, D. S. (2014). Instrumental variable methods for causal inference. Statistics in Medicine, 33(13), 2297-2340.
Jackson, J. W., & Swanson, S. A. (2015). Toward a clearer portrayal of confounding bias in instrumental variable applications. Epidemiology, 26(4), 498.
Zhao, Q., & Small, D. S. (2018). Graphical diagnosis of confounding bias in instrumental variable analysis. Epidemiology, 29(4), e29–e31.
n <- 10000
Z <- rbinom(n, 1, 0.5)
X <- data.frame(matrix(c(rnorm(n), rbinom(n * 5, 1, 0.5)), n))
D <- rbinom(n, 1, plogis(Z + X[, 1] + X[, 2] + X[, 3]))
Y <- D + X[, 1] + X[, 2] + rnorm(n)
print(output <- iv.diagnosis(Y, D, Z, X))
iv.diagnosis.plot(output)
Z <- rnorm(n)
D <- rbinom(n, 1, plogis(Z + X[, 1] + X[, 2] + X[, 3]))
Y <- D + X[, 1] + X[, 2] + rnorm(n)
print(output <- iv.diagnosis(Y, D, Z, X)) ## stand.diff is not reported
iv.diagnosis.plot(output)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.