# How to calculate the sample size for a categorical independent variable with a dichotomous dependent variable

Suppose that in a large population group you have 5 different ethnic groups, and you wish to calculate the prevalence of a disease in each ethnicity(percentage of people in each ethnic group having that disease).

How would I calculate the ideal sample size to compare the prevalence between ethnic groups.

The estimated prevalence of the disease is ~20% overall.

We should be able to detect a prevalence difference of about 25% between odds ratios.

• For this type of calculation, you need to specify estimates of the disease prevalence (ideally, for each of the ethnicities) and how big a difference in prevalence you would like to be able to detect. Please edit your question to add those details. – EdM Dec 16 '19 at 20:43

This will have to be a fairly large study, in addition to the difficulties of assuring (1) representative sampling of the ethnic groups and (2) correct estimation of prevalences within each group (e.g., if those without disease aren't adequately represented in samples taken from clinicians' records). You need to be working with a statistician trained in epidemiology to do this correctly.

For an idea of the scale involved, consider finding the difference you propose between just 2 groups. You propose a baseline probability of disease of 0.2, which we will call $$\pi_0$$. That corresponds to an odds ratio of 0.25. You would like to distinguish this from an odds ratio that is 25% different, an odds ratio of 0.3125 that corresponds to a probability of disease of about 0.24, which we will call $$\pi_1$$.

There's a rule of thumb for the sample size needed to distinguish such a difference in such binomial proportions, for 80% power to detect a difference at p < 0.05. If $$\bar\pi$$ is the average between the 2 probabilities and the 2 groups have the same size $$N$$, then you need about

$$N \approx \frac{16 \bar\pi (1-\bar\pi)}{(\pi_0-\pi_1)^2}$$

or over 1700 in each group. More exact calculations are provided by statistical analysis programs; I got a value of 1850 in each group with G*Power. The total number required will be higher if the 2 groups aren't equal in size, as there will be more uncertainty for the value in the lower-sized group.

With multiple groups and potentially different numbers sampled from each group you might be best off examining a range of specific reasonable scenarios for outcomes as alternative hypotheses for estimating sample sizes. The classic test for determining whether there are any differences in a binary outcome among multiple groups is the chi-square test, for a 2 (disease status) x 5 (ethnic groups) table in your case.

For chi-square test sample-size determination, you could for example use the pwr package in R to hypothesize different probabilities within each of the 10 cells of the table (all probabilities summing to 1; these probabilities would include differences in numbers sampled among ethnic groups and their different probabilities of disease), calculate the associated effect size with its ES.w2() function, and then use that effect size in the pwr.chisq.test() function to determine the number of total cases needed to achieve the desired power, over a range of scenarios.

Again, this is a sufficiently challenging problem that you need experienced statistical help. Such a person should be able to work with you not only on sample-size determination but also on the sampling difficulties noted in the first paragraph.