10
$\begingroup$

I have a sample of 250 units. The distribution is asymmetric. I want to test a hypothesis that the median of the population is different from 3.5, so I think a one-sample test would be appropriate. I know that the Wilcoxon rank test is not appropriate because the distribution is not symmetric. Is a sign test appropriate to use? If it is not can anyone recommend any other test?

$\endgroup$
5
  • 3
    $\begingroup$ You lost me at the first line, for several reasons. (1) A sample cannot have a Gaussian distribution (but it can approximately have one). (2) One characteristic of all Gaussian distributions (and therefore of approximations to them) is symmetry. You have contradicted yourself. By describing your data in your own terms, rather than statistical jargon, you will better communicate what you have. Could you also explain, in as plain a manner as possible, what you really want to accomplish with your data? What kind of information is a "sample test based on median" intended to give you? $\endgroup$
    – whuber
    Commented Jan 6, 2015 at 21:04
  • 1
    $\begingroup$ The median of the sample is whatever it is; there would be no need to test that. Perhaps you want to test whether the median of the population (from which the sample is obtained) equals $3.5$? If so, it is important to know how the value of $3.5$ was developed. Is it a summary of some other dataset, perhaps? Or is it some predetermined number, such as a quality standard? $\endgroup$
    – whuber
    Commented Jan 6, 2015 at 22:14
  • 1
    $\begingroup$ It is a predetermined number $\endgroup$
    – LeonRupnik
    Commented Jan 6, 2015 at 22:33
  • 2
    $\begingroup$ "Distribution is asymmetric so I want to test a hypothesis if a median of a population is different from 3.5..." -- Why would asymmetry in a sample impact what hypothesis is interesting? $\:$ "Is a sign test appropriate to use?" -- sure, but (at least in the original form) it relies on continuity - you need to adapt it if your variable is discrete (you don't say what your data consist of). $\endgroup$
    – Glen_b
    Commented Jan 6, 2015 at 23:42
  • $\begingroup$ The data is continuous $\endgroup$
    – LeonRupnik
    Commented Jan 7, 2015 at 9:12

1 Answer 1

10
$\begingroup$

Synopsis

The count of data exceeding $3.5$ has a Binomial distribution with unknown probability $p$. Use this to conduct a Binomial test of $p=1/2$ against the alternative $p\ne 1/2$.

The rest of this post explains the underlying model and shows how to perform the calculations. It provides working R code to carry them out. An extended account of the underlying hypothesis testing theory is provided in my answer to "What is the meaning of p-values and t-values in statistical tests?".

The statistical model

Assuming the values are reasonably diverse (with few ties at $3.5$), then under your null hypothesis, any randomly sampled value has a $1/2=50\%$ chance of exceeding $3.5$ (since $3.5$ is characterized as the middle value of the population). Assuming all $250$ values were randomly and independently sampled, the number of them exceeding $3.5$ will therefore have a Binomial$(250,1/2)$ distribution. Let us call this number the "count," $k$.

On the other hand, if the population median differs from $3.5$, the chance of a randomly sampled value exceeding $3.5$ will differ from $1/2$. This is the alternative hypothesis.

Finding a suitable test

The best way to distinguish the null situation from its alternatives is to look at the values of $k$ that are most likely under the null and less likely under the alternatives. These are the values near $1/2$ of $250$, equal to $125$. Thus, a critical region for your test consists of values relatively far from $125$: close to $0$ or close to $250$. But how far from $125$ must they be to constitute significant evidence that $3.5$ is not the population median?

In depends on your standard of significance: this is called the test size, often termed $\alpha$. Under the null hypothesis, there should be close to--but not more than--an $\alpha$ chance that $k$ will be in the critical region.

Ordinarily, when we have no preconceptions about which alternative will apply--a median greater or less than $3.5$--we try to construct the critical region so that there is half of that chance, $\alpha/2$, that $k$ is low and the other half, $\alpha/2$, that $k$ is high. Because we know the distribution of $k$ under the null hypothesis, this information is enough to determine the critical region.

Technically, there are two common ways to carry out the calculation: compute the Binomial probabilities or approximate them with a Normal distribution.

Calculation with binomial probabilities

Use the percentage point (quantile) function. In R, for instance, this is called qbinom and would be invoked like

alpha <- 0.05 # Test size
c(qbinom(alpha/2, 250, 1/2)-1, qbinom(1-alpha/2, 250, 1/2)+1)

The output for $\alpha=0.05$ is

109 141

It means that the critical region comprises all the low values of $k$ between (and including) $0$ and $109$, together with all the high values of $k$ between (and including) $141$ and $250$. As a check, we can ask R to calculate the chance that k lies in that region when the null is true:

pbinom(109, 250, 1/2) + (1-pbinom(141-1, 250, 1/2))

The output is $0.0497$, very close to--but not greater than--$\alpha$ itself. Because the critical region must end at a whole number, it is not usually possible to make this actual test size exactly equal to the nominal test size $\alpha$, but in this case the two values are very close indeed.

Calculation with the normal approximation

The mean of a Binomial$(250, 1/2)$ distribution is $250\times 1/2=125$ and its variance is $250\times 1/2\times (1-1/2) = 250/4$, making its standard deviation equal to $\sqrt{250/4}\approx 7.9$. We will replace the Binomial distribution with a Normal distribution. The standard Normal distribution has $\alpha/2=0.05/2$ of its probability less than $-1.95996$, as computed by the R command

qnorm(alpha/2)

Because Normal distributions are symmetric, it also has $0.05/2$ of its probability greater than $+1.95996$. Therefore the critical region consists of values of $k$ that are more than $1.95996$ standard deviations away from $125$. Compute these thresholds: they equal $125 \pm 7.9\times 1.96 \approx 109.5, 140.5$. The calculation can be carried out in one swoop as

250*1/2 + sqrt(250*1/2*(1-1/2)) * qnorm(alpha/2) * c(1,-1)

Since $k$ has to be a whole number, we see it will fall into the critical region when it is $109$ or less or $141$ or greater. This answer is identical to the one obtained using the exact Binomial calculation. This typically is the case when $p$ is nearer $1/2$ than it is to $0$ or $1$, the sample size is moderate to large (tens or more), and $\alpha$ is not very small (a few percent).


This test, because it assumes nothing about the population (except that it doesn't have a lot of probability focused right on its median), is not as powerful as other tests that make specific assumptions about the population. If the test nevertheless rejects the null, there's no need to be concerned about lack of power. Otherwise, you have to make some delicate trade-offs between what you are willing to assume and what you are able to conclude about the population.

$\endgroup$
2
  • 2
    $\begingroup$ As this is practically a worked example of your rather more abstract "meaning of a p-value" answer, not only in espousing the same philosophy but in the way your answer is structured, I think you ought to link it ("An example of how this is applied in practice can be found in my answer to...") in the conclusion of your answer there. $\endgroup$
    – Silverfish
    Commented Jan 6, 2015 at 23:32
  • 2
    $\begingroup$ @Silver Thank you; that indeed had crossed my mind. I thought I might wait a little first. Among other things, I would not be surprised if some enterprising community member were to dig up a duplicate thread, which I would want to examine more closely. After all, this is basic material--lots of questions have asked about binomial tests. The only claim this one has to being new is that it arrived here as a need for a test of a median--so it was not so obviously a binomial test at the outset--and the only claim my answer has to being worthy of reading lies in its effort to explain every step. $\endgroup$
    – whuber
    Commented Jan 6, 2015 at 23:37

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.