【问题标题】:R: Logit Regression with Instrument Variable and Interaction TermR:带有仪器变量和交互项的 Logit 回归
【发布时间】:2025-11-25 01:05:04
【问题描述】:

我对 R 有一个严重的问题。我不知道如何使用仪器变量运行 logit 回归。 棘手的是我有 2 个独立变量作为交互项,但该工具仅适用于两个独立变量之一。此外,我有几个控件。 我用 AER ivreg 包尝试了一些东西,但我无法弄清楚我必须在回归命令中输入什么。

如果有人可以帮助我,我将不胜感激。

【问题讨论】:

    标签: r logistic-regression interaction


    【解决方案1】:

    我认为这篇文章是您所需要的: http://www.r-bloggers.com/a-simple-instrumental-variables-problem/

    帖子中的代码

    library(AER)
    library(lmtest)
    data("CollegeDistance")
    cd.d<-CollegeDistance
    simple.ed.1s<- lm(education ~ distance,data=cd.d)
    cd.d$ed.pred<- predict(simple.ed.1s)
    simple.ed.2s<- lm(wage ~ urban + gender + ethnicity + unemp + ed.pred ,     data=cd.d)
    simple.comp<- encomptest(wage ~ urban + gender + ethnicity + unemp + ed.pred , wage ~ urban + gender + ethnicity + unemp + education , data=cd.d)
    1s.ftest<- encomptest(education ~ tuition + gender + ethnicity + urban ,     education ~ distance , data=cd.d)
    
    library(arm)
    coefplot(lm(wage ~ urban + gender + ethnicity + unemp + education,data=cd.d),vertical=FALSE,var.las=1,varnames=c("Education","Unemp","Hispanic","Af-am","Female","Urban","Education"))
    coefplot(simple.ed.2s ,     vertical=FALSE,var.las=1,varnames=c("Education","Unemp","Hispanic","Af-am","Female","Urban","Education"))
    

    【讨论】: