[R] Confidence Interval for p1-p2 and plot the CI with bar chart

AbouEl-Makarim Aboueissa @boue|m@k@r|m1962 @end|ng |rom gm@||@com
Sun Nov 14 01:00:28 CET 2021

Dear All:

I do have a binary data set with multiple variables, event = 1 in all
variables. As an example, I attached a data set with 6 variables. The first
column is the grouping variable. Then the next 5 columns are the binary
data for 5 variables.

- Can we compute the confidence interval for the difference between the two
proportions of the event = 1 in both groups (say: G1 – G2) for the 5
variables in one shut.

- I also need to create the Bar plot of individual proportions (both groups
side-by-side) and add the confidence intervals bar for the 5 variables in
one graph.

Example.Data <- read.table(file="F/Example_Data_for_R.csv", header=T,



#### For example, this is how I use the prop.test() function to get the CI
for p1-p2

x12 <- c(x1, x2)

n12 <- c(n1, n2)

prop.test(x12, n12, conf.level = 0.95)$conf.int

But, I am not sure how to use it for raw data, and for multiple pairs of
data in one shut if possible.

With many thanks in advance


*AbouEl-Makarim Aboueissa, PhD*

*Professor, Statistics and Data Science*
*Graduate Coordinator*

*Department of Mathematics and Statistics*
*University of Southern Maine*

More information about the R-help mailing list