iv.lm: Estimate linear regression models with an instrumental...

Description Usage Arguments Examples

View source: R/ivlm.R

Description

This function allows you to estimate a two-stage least squares linear regression in one step.

Usage

1
iv.lm(model_formula, instrument_formula = NULL, data = NULL, ...)

Arguments

model_formula

The formula of the main regression problem.

instrument_formula

The formula for the first stage of the regression problem. Estimate an endogenous variable from one (or more) instruments. If blank, defaults to ordinary linear regression.

data

(optional) A data frame containing all variables for the regression model.

...

Additional arguments to pass to glm().

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)
error <- rnorm(N, 1, 1)
x <- z + error + rnorm(N, 1, 1)
y <- x + error

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

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

summary(fit_ols)
summary(fit_2sls)

instruments documentation built on Nov. 16, 2018, 5:03 p.m.