零假设检验

时间:2021-04-18 16:51:43

标签: stata

我运行了一个回归并得到了一条看起来像这样的估计回归线(其中 a*b 是交互项)

Y=B+B1*a+B2*b+B3*a*b 

我想找到检验零假设的 p 值,即当 a=2 时,'b' 对 'Y' 的影响为零。

我知道 F-test 可以工作,但我不知道如何在命令中包含 a=2。我在想类似的事情

test b b*a if a ==2

但这不起作用。

1 个答案:

答案 0 :(得分:1)

如果我们有一个这样的模型:

enter image description here

我们可以通过对 X1 取偏导数来得到 X1 对 Y 的影响:

enter image description here

如果我们想知道X2为2时X1对y的影响,我们只需将X2填入2即可。然后,我们剩下一个简单的线性组合,可以通过 lincommargins 计算(margins 是推荐的方法)。

. sysuse auto
(1978 Automobile Data)

. qui reg price c.mpg##c.weight

. margins, dydx(mpg) at(weight = 2)

Average marginal effects                        Number of obs     =         74
Model VCE    : OLS

Expression   : Linear prediction, predict()
dy/dx w.r.t. : mpg
at           : weight          =           2

------------------------------------------------------------------------------
             |            Delta-method
             |      dy/dx   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         mpg |    396.401   185.0749     2.14   0.036     27.28083    765.5212
------------------------------------------------------------------------------

. lincom mpg + c.mpg#c.weight * 2

 ( 1)  mpg + 2*c.mpg#c.weight = 0

------------------------------------------------------------------------------
       price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |    396.401   185.0749     2.14   0.036     27.28083    765.5212
------------------------------------------------------------------------------