Let $X$ be an amount of successes and $X\sim B(n,p)$. Let $\varphi$ be a UMP test with $$H_0: \ p\leq p_{0}, \\H_1: p>p_{0}.$$ I have a problem with finding an exact form of UMC test when $n=6$, $p_0=0.25$, $\alpha=0.05$ and evaluating the power of a test against alternative $p=0.4$. My last problem is associated with fixing $n$ in such a way that power of a test will be $\geq0.7$ (we can use tables of binomial distribution or use approximation with the help of normal distribution, the values of $p_0$, $\alpha$, $p$ are the same as previously).
I have only managed to find the form of a test:
$\varphi(p) = \begin{cases} 1 & \text{if } p \leq p_0 \\ 0 & \text{if } p>p_0. \end{cases}$
I know that power of a test is $Pr($ reject $H_0|H_1$ is true$)$ but I am not convinced how to proceed later.
I will try to get you started:
You are given: $n=6, p_0 = 0.25, \alpha = 0.05, p_a=0.4.$ In order to test $H_0: p \le p_0$ against $H_a: p > p_0,$ it makes sense to reject $H_0$ when $\hat p = X/n$ is large, which means rejecting for large $X.$
The significance level is determined by the distribution when $H_0$ is true; that is, when $X\sim\mathsf{Binom}(n=6,p=.25).$ To find the critical value $c$ such that Reject means $\{X \ge c\},$ we need to find $c$ with $$P(X\ge c\,|\, n=6, p=.25) \le \alpha = 0.05.$$
I will use R for probability computations. In R,
dbinom,pbinom, andqbinomare the PDF, CDF, and quantile function (inverse CDF) respectively.So it seems that $c = 4$ for a test just not exceeding probability $0.05 = 5\%.$ You should verify this (exactly) using tables or (approximately) with a normal approximation.
Now that we know the exact definition of "Reject", we can find the power of the test against the particular alternative value $p_a = 0.4.$ Thus, the desired power is $$P(Rej\, |\, n=6,p=0.4) = P(X \ge c\, |\, n=6,p=0.4)\\ = P(X \ge 4\, |\, n=6, p=0.4) = 0.1792.$$
[Again here, you should use tables or normal approximation to verify what I have done using R. For $n$ as small as $6$ it is best to use tables; the normal approximation works best when $np$ and $n(1-p)$ both exceed $5.]$
In the figure above, the significance level is the sum of the heights of the blue bars to the right of the critical value marked by the vertical dotted line. The power is the sum of the heights of the brown bars to the right of that line.
This result $0.1792$ is not very good power. If $H_a$ is true with $p_a = 0.4,$ we would like to have a good chance of rejecting the null hypothesis. In many studies, researchers try to to choose $n$ sufficiently large that the power is $80\%$ or $90\%.$ Your next question seeks $n$ large enough that the power is at least $70\% = 0.7.$
So you need to find $n$ and the corresponding $c$ with $P(X \ge c\,|\,n, p=0.25) \le \alpha = 0.05$ and also $P(X \ge c\,|\,n, p=0.4) \ge 1-\beta = 0.7.$
In terms of the figure above, you need to find $n$ large enough that the two distributions have better separation. The goal is for the significance level to be small and the power to be large.
The reason I have been stressing that you should verify everything so far is that it may be easier to find the $n$ needed for $70\%$ power using a normal approximation and solving a couple of equations, than by trial and error using R.
The figure below shows binomial distributions for $n = 6$ with $p_0 = .25$ and $p_a = 0.4.$ The critical value is shows as a vertical dotted line.
In closing, just let's see what we get with $n=15.$ It's clear that $n=15$ gives better power than did $n=6,$ but not large enough to get power $0.7.$
So, I hope you understand the second problem and can work out how to solve it by whatever method you choose.