I have 10 samples which has males and females. I want to check whether the sex ratios in any of these sample are significantly different from other. Can someone please help me what test can I use in R to find this?
2 Answers
First, note that ratios being different is equivalent to proportions being different. So you need to test for different proportions.
Here is the null hypothesis - $H_0: p_1 = p_2 = p_3 = ...$ - and the alternative hypothesis is simply that one proportion does not equal one of the others.
Let $X_i = $ the number of males in group i and $n_i = $ the number of people in group i. Under the null hypothesis of one common probability, we can estimate the probability someone is male: $\bar p = \frac{\sum{X_i}} {\sum{n_i}}$.
Define $\hat X_i$ to be our expectation of what $X_i$ should be under the null hypothesis: $\hat X_i = \bar p * n_i$.
Given large sample sizes, $X_i$ is approximately normally distributed. If $X_i$ is normally distributed, then the following test statistic is chi-squared distributed with 9 (number of groups minus 1) degrees of freedom: $\chi ^ 2 = \sum{\frac{(X_i - \hat X_i)^2} {\hat X_i}}$. If the test statistic exceeds the critical value, the null hypothesis can be rejected. In this example, you need a statistic of at least 16.919 to reject at .05 significance.
See here - http://www.itl.nist.gov/div898/handbook/prc/section4/prc46.htm - for an example.
As Wart has pointed out, the $\chi^2$ test for homogeneity (i.e. independence) is a good way to proceed in this situation. In R, this can be done with the command
chisq.test(mytable)
glm
(with the Binomial family) andanova
(following examples in their help pages)--but that approach can fail for small samples and will be inappropriate for testing all differences. In light of this, please edit the post to clarify your situation. $\endgroup$