差异显着性的适当检验

appropriate test for significance of difference

我需要帮助进行假设检验,以比较我在 Stata 中的两个解释变量的系数。我的 null 和备选方案是:

null:β1=β2 vs alt:β1>β2。

到目前为止,我已经使用命令test 来比较这两个估计值。但是,我不知道是否可以修改 test 以适合我的 alt。

要对系数进行单侧检验,您可以

  • 对系数进行相应的双侧检验(或者有时只看回归输出)
  • 使用结果获得单侧检验的 p 值。这一步可以通过两种方式完成,要么直接使用反向累积学生 t 分布,要么对双侧检验的 p 值进行一些算术运算。

如果您要测试系数的差异(因为 a=b 等同于 a-b=0),方法与测试单个系数相同。你需要做一个双面的差异检验:

sysuse auto, clear
regress price mpg weight 
gen high_mpg    = mpg>20
gen high_weight = weight>3000
reg price high_mpg high_weight foreign 

/* Test H0: diff = 0 */
test high_weight - foreign = 0
display r(p)
display r(F)

/* The ttail approach works when the actual coefficient difference is positive or negative */
local sign_diff = sign(_b[high_weight] - _b[foreign] - 0)
display "p-value for Ha: diff < 10 = " ttail(r(df_r),`sign_diff'*sqrt(r(F)))
display "p-value for Ha: diff > 10 = " 1-ttail(r(df_r),`sign_diff'*sqrt(r(F)))

/* Can also do it by hand like this if diff is positive (like above) */
display "p-value for Ha: diff < 0 = " r(p)/2 
display "p-value for Ha: diff > 0 = " 1-r(p)/2 

/* if difference is negative, you can still do it by hand */
/* but need to flip the p-value division rules since we are on the other */
/* side of the distribution */
/* Test H0': diff2 = -400 */ 
test high_mpg - foreign  = -400
local sign_diff2 = sign(_b[high_mpg] - _b[foreign] + 400)
display "p-value for Ha': diff2 < 0 = " ttail(r(df_r),`sign_diff2'*sqrt(r(F)))
display 1-r(p)/2
display "p-value for Ha': diff2 > 0 = " 1-ttail(r(df_r),`sign_diff2'*sqrt(r(F)))
display r(p)/2

如果你的测试 returns r(chi2) 而不是 r(F),你需要将 ttail 部分换成

normal(`sign_diff'*sqrt(r(chi2)))