Interval estimation of difference in independent proportions
Source:    Publish Time: 2012-08-23 06:53   4099 Views   Size:  16px  14px  12px
Author: Xuanqian Xie   1.To calculate 95%CI manually using the Wald method.   /*Method=Wald*/ data wal

Author: Xuanqian Xie

 

1.To calculate 95%CI manually using the Wald method.

 

/*Method=Wald*/

data wald;

E0=12; EN0=30; N0= E0+ EN0;

E1=20; EN1=30; N1= E1+ EN1;

 

se=sqrt(((e0/n0)*(1-e0/n0)*1/N0) + ((e1/n1)*(1-e1/n1)*1/N1));

Estimate=(e1/n1) - (e0/n0);

low_cl=     (e1/n1- e0/n0)- 1.96* se;

up_cl=      (e1/n1- e0/n0)+ 1.96* se;

 

put "Estimate=" Estimate;

put "low_cl=" low_cl=;

put "up_cl=" up_cl;

run;

 

Estimate=0.1142857143

low_cl=low_cl=-0.078344363

up_cl=0.3069157915

 

 

2.Using the SAS options, “Method=Wald”.

 

                                     Column 2 Risk Estimates

 

                                                (Asymptotic) 95%         (Exact) 95%

                            Risk        ASE     Confidence Limits     Confidence Limits

          ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ

          Row 1           0.6000     0.0693     0.4642     0.7358     0.4518     0.7359

          Row 2           0.7143     0.0697     0.5777     0.8509     0.5542     0.8428

          Total           0.6522     0.0497     0.5549     0.7495     0.5457     0.7485

 

          Difference     -0.1143     0.0983    -0.3069     0.0783    -0.3118     0.0916

 

                                  Difference is (Row 1 - Row 2)

 

 

                                Proportion (Risk) Difference Test

                                         H0: P1 - P2 = 0

 

                                Proportion Difference     -0.1143

                                ASE (Sample)               0.0983

                                Z                         -1.1629

                                One-sided Pr <  Z          0.1224

                                Two-sided Pr > |Z|         0.2449

 

                                         Sample Size = 92

 

 

data test;

input results $2. group $4. count ;

datalines;

P VCE  20

N VCE  30

P CTE  12

N CTE  30

;

 

/*Method=Wald*/

proc freq data=test order=data ;

    table  group * results  /riskdiff (Method=Wald EQUAL) ;

    weight count;

      exact  RISKDIFF ;

run;

 

 

3.  The Exact method for small sample size.

 

 

                                     Column 1 Risk Estimates

 

                                                (Asymptotic) 95%         (Exact) 95%

                            Risk        ASE     Confidence Limits     Confidence Limits

          ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ

          Row 1           0.3571     0.1281     0.0704     0.6439     0.1276     0.6486

          Row 2           0.0000     0.0000     0.0000     0.0357     0.0000     0.2316

          Total           0.1786     0.0724     0.0189     0.3383     0.0606     0.3689

 

          Difference      0.3571     0.1281     0.0347     0.6796    -0.0470     0.6824

 

                                  Difference is (Row 1 - Row 2)

                The asymptotic confidence limits include a continuity correction.

 

 

                                Proportion (Risk) Difference Test

                                         H0: P1 - P2 = 0

 

                                Proportion Difference      0.3571

                                ASE (Sample)               0.1281

                                Z                          2.2311

                                One-sided Pr >  Z          0.0128

                                Two-sided Pr > |Z|         0.0257

 

                            The test includes a continuity correction.

 

The “CORRECT” option specifies that the continuity correction

proc freq data=aa  order=data;

    where study="SBM";

    table group * results  /all riskdiff (Method=wald equal correct) measures;

    weight count;

      exact  RISKDIFF ;

      output out=SBM_1 RISKDIFF;

      title "SBMRI";

run;

 

4.The Wilson score method / newcombe or corrected Newcombe interval

SAS 9.3 has the options of the Wilson score method for estimating 95%CI, while SAS called it as “newcombe” method. Please note the earlier version of SAS without this option.   

proc freq data=VCE3 order=data;

weight count;

tables treat*outcome / riskdiff(cl=( newcombe) correct norisks);

exact riskdiff(fmscore);

run;

 

The following 2 articles have further discussion of 95% CI of 2 proportions.

Newcombe, R. G. (1998), “Interval Estimation for the Difference Between Independent Proportions: Comparison of Eleven Methods,” Statistics in Medicine, 17, 873–890.

 

Stokes M, Up To Speed With Categorical Data Analysis, Paper 346-2011, SAS Global Forum 2011