微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在 R 中运行 IVPROBIT 的内生性测试

如何解决如何在 R 中运行 IVPROBIT 的内生性测试

有没有办法计算 R 中 ivprobit 输出的内生性的 Wald 检验或 Wu-Hausman 统计量?

Wald Chi-Square 和其他拟合统计量在 R 的 ivreg functionStata's ivprobit 中都作为输出给出,但在这里没有。

我尝试使用 ivprobit 作为输入之一计算 Wald 和 Wu-Hausman,但出现错误

library(ivprobit)
endmod <- ivprobit(y1 ~ x1| x2 | z1 + x1,data=data)
no_ivs <- glm(y1 ~ x1 + x2,data,family=binomial(link="probit"))

library(lmtest)
waldtest(no_ivs,endmod)

## Error ##
Error in modelUpdate(objects[[i - 1]],objects[[i]]) : 
  original model was of class "glm",updated model is of class "ivprobit"

library(systemfit)
hausman.systemfit(no_ivs,endmod)

## Error ##
Error in vcov.default(results3sls) : 
  object does not have variance-covariance matrix

然后我尝试通过运行 2SLS(也手动)来手动计算它,但考虑到第一步是一个线性模型(因为内生变量是正态分布的),而第二步是一个概率,我得到的错误是Wald Test 无法计算。

l0 <- glm(y2 ~ x2 + x1,family=binomial(link="probit")))
l1 <- lm(x2 ~ x1 + z1,data)
x2.hat <- fitted.values(l1)
l2 <- glm(y2 ~ x2.hat + x1,family =binomial(link="probit"))

library(lmtest)
waldtest(l0,l2)

## Error ##
Error in objects[[i]] : subscript out of bounds
In addition: Warning message:
In waldtest.default(object,...,test = match.arg(test)) :
  models with response "y2" removed because response differs from model 1

library(plm)
phtest(l0,l2)

## Error ##
Error in UseMethod("phtest") : 
  no applicable method for 'phtest' applied to an object of class "c('glm','lm')"

这是 ivprobit 函数的缺陷吗?还是我做错了什么*?

* 是否也可能是一个数学问题(ivprobit 无法将必要的输入输出到 Wald)?如果是这样,我可以将我的问题转给统计人员。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。