R中的第一阶段IV回归输出 [英] First Stage IV Regression Output in R

查看:647
本文介绍了R中的第一阶段IV回归输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想报告我的两阶段最小二乘回归法两个阶段的结果,但是观星者的输出只给了我第二阶段的结果.

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.

我已经用R中的ivreg命令计算了两阶段最小二乘回归. 这是我的代码:

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)

其中

Y =因变量(续);

Y = dependent variable (cont.);

X =内生自变量(虚拟);

X = endogenous independent variable (dummy);

W1-W4 =控制变量;

W1-W4 = control variables;

Z =外生器械(虚拟)

Z = exogenous instrument (dummy)

现在,我很难报告2SLS回归的第一阶段. 当我使用常用​​的stargazer命令时:

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

stargazer(ivmodel1)

我只收到第二阶段的结果,但我也需要第一阶段的估计. 有人知道在R中使用什么命令以接收两个阶段的结果吗?

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?

推荐答案

分别对每个阶段建模时,都可以将它们都交给stargazer:

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")

这来自: R:鲁棒的SE和模型诊断在观星台上

这篇关于R中的第一阶段IV回归输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆