在命令nlcom之后检索标准错误

时间:2014-04-17 20:48:17

标签: stata

在Stata中,命令nlcom使用delta方法来测试关于估计系数的非线性假设。该命令在结果窗口中显示标准错误,但遗憾的是不能将它们保存在任何地方。

估算后可用的是矩阵r(V),但我无法弄清楚如何使用它来计算标准误差。

2 个答案:

答案 0 :(得分:3)

显然你需要取r(V)对角元素的平方根。这是一种将标准误差作为变量返回到一个观测数据集中的方法。

sysuse auto, clear
reg mpg weight turn
nlcom (v1: 1/_b[weight]) (v2: _b[weight]/_b[turn])
mata: se = sqrt(diagonal(st_matrix("r(V)")))'
clear
getmata (se1 se2 ) = se /* supply names as needed */
list

答案 1 :(得分:2)

您需要使用post选项,如下所示:

. sysuse auto
(1978 Automobile Data)

. reg price mpg weight 

      Source |       SS       df       MS              Number of obs =      74
-------------+------------------------------           F(  2,    71) =   14.74
       Model |   186321280     2  93160639.9           Prob > F      =  0.0000
    Residual |   448744116    71  6320339.67           R-squared     =  0.2934
-------------+------------------------------           Adj R-squared =  0.2735
       Total |   635065396    73  8699525.97           Root MSE      =    2514

------------------------------------------------------------------------------
       price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         mpg |  -49.51222   86.15604    -0.57   0.567    -221.3025     122.278
      weight |   1.746559   .6413538     2.72   0.008      .467736    3.025382
       _cons |   1946.069    3597.05     0.54   0.590    -5226.245    9118.382
------------------------------------------------------------------------------

. nlcom ratio: _b[mpg]/_b[weight], post

       ratio:  _b[mpg]/_b[weight]

------------------------------------------------------------------------------
       price |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       ratio |  -28.34844   58.05769    -0.49   0.625    -142.1394    85.44254
------------------------------------------------------------------------------

. di _se[ratio]
58.057686

此标准误差是方差矩阵r(V)的条目的平方根:

. matrix list r(V)

symmetric r(V)[1,1]
           ratio
ratio  3370.6949

. di sqrt(3370.6949)
58.057686