# p-value of the following test

I have the following problem:

I have $$X_1 ... X_n$$ ~ Bernoulli(p) independent. I also have the following test hypothesis: $$H_0: p = p_0$$ and $$H_1: p > p_0$$. I define my test as follows:

$$T:$$ I refuse $$H_0$$ in favour of $$P_1$$ if the number of successes is very high.

Now suppose $$p_0 = 0.6$$ and $$n = 20$$, we find that we have 18 successes.

I want to find the p-value of the test.

Now this is what I have done:

$$p-value = \mathbb{P}(\sum x_i \geq 18)$$ = 0.0005240494 However confronting it with the command:

binom.test(18,20,p=.6,alternative=greater)


It is not right (by a factor of 10). My problem is that I am not able to correctly asses what the "number of succession is very high". How do I work around this?

• What is the confidence level and significance level, respectively? Maybe 0.95 and 1-0.95=0.05? – callculus Jan 17 at 21:19
• I don't have that information. I don't think is needed as the purpose of the p-value is to work without one, from my understanding. – qcc101 Jan 17 at 21:56
• $\mathbb{P}(\sum X_i \geq 18)=0.0036$ – d.k.o. Jan 17 at 23:27
• @d.k.o. I see, maybe I messed up my calculation. Still, is this the right way to do it? – qcc101 Jan 18 at 9:35
• Yes this is the correct way to do it – Alex Jan 22 at 7:12

Letting $$K=\sum_i \mathbb{I}(X_i = 1)$$ be the number of successes, you have $$K \sim \text{Bin}(n,p)$$. Thus, your p-value is:
\begin{aligned} p \equiv p(k) &\equiv \mathbb{P}( K \geqslant k | H_0) \\[6pt] &= \mathbb{P}( K \geqslant k | K \sim \text{Bin}(n,p_0)) \\[6pt] &= \sum_{r=k}^n \text{Bin}(r|n,p_0). \\[6pt] \end{aligned}
With $$p_0=0.6$$, $$n=20$$ and $$k=18$$ you get the p-value:
$$p = \sum_{r=18}^{20} \text{Bin}(r|20, 0.6) = 0.003611472.$$