R vs SAS Confidence Intervals for Proportions

Introduction

There are several ways to calculate a confidence interval (CI) for a proportion. You need to select the method based on if you have a 1 sample proportion (1 proportion calculated from 1 group of subjects), or if you have 2 samples and you want a CI for the difference in the 2 proportions. The difference in proportion can come from either 2 independent samples (different subjects in each of the 2 groups), or can be matched (the same subject with 1 result in 1 group and 1 result in the other group [paired data]).

The method selected is also dependent on whether your proportion is close to 0 or 1 (or near to the 0.5 midpoint), and your sample size.

For more technical derivation and reasons for use for each of the methods listed below, see the corresponding SAS page.

General Comparison Table For Single Sample Proportions

The following table provides an overview of the results comparing between R and SAS for Single Sample Proportions and independent 2 sample proportions . See the corresponding SAS page and R page for results showing a single set of data run through both SAS and R.

Analysis of One Sample Proportion Supported in R Supported in SAS Results Match
Clopper-Pearson Exact Yes {cardx} Yes (default) Yes
Normal approximation (Wald Method) Yes {cardx} Yes (default) Yes
Normal approximation (Wald Method) with continuity correction Yes {cardx} Yes Yes
Wilson (Score, Altman, Newcombe) method Yes {cardx} Yes Yes
Wilson (Score, Altman, Newcombe) method with continuity correction Yes {cardx} Yes Yes
Agresti Coull Yes {cardx} Yes Yes
Jeffreys Bayesian HPD Yes {cardx} Yes Yes
midp Yes {PropCIs} Yes results match to the 3rd decimal place
Blaker Yes {PropCIs} Yes results match to the 5th decimal place
Wilson Stratified score Yes {cardx} No NA

General Comparison Table For Two Independent Samples Proportions

Analysis of Two independant Sample Proportions Supported in R Supported in SAS Results Match
Normal approximation (Wald Method) Yes {cardx} ard_stats_prop_test function uses stats::prop.test Yes (default) Yes, but documentation for stats::prop.test says it’s using newcombe method so more research needed given results match wald method?
Normal approximation (Wald Method) with continuity correction Yes {cardx} ard_stats_prop_test function uses stats::prop.test Yes Unknown.
Wilson (Score, Altman, Newcombe) method Unknown - more research needed Yes SAS results match by hand calculation
Wilson (Score, Altman, Newcombe) method with continuity correction Unknown - more research needed Yes SAS results match by hand calculation

Prerequisites: R Packages

See the R page for more detail.

# Example R packages required
library(cardx)