简体   繁体   English

计算 R 中 Tobit 的虚拟(及其标准误差)的边际效应

[英]Calculate marginal effect of dummy (and its standard error) for Tobit in R

I have a standard Tobit model where the only explanatory variable is a dummy for treatment (plus the intercept), and I want to estimate the marginal effect of this treatment on my dependent variable and also the standard error of this ME.我有一个标准的 Tobit 模型,其中唯一的解释变量是处理的虚拟变量(加上截距),我想估计这种处理对我的因变量的边际影响以及这个 ME 的标准误差。

I know that the mfx package in R is able to recover what I want for the Probit and Logit models, but I couldn't find a similar package for Tobit.我知道 R 中的 mfx 包能够恢复我想要的 Probit 和 Logit 模型,但我找不到类似的 Tobit 包。 Does anyone know about a package that can do this or how to recover the ME and its standard error by "hand"?有谁知道可以执行此操作的软件包或如何通过“手动”恢复 ME 及其标准错误? Thanks!谢谢!

Edit: The AER package has a function that estimates a Tobit model, so I was looking for some way of calculating the ME (and the standard error of the ME) using it.编辑:AER 包有一个估计 Tobit 模型的函数,所以我正在寻找使用它计算 ME(和 ME 的标准误差)的某种方法。 Here is an example of what I am doing using data from the AER package.这是我使用 AER 包中的数据所做的一个示例。

library(AER)

data("CollegeDistance")

model <- tobit(CollegeDistance$education ~ CollegeDistance$gender, left = 0, data = CollegeDistance, x= TRUE)

With this code I can recover the Tobit coefficients for the intercept and the dummy variable (gender), the scale parameter, and the mean value of "gender" and the intercept.使用此代码,我可以恢复截距和虚拟变量(性别)、尺度参数以及“性别”和截距的平均值的 Tobit 系数。 But differently from the mfx package for Probit/Logit, the Tobit function from the AER package doesn't return the marginal effect of gender on years of education nor its standard error.但与 Probit/Logit 的 mfx 包不同,AER 包中的 Tobit 函数不返回性别对受教育年限的边际效应或其标准误差。

So, I was wondering if 1) someone knows how to recover the ME and the ME's standard error from the output of the AER's tobit function or if 2) someone is aware of a function that works like probitmfx does for Probit?所以,我想知道是否 1) 是否有人知道如何从 AER 的 tobit 函数的输出中恢复 ME 和 ME 的标准错误,或者是否 2) 有人知道像 probitmfx 对 Probit 那样工作的函数? Thanks once again.再次感谢。

You may want to try the marginaleffects package.您可能想尝试marginaleffects包。 (Disclaimer: I am the maintainer.) (免责声明:我是维护者。)

library(AER)
library(marginaleffects)
data("CollegeDistance")
model <- tobit(education ~ gender, left = 0, data = CollegeDistance, x= TRUE)
mfx <- marginaleffects(model)
summary(mfx)
## Average marginal effects 
##       type         Term  Effect Std. Error z value Pr(>|z|)   2.5 %  97.5 %
## 1 response genderfemale -0.0351    0.05222 -0.6722  0.50148 -0.1374 0.06725
## 
## Model type:  tobit 
## Prediction type:  response

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM