1

我想获得两个比例差异的置信区间。

例如

webuse highschool
tab race sex, col chi2


  1=white, |
  2=black, |   1=male, 2=female
   3=other |      male     female |     Total
-----------+----------------------+----------
     White |     1,702      1,850 |     3,552 
           |     87.82      86.73 |     87.25 
-----------+----------------------+----------
     Black |       201        249 |       450 
           |     10.37      11.67 |     11.05 
-----------+----------------------+----------
     Other |        35         34 |        69 
           |      1.81       1.59 |      1.69 
-----------+----------------------+----------
     Total |     1,938      2,133 |     4,071 
           |    100.00     100.00 |    100.00 

      Pearson chi2(2) =   1.9652   Pr = 0.374

白人男性和女性的比例差异为 87.82 - 86.73 = 1.09,我想要这个差异的置信区间。

4

2 回答 2

2

prtest命令是您所需要的:prtest sex, by(race). 您的变量不应包含两个以上的组。

webuse highschool
tab race sex, col chi2

// dummies
gen is_black = (race == 2) if race < 3
gen is_female = (sex == 2) if !mi(sex)

// proportions test
prtest is_female, by(is_black)
于 2013-05-17T17:26:10.690 回答
1

您可以使用直接形式的-prtest-代替,即-prtesti-.

缺点是您必须手动输入计数和比例:

用你的例子:

prtesti 1702 0.8782 1850 0.8673

Two-sample test of proportions                     x: Number of obs =     1702
                                                   y: Number of obs =     1850
------------------------------------------------------------------------------
    Variable |       Mean   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
           x |      .8782   .0079276                      .8626622    .8937378
           y |      .8673   .0078874                       .851841     .882759
-------------+----------------------------------------------------------------
        diff |      .0109   .0111829                     -.0110181    .0328181
             |  under Ho:   .0112015     0.97   0.331
------------------------------------------------------------------------------
        diff = prop(x) - prop(y)                                  z =   0.9731
    Ho: diff = 0

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(Z < z) = 0.8347         Pr(|Z| < |z|) = 0.3305          Pr(Z > z) = 0.1653
于 2013-05-20T07:41:33.923 回答