【问题标题】:appropriate test for significance of difference差异显着性的适当检验
【发布时间】:2020-10-03 12:20:06
【问题描述】:

我需要帮助进行假设检验来比较我在 Stata 中的两个解释变量的系数。我的 null 和替代方法是:

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

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

【问题讨论】:

    标签: statistics stata hypothesis-test


    【解决方案1】:

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

    • 对系数执行相应的双边检验(或者有时只查看回归输出)
    • 使用结果获取单侧检验的 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
    

    如果您的测试返回 r(chi2) 而不是 r(F),则需要将 ttail 部分换成

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

    【讨论】:

    • 感谢您的回复 Dimitriy,这对您很有帮助。如果可以的话,我有两件事想澄清一下。 1) 我运行测试命令并从 r(p) 得到一个 0.0001 的 p 值,这给了我一个大约 0.9999 的相应 p 值,因为我想测试 Ha diff>0 我是否将其解释为无法拒绝 null 支持 alt 差异是积极的? 2) 我的测试返回了 r(chi2) 。所以通过交换它你的意思是我应该使用 r(chi2) 而不是 r(F) 还是我需要使用 F 分布重新估计?
    • (1) 是的,押韵助记符是“当 p 值小时拒绝空值”,因为 p 值对应于在空值下观察到至少如此大的差异的概率.你可以在CV site 找到很多很好的例子,这是一个更好的地方来解决不涉及编程的统计问题。
    • 在 (2) 上,您想将 ttail 部分换成 -normal(`sign_diff'*sqrt(r(chi2)))-。
    猜你喜欢
    • 2013-01-09
    • 2012-08-30
    • 1970-01-01
    • 1970-01-01
    • 2021-12-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-07
    相关资源
    最近更新 更多