【问题标题】:Using rdrobust to calculate 2sls and getting error message stating "should be set within the range of x"使用 rdrobust 计算 2sls 并收到错误消息“应设置在 x 的范围内”
【发布时间】:2021-11-27 19:38:35
【问题描述】:

我正在尝试在 Stata 中计算两阶段最小二乘法。我的数据集如下所示:

income bmi  health_index asian black q_o_l age  aide
100    19   99           1     0     87    23   1
0      21   87           1     0     76    29   0
1002   23   56           0     1     12    47   1
2200   24   67           1     0     73    43   0
2076   21   78           1     0     12    73   1

我正在尝试使用rdrobust 来估计治疗效果。我使用了以下代码:

rdrobust q_o_l aide health_index bmi income asian black age, c(10)

我用多种多项式形式改变了income 变量,并使用了多种带宽。我不断收到相同的错误消息:

c() should be set within the range of aide

我假设这与带宽有关。我该如何纠正?

【问题讨论】:

  • 错误消息似乎与您的变量-aide-有关。

标签: statistics stata


【解决方案1】:

语法有两个问题。你写道:

rdrobust q_o_l aide health_index bmi income asian black age, c(10)

这将忽略 health_index-age 变量,因为您只能有一个运行变量。然后它将尝试使用 10 的截止值作为辅助(第二个变量始终是运行变量)。由于助手是二进制的,因此 Stata 抱怨。

对我来说,在您的设置中什么是有意义的并不明显,但这里有一个示例说明问题和两种补救措施:

. use "http://fmwww.bc.edu/repec/bocode/r/rdrobust_senate.dta", clear

. rdrobust vote margin, c(0) covs(state year class termshouse termssenate population)

Covariate-adjusted sharp RD estimates using local polynomial regression.

      Cutoff c = 0 | Left of c  Right of c            Number of obs =       1108
-------------------+----------------------            BW type       =      mserd
     Number of obs |       491         617            Kernel        = Triangular
Eff. Number of obs |       309         279            VCE method    =         NN
    Order est. (p) |         1           1
    Order bias (q) |         2           2
       BW est. (h) |    17.669      17.669
       BW bias (b) |    28.587      28.587
         rho (h/b) |     0.618       0.618

Outcome: vote. Running variable: margin.
--------------------------------------------------------------------------------
            Method |   Coef.    Std. Err.    z     P>|z|    [95% Conf. Interval]
-------------------+------------------------------------------------------------
      Conventional |  6.8862     1.3971   4.9291   0.000    4.14804      9.62438
            Robust |     -          -     4.2540   0.000    3.78697       10.258
--------------------------------------------------------------------------------
Covariate-adjusted estimates. Additional covariates included: 6

. sum margin

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
      margin |      1,390    7.171159    34.32488       -100        100

. rdrobust vote margin state year class termshouse termssenate population, c(7)    // margin rang
> es from -100 to 100

Sharp RD estimates using local polynomial regression.

      Cutoff c = 7 | Left of c  Right of c            Number of obs =       1297
-------------------+----------------------            BW type       =      mserd
     Number of obs |       744         553            Kernel        = Triangular
Eff. Number of obs |       334         215            VCE method    =         NN
    Order est. (p) |         1           1
    Order bias (q) |         2           2
       BW est. (h) |    14.423      14.423
       BW bias (b) |    24.252      24.252
         rho (h/b) |     0.595       0.595

Outcome: vote. Running variable: margin.
--------------------------------------------------------------------------------
            Method |   Coef.    Std. Err.    z     P>|z|    [95% Conf. Interval]
-------------------+------------------------------------------------------------
      Conventional |   .1531     1.7487   0.0875   0.930   -3.27434      3.58053
            Robust |     -          -     -0.0718  0.943   -4.25518      3.95464
--------------------------------------------------------------------------------

. rdrobust vote margin state year class termshouse termssenate population, c(-100) // nonsensical
>  cutoff for margin
c() should be set within the range of margin
r(125);

end of do-file

r(125);

您可能还会觉得this answer 很有趣。

【讨论】:

    猜你喜欢
    • 2014-05-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多