Description Usage Arguments Examples
This function allows you to estimate two stage generalized linear models in one step.
1 2 |
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 regular glm. |
data |
(optional) A data frame containing all variables for the regression model. |
family |
The distribution family of the outcome variable. |
link |
The link function to the outcome variable. |
... |
Additional arguments to pass to glm(). |
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 <- rbinom(N, 1, invlogit(x + error))
# Fit glm
fit_glm <- glm( y ~ x, family = binomial(link = 'logit'))
# Fit with iv
fit_iv <- iv.glm(y ~ x, x ~ z, family = binomial, link = 'logit')
summary(fit_glm)
summary(fit_iv)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.