【问题标题】:Tobit Model, regession with white standard errorsTobit 模型,带有白色标准误差的回归
【发布时间】:2018-08-29 13:04:11
【问题描述】:

见鬼,有人能告诉我如何在 Tobit 模型中使用 White 标准错误吗? 以下代码适用于线性模型,但不适用于 tobit 模型。

library(censReg)
library(sandwich)

# OLS model 
reg_ols <- lm(vrs_eff ~ cows, data=milk_data)
summary(reg_ols)
# using White standard errors
# vcovHC: Heteroskedasticity-consistent estimation 
# of the covariance matrix of the coefficient estimates in regression models.
cov_mat_OLS <- vcovHC(reg_ols, type="HC")
cov_mat_OLS
# coeftest is a generic function for performing z and 
# (quasi-)t Wald tests of estimated coefficients.
# Calculate new t and p values with white standard errors
coeftest(reg_ols, cov_mat_OLS)

# Tobit model
reg_tobit <- censReg(vrs_eff ~ cows, left=0, right=1, data=milk_data)
summary(reg_tobit)
cov_mat_T <- vcovHC(reg_tobit, type="HC")
cov_mat_T
coeftest(reg_tobit, cov_mat_T)

summary(reg_ols)
summary(reg_tobit)

【问题讨论】:

    标签: r statistics regression


    【解决方案1】:

    我们可以使用AER::tobit,帮助页面告诉我们“tobit 函数是 survreg 的便捷接口”,我们可以通过定义 "Surv" 对象(其中是困难的方式)。

    无论如何,survreg() 带来了 robust=TRUE 选项“使用稳健的‘三明治’标准误差,如果公式中没有 cluster() 项,则基于个体的独立性,如果有。” 并且robust=TRUE 也适用于AER::tobit(),因为它被传递给survreg()

    演示

    首先,我们说服自己,两种 tobit 方法给出相同的结果。

    library(censReg); library(AER)
    data("Affairs")
    
    fit.censReg <- censReg(frml, data=Affairs, right=4)
    fit.AER <- tobit(frml, data=Affairs, right=4, x=TRUE)
    stopifnot(all.equal(fit.censReg$estimate[1:6], fit.AER$coefficients))
    

    现在比较——首先没有稳健的标准错误:

    summary(tobit(frml, data=Affairs, right=4))$coefficients
    # Test of coefficients:
    #   
    #                Estimate Std. Error z value  Pr(>|z|)    
    # (Intercept)    7.900980   2.803855  2.8179 0.0048339 ** 
    # age           -0.177598   0.079906 -2.2226 0.0262441 *  
    # yearsmarried   0.532302   0.141168  3.7707 0.0001628 ***
    # religiousness -1.616336   0.424397 -3.8085 0.0001398 ***
    # occupation     0.324186   0.253878  1.2769 0.2016238    
    # rating        -2.207007   0.449832 -4.9063 9.281e-07 ***
    # Log(scale)     2.072319   0.110396 18.7717 < 2.2e-16 ***
    # ---
    # Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
    

    其次,具有稳健的标准误差:

    summary(tobit(frml, data=Affairs, right=4, robust=TRUE))$coefficients
    # Test of coefficients:
    #   
    #               Estimate Std. Error z value  Pr(>|z|)    
    # (Intercept)    7.90098    3.00928  2.6255 0.0086511 ** 
    # age           -0.17760    0.08684 -2.0451 0.0408424 *  
    # yearsmarried   0.53230    0.14457  3.6820 0.0002314 ***
    # religiousness -1.61634    0.43674 -3.7009 0.0002148 ***
    # occupation     0.32419    0.25338  1.2795 0.2007325    
    # rating        -2.20701    0.44971 -4.9076 9.218e-07 ***
    # Log(scale)     2.07232    0.11196 18.5088 < 2.2e-16 ***
    # ---
    # Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
    

    注意,sandwich::vcovCL() 函数实际上是为集群设计的。但是我们可以稍微“破解”它,并将单个观察结果作为集群给出,即行名。这适用于censReg()tobit()

    library(sandwich)
    coeftest(fit.AER, vcov.=vcovCL(fit.AER, cluster=rownames(Affairs), type="HC0"))
    # z test of coefficients:
    #   
    #                Estimate Std. Error z value  Pr(>|z|)    
    # (Intercept)    7.900980   3.011782  2.6234 0.0087068 ** 
    # age           -0.177598   0.086912 -2.0434 0.0410105 *  
    # yearsmarried   0.532302   0.144688  3.6790 0.0002342 ***
    # religiousness -1.616336   0.437101 -3.6979 0.0002174 ***
    # occupation     0.324186   0.253587  1.2784 0.2011075    
    # rating        -2.207007   0.450084 -4.9035 9.412e-07 ***
    # Log(scale)     2.072319   0.112057 18.4934 < 2.2e-16 ***
    # ---
    # Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
    
    # same
    coeftest(fit.censReg, vcov.=vcovCL(fit.censReg, cluster=rownames(Affairs), type="HC0"))
    

    可以看出,vcovCL 标准错误与AER::tobit(., robust=TRUE) 基本相同。

    【讨论】:

      猜你喜欢
      • 2020-05-16
      • 2014-05-02
      • 2011-05-22
      • 1970-01-01
      • 1970-01-01
      • 2013-08-20
      • 2018-11-15
      • 2021-12-25
      • 1970-01-01
      相关资源
      最近更新 更多