iv.diagnosis {ivmodel}R Documentation

Diagnostics of instrumental variable analysis

Description

Diagnostics of instrumental variable analysis

Usage

iv.diagnosis(Y, D, Z, X)

iv.diagnosis.plot(output, bias.ratio = TRUE, base_size = 15, text_size = 5)

Arguments

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 iv.diagnosis.

bias.ratio

Add bias ratios (text) to the plot?

base_size

size of the axis labels

text_size

size of the text (bias ratios)

Value

a list or data frame

x.mean1

Mean of X under Z = 1 (reported if Z is binary)

x.mean0

Mean of X under Z = 0 (reported if Z is binary)

coef

OLS coefficient of X ~ Z (reported if Z is not binary)

se

Standard error of OLS coefficient (reported if Z is not binary)

p.val

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)

stand.diff

Standardized difference (reported if Z is binary)

bias.ratio

Bias ratio

bias.amplify

Amplification of bias ratio

bias.ols

Bias of OLS

bias.2sls

Bias of two stage least squares)

Functions

Author(s)

Qingyuan Zhao

References

Examples

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)


[Package ivmodel version 1.9.1 Index]