diagnose: Diagnose problems with iv models.

Description Usage Arguments Examples

View source: R/helpers.R

Description

For instrumental variable models to be valid, instruments should be correlated with the variable for which they are instrumenting; and not correlated with the error term in the regression model. This function diagnoses potential problems with either of those criteria.

Usage

1
diagnose(x, thresh = 0.1)

Arguments

x

an object of class ivm

thresh

arbitrary threshold for correlations. defaults to 0.1.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# Fake data
N <- 1000
z <- rnorm(N, 1, 1)
q <- rnorm(N, 0, 1)
error <- rnorm(N, 1, 1)
x <- z + error + rnorm(N, 1, 1)
y <- x + error

# Fit OLS
fit_ols <- lm(formula = y ~ x)

# Fit 2SLS
fit_2sls <- iv.lm(y ~ x, x ~ z + q)

diagnose(fit_2sls)

alexpavlakis/instruments documentation built on May 6, 2019, 1:34 a.m.