I have a dataset including two groups of individuals. I get the median of a measurement (say weight) for each group, say W1 and W2 for group 1 and 2, and then get the ratio of the medians W1/W2. How can I test whether the ratio W1/W2 differs from one using bootstrap?

Please do not offer alternative methods to compare weights of the two groups such as t-test or wilcoxon test; I use weight here just for simple description.

  • $\begingroup$ Are you just asking how to use the bootstrap to test a hypothesis? $\endgroup$ Jun 18, 2015 at 16:36
  • $\begingroup$ @gung, not really, but bootstrap is the only I can think of for this test. Please let me know if you have different ways to test a ratio. Thanks. $\endgroup$
    – ZZG
    Jun 19, 2015 at 2:42

1 Answer 1


Set $\alpha=0.05$. Suppose there are $n_1$ and $n_2$ people in groups $1$ and $2$ respectively. Calculate $\frac{M_1}{M_2}_{obs}$ from your data. The hypotheses are: $$H_0: \frac{M_1}{M_2} = 1$$ $$H_a: \frac{M_1}{M_2} \neq 1$$

First ensure that the medians of both groups are equal. Draw a bootstrap sample of size $n_1$ from group $1$ and a bootstrap sample of size $n_2$ from group $2$. Calculate $\frac{M_{1}^{*}}{M_{2}^{*}}$ from these samples and repeat for $1000$ times. The $p$-value is:

$$ \text{p-value} = \frac{\text{number of times} \frac{M_{1}^{*}}{M_{2}^{*}} > \frac{M_1}{M_{2}}_{obs} \ \text{and number of times} \ \frac{M_{1}^{*}}{M_{2}^{*}} < \frac{M_1}{M_{2}}_{obs}}{1000}$$

If $p < 0.05$ then reject $H_0$.

  • $\begingroup$ Your solution always gets a p-value = 1, because one of the two relationships $M^∗_1/M^∗_2 > M_1/M_2$ and $M^∗_1/M^∗_2 < M_1/M_2$ must be always true, because of noise, the equality rarely appears. $\endgroup$
    – ZZG
    Jun 19, 2015 at 2:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.