# Hypothesis testing equality of parameters in MORE than 2 Bernoulli populations

I am giving the number of trials and number of successes for 4 Bernoulli samples.

I want to test the null hypothesis that p1 = p2 = p3 = p4 versus the alternative hypothesis that pi != pj for any i and j between 1 and 4. (px is the probability of success for population x)

How do I go about this? I only understand how to do this with two populations.

You can use Pearson's chi-squared test to do this. See

A test of homogeneity compares the distribution of counts for two or more groups using the same categorical variable (e.g. choice of activity—college, military, employment, travel—of graduates of a high school reported a year after graduation, sorted by graduation year, to see if number of graduates choosing a given activity has changed from class to class, or from decade to decade).[3]

Code example:

 #fake data

nl <- c(20,25,30,20) # sample size
pl1 <- c(0.2,0.3,0.4,0.5) # diffrent p
pl2 <- c(0.3,0.3,0.3,0.3) # same p

tab1 <- sapply(1:4,function(i){
s <- sum(rbinom(nl[i],1,pl1[i]))
return(c(nl[i]-s,s))
})
tab2 <- sapply(1:4,function(i){
s <- sum(rbinom(nl[i],1,pl2[i]))
return(c(nl[i]-s,s))
})

tab1
#     [,1] [,2] [,3] [,4]
#[1,]   19   19   24    8
#[2,]    1    6    6   12

# testing
chisq.test(tab1) # p-value = 0.0006819
chisq.test(tab2) # p-value = 0.8818