![](/img/trans.png)
[英]Tobit regression in R, while looping regressions my data is not censored using censReg
[英]tobit model in R, using censReg(), with arbitrary observed values of censored observations
使用 censReg() 函数估计 R 中的 tobit 模型。 似乎审查观察的观察值应该无关紧要(当然,只要它们低于审查值)。 在下面的代码中比较 tobit1 和 tobit2 是正确的。 但是,当我稍微改变观察值(从 -2.8e5 到 -2.9e5)时,结果完全改变。 知道这里发生了什么吗?
set.seed(8)
n = 200
x = rnorm(n)
a=3; b = 3
# generate latent y; censoring value k; and observed z
y = rnorm(n, a+b*x)
k = 2
z = ifelse(y>k, y, 0)
table(z==0) # 82 T, 118 F
# tobit with "reasonable" observed values for censored obs:
tobit1 = censReg(z~x,left=k)
# tobit with arbitrarily low observed values for censored obs:
z2 = ifelse(y>k, y, -2.8e5)
tobit2 = censReg(z2~x,left=k)
# ... and even lower:
z3 = ifelse(y>k, y, -2.9e5)
tobit3 = censReg(z3~x,left=k)
stargazer(tobit1,tobit2,tobit3,type='text')
=================================================
Dependent variable:
-----------------------------
z z2 z3
(1) (2) (3)
-------------------------------------------------
x 2.988*** 2.988*** 8,518.070
(0.109) (0.109)
logSigma -0.090 -0.090 8.808
(0.065) (0.065)
Constant 2.937*** 2.937*** -7,792.855
(0.097) (0.097)
-------------------------------------------------
Observations 200 200 200
Log Likelihood -177.353 -177.353 -1,201.950
Akaike Inf. Crit. 360.707 360.707 2,409.899
Bayesian Inf. Crit. 370.602 370.602 2,419.794
=================================================
Note: *p<0.1; **p<0.05; ***p<0.01
嗯,这很令人失望。 我遇到了通过谷歌确定censReg
在包“censReg”中的麻烦(从censReg
并不明显),安装包及其依赖项,并加载“censReg”和“stargazer”。 现在我明白了:
> # tobit with "reasonable" observed values for censored obs:
> tobit1 = censReg(z~x,left=k)
Warning message:
In censReg(z ~ x, left = k) :
at least one value of the endogenous variable is smaller than the left limit
>
> # tobit with arbitrarily low observed values for censored obs:
> z2 = ifelse(y>k, y, -2.8e5)
> tobit2 = censReg(z2~x,left=k)
Warning message:
In censReg(z2 ~ x, left = k) :
at least one value of the endogenous variable is smaller than the left limit
> # ... and even lower:
> z3 = ifelse(y>k, y, -2.9e5)
> tobit3 = censReg(z3~x,left=k)
Warning message:
In censReg(z3 ~ x, left = k) :
at least one value of the endogenous variable is smaller than the left limit
stargazer(tobit1,tobit2,tobit3,type='text')
=================================================
Dependent variable:
-----------------------------
z z2 z3
(1) (2) (3)
-------------------------------------------------
x 2.988*** 2.988*** 2.988***
(0.109) (0.109) (0.109)
logSigma -0.090 -0.090 -0.090
(0.065) (0.065) (0.065)
Constant 2.937*** 2.937*** 2.937***
(0.097) (0.097) (0.097)
-------------------------------------------------
Observations 200 200 200
Log Likelihood -177.353 -177.353 -177.353
Akaike Inf. Crit. 360.707 360.707 360.707
Bayesian Inf. Crit. 370.602 370.602 370.602
=================================================
Note: *p<0.1; **p<0.05; ***p<0.01
因此,您收到了未提供的警告消息,并且您可能发现了特定于您正在使用的操作系统的错误,而您尚未披露。 我在 Ubuntu 18.04 机器上使用 R 3.6.1。 您应该确定您使用的是最新版本的 R(尽管我还没有更新到 3.6.2)和所有涉及的包(注意我有 stargazer_5.2.2 + censReg_0.5-30 + maxLik_1。 3-6) 如果是这样,请将错误报告发送至:
maintainer("censReg")
[1] "Arne Henningsen <arne.henningsen@gmail.com>"
请附上您的:
sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.3 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8
[4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] stargazer_5.2.2 censReg_0.5-30 maxLik_1.3-6 miscTools_0.6-22 vars_1.5-3
[6] lmtest_0.9-37 urca_1.3-0 strucchange_1.5-1 sandwich_2.5-1 zoo_1.8-6
[11] MASS_7.3-51.4 MTS_1.0
loaded via a namespace (and not attached):
[1] Rcpp_1.0.3 Formula_1.2-3 magrittr_1.5 lattice_0.20-38
[5] bibtex_0.4.2 stringr_1.4.0 timeSeries_3042.102 tools_3.6.1
[9] grid_3.6.1 glmmML_1.1.0 timeDate_3043.102 nlme_3.1-141
[13] yaml_2.2.0 bdsmatrix_1.3-3 Rdpack_0.11-0 gbRd_0.4-11
[17] plm_2.1-0 fGarch_3042.83.1 stringi_1.4.3 compiler_3.6.1
[21] fBasics_3042.89 spatial_7.3-11 mvtnorm_1.0-11
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.