stata中两个平均值和中位数之间的差异

问题描述

我想将均值和中值差的 p 值从 stata 导出到乳胶。我尝试了下面的代码,它适用于均值的 p 值。但是,我不知道如何添加对中位数差异的分析。你能帮我解决这个问题吗?

eststo control: quietly estpost summarize a b c if treated == 0
eststo treated: quietly estpost summarize a b c if treated == 1
eststo diff: quietly estpost ttest a b c,by(treated) unequal
esttab using means_medians.tex,replace  mlabels("Treated" "Control" "Difference")  
cells("mean(pattern(1 1 0) fmt(2)) sd(pattern(1 1 0 ) fmt(3)) b(star pattern(0 0 1) fmt(2))") label

解决方法

您可以使用 epctile 作为适当的估计命令实现并返回 e(V) 和估计表。 (忽略第一部分中丑陋的输出。我大约在 10 年前为一个特定项目编写了它,但似乎我从来没有把它做得足够适合一般用途。)

. sysuse auto,clear
(1978 Automobile Data)

. epctile mpg,p(50)

Mean estimation                   Number of obs   =         74

--------------------------------------------------------------
             |       Mean   Std. Err.     [95% Conf. Interval]
-------------+------------------------------------------------
    __000006 |   -.027027    .058435     -.1434878    .0894338
--------------------------------------------------------------

Percentile estimation
------------------------------------------------------------------------------
         mpg |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         p50 |         20        .75    26.67   0.000     18.53003    21.46997
------------------------------------------------------------------------------

此命令不在 SSC 上,它在我的页面上,因此要安装它,请按照 findit epctile 中的提示进行操作。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...