First Stage IV Regression Output in R

谁说胖子不能爱 提交于 2020-01-25 06:48:48

问题


I want to report the results of both stages of my Two-Stage Least Square Regression but stargazer output only gives me the second stage.

I have calculated a Two-Stage Least Square Regression with the ivreg command in R. This is what my code looks like:

ivmodel1 <- ivreg(Y ~ X + W1  + W2 + W3 + W4 | W1  + W2 + W3 + W4 + Z, data = df)

where

Y = dependent variable (cont.);

X = endogenous independent variable (dummy);

W1-W4 = control variables;

Z = exogenous instrument (dummy)

Now I am having difficulties to report the first stage of the 2SLS regression. When I use the usual stargazer command:

stargazer(ivmodel1)

I only receive the resuts of the second stage but I also need the first stage estimates. Does someone know what commmand to use in R in order to receive the results of both stages?


回答1:


When you model each stage separately, you can hand both to stargazer:

library(AER)
library(stargazer)

y <- rnorm(100, 5, 10)
x <- rnorm(100, 3, 15)
z <- rnorm(100, 3, 7)
a <- rnorm(100, 1, 7)
b <- rnorm(100, 3, 5)

# Fitting IV models
fit1 <- ivreg(y ~ x + a  |
                a + z,
              model = TRUE)
fit2 <- ivreg(y ~ x + a  |
                a + b + z,
              model = TRUE)

# Create latex table
stargazer(fit1, fit2, type = "text")

This comes from: R: Robust SE's and model diagnostics in stargazer table



来源:https://stackoverflow.com/questions/58542739/first-stage-iv-regression-output-in-r

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!