# Calculating the p value for the sign test

I am utterly confused at calculating the p value for both single sampled and matched pair sign tests.

Suppose we have a sample size of 12 and 4 values are below our hypothesized median of $$m_x$$ and 8 are above.

And that $$H_0: m=m_x$$ and $$H_1: m≠m_x$$ with $$\alpha = 0.10$$

Now, taking the number of plus signs to be our test statistic, I know that the number of plus signs follow a binomial distribution of $$n=12$$ $$p=0.5$$, however this is where I fail to proceed from.

If we take a look at the distribution of our test statistic we would find exactly half of the values above and below the hypothesized median, but which probability would we calculate to compare to $$\alpha$$ here?

The textbook I am using is extremely unhelpful here and gives the vague statement that

Given n data points a single sample sign test is created using $$X- \text{Bin}(n,0.5)$$, the test statistic can be the amount of plus signs. We can calculate the probability that $$X$$ is above the test statistic, below it or either.

Why cant we just calculate the probability that the number of plus signs is equal to our test statistic or $$P(X=4)$$ and compare that to $$\alpha$$, furthermore how can I tell whether to calculate $$P(X≥ \text{Test statistic})$$ or $$P(X≤ \text{Test statistic})$$

The easiest way to understand this problem is to do a drawing of your Binomial (12;0.5)

if, as it is in your case, the test is two-sided, the p-value is the probability of the two queues...

$$\text{p-value }=2\times \mathbb{P}[X\geq 8]=2\times \mathbb{P}[X\leq4]=19.4\%\times2=38.8.\%$$

This means that you CANNOT REJECT $$H_0$$ for any significance level $$\alpha<38.8\%$$

At $$10\%$$ you will reject $$H_0$$ only if you had $$\{0;1;2;10;11;12\}$$ values under or above $$m_x$$

If you had 3 or 9 and you want to decide anyway, you can do a randomized test. This link is an useful topic to become familiar with randomized tests

• Suppose we have a sample size of 12 and 6 values are below our hypothesized median and 6 are above. In two-tailed test, the p-value is :$2\sum_{i=0}^6\tbinom{12}{i}(\frac{1}{2})^n>1$. What is the correct formula to calculate p-value when $S^{+}=S^{-}$? Commented Sep 22, 2022 at 22:39