【发布时间】:2018-12-03 16:29:44
【问题描述】:
在 Stata 中,命令 nlcom 使用 delta 方法来检验关于估计系数的非线性假设。该命令在结果窗口中显示标准错误,但遗憾的是没有将它们保存在任何地方。
估计后可用的只是矩阵r(V),但我不知道如何使用它来计算标准误差。
【问题讨论】:
标签: stata
在 Stata 中,命令 nlcom 使用 delta 方法来检验关于估计系数的非线性假设。该命令在结果窗口中显示标准错误,但遗憾的是没有将它们保存在任何地方。
估计后可用的只是矩阵r(V),但我不知道如何使用它来计算标准误差。
【问题讨论】:
标签: stata
您需要使用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
【讨论】:
sysuse autoreg price mpg weightnlcom ratio: _b[mpg]/_b[weight]mat se = r(V)di sqrt(round(se[1,1]))
post 不需要用nlcom 回答这个问题。无论如何,@NickCox 和 @PearlySpencer 没有分享我的观点 -;)!
显然你需要对 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
【讨论】: