我正在尝试将 Logit 回归从 Stata 复制到 R。在 Stata 中,我使用“稳健”选项来获得稳健的标准误差(异方差一致的标准误差)。我能够从 Stata 复制完全相同的系数,但我无法与包“三明治”具有相同的稳健标准误差。
我尝试了一些 OLS 线性回归示例;似乎 R 和 Stata 的三明治估计器给了我同样强大的 OLS 标准误差。有谁知道Stata如何计算非线性回归的三明治估计量,在我的例子中是logit回归?
谢谢!
附加代码:在R中:
library(sandwich)
library(lmtest)
mydata <- read.csv("http://www.ats.ucla.edu/stat/data/binary.csv")
mydata$rank<-factor(mydata$rank)
myfit<-glm(admit~gre+gpa+rank,data=mydata,family=binomial(link="logit"))
summary(myfit)
coeftest(myfit, vcov = sandwich)
coeftest(myfit, vcov = vcovHC(myfit, "HC0"))
coeftest(myfit, vcov = vcovHC(myfit))
coeftest(myfit, vcov = vcovHC(myfit, "HC3"))
coeftest(myfit, vcov = vcovHC(myfit, "HC1"))
coeftest(myfit, vcov = vcovHC(myfit, "HC2"))
coeftest(myfit, vcov = vcovHC(myfit, "HC"))
coeftest(myfit, vcov = vcovHC(myfit, "const"))
coeftest(myfit, vcov = vcovHC(myfit, "HC4"))
coeftest(myfit, vcov = vcovHC(myfit, "HC4m"))
coeftest(myfit, vcov = vcovHC(myfit, "HC5"))
状态:
use http://www.ats.ucla.edu/stat/stata/dae/binary.dta, clear
logit admit gre gpa i.rank, robust