The formular for calculating the p-value for sign test Suppose we have a sample size of 12 and 6 values are below our hypothesized median and 6 are above.
We assume that $H0:m=m_x$ and $H1:m\neq m_x$ with $\alpha=0.10$.
We know that $S^{+}=S^{-}=6$.
In two-tailed test, the formula for calculating  p-value is : $2P(S^{+}\geq 6)$, where $S^{+}\sim B(12,0.5)$, (Please see https://www.math.mcgill.ca/~dstephens/OldCourses/204-2007/Handouts/Math204-NonParOneTwo.pdf)
then we have
$2\sum_{i=6}^{12}\tbinom{12}{i}(\frac{1}{2})^n>1$, but the p-value cannot exceed 1. Can anyone find the wrong place. In many reference books about sign test, the above formula was mentioned, but if we use the formula to calculate , we get a p-value which is greater than 1.
What is the correct formula to calculate p-value when $S^{+}=S^{−}?
 A: As I said in the comment, if $S^+=n/2$, then the formula for the p-value is just $p=1$, but I'll explain why that is here.
Let's look first at the case where the counts are $S^−=1,S^+=11$, then the values which are more or equally extreme are $S^−=1,S^+=11$, $S^−=0,S^+=12$. Given that we are interested in a two-sided test, the values $S^−=11,S^+=1$ and $S^−=12,S^+=0$ are also considered more or equally extreme. So our p-value becomes $$p=P(S^+=0)+P(S^+=1)+P(S^+=11)+P(S^+=12)=P(S^+\leq 1)+P(S^+\geq 11)$$
Since the Bernouilli distribution is symmetric, $P(S^+\leq 1)=P(S^+\geq 11)$ and thus we have
$$p=2 P(S^+\geq 11)$$
Now, if we go back to the case where $S^+=n/2$, then all possible values for $S^+$ are 'more or equally' extreme, and so the p-value is
$$p=\sum_{i=0}^{12} P(S^+=i)=1$$
Note however that
$$\sum_{i=0}^{12} P(S^+=i)=P(S^+\leq 5)+P(S^+=6)+P(S^+\geq 7)=P(S^+=6)+2P(S^+\geq 7)$$
which does not match $2P(S^+\geq 6)$ because in the latter formula, you've counted $P(S^+=6)$ twice.
Hopefully this clarifies your question.
