# Comparing median of groups within many clusters

I have the gender composition for thousands of boards (there is no sampling involved. The data set contains all boards). Boards are consisted of different number of male and female directors. So, to fix things, boards are clusters, and within each cluster there are two groups of male and female directors. What I want to do is to examine how older the median male director in each board is than the median female director in that board, to estimate a confidence interval for this difference, and to comment on its significance by bootstrapping. My question is on how this should be tackled. more specifically:

1. I guess, as I stated, it is the difference in medians which needs to be calculated in here, and not the median of differences, correct? This is as, the male and female directors are nested in each board and are thus should be compared within boards.

2. Would report the median of these difference in medians then? or can I use mean of difference in medians?

3. Suppose that I have ended up with 1000 difference in medians. What I need to do, is to resample with replacement 1000 rounds, samples of size 1000 from the original 1000 observations, and in each round save the median, and finally to report the .05 and .95 quantiles as the confidence interval. Correct?

4. Though the data has nested structure, it doesn't matter for my bootstrapping, in other words, I don't need to resample directors in boards, correct?

• What question are you trying to answer by this? Why are you using clustering? What problem does the clustering "fix"?
– Tim
Commented Dec 6, 2022 at 14:50
• The question is simply the age difference in males and females. The data is simply clustered. The intraclass correlation is over .55 which means that the clustered nature of data should be taken into account in analysis. In other words males and females in the same board be compared to one another and not simply males and females Commented Dec 6, 2022 at 21:41

For each board $$b$$, you can calculate the median age of male directors minus the median age of female directors. Call the difference $$d_b$$, and suppose you have $$n$$ such differences. For a first approximation, those $$n$$ differences are the only data you need — you don’t need other data on individual ages or on single-sex boards.
If the $$d_b$$ are roughly normal, then you can report their mean and its confidence intervals in the usual way.
If the $$d_b$$ are not normally distributed, you can still get a confidence interval for their median, with confidence $$p$$, using the $$(1-p)/2$$ and $$(1+p)/2$$ percentiles of the $$B((1+n)/2,(1+n)/2)$$ distribution. E.g. in R we might calculate them as qbeta((1-p)/2, (n+1)/2, (n+1)/2) and qbeta((1+p)/2, (n+1)/2, (n+1)/2).
If those percentiles are $$L$$ and $$M$$, then with confidence $$p$$, the sample median of the $$d_b$$ will be between the $$L$$ and $$M$$ quantiles of the distribution of $$d_b$$.