Determine the sample size for a two sided $z$-test

hypothesis testinglaw-of-large-numberssampling-theorystatistical-inference

Let $X_{1}, \ldots, X_{n}$ be an iid sample from $N(\mu,\sigma^2)$
where $\sigma$ is known. We want to test a hypothesis
$$
H_{0}:\mu = \mu_{0}
\quad \mbox{versus} \quad
H_{1}: \mu \ne \mu_0
$$

Now, assume that the values of $\alpha$ (probability of Type I Error)
and $\beta$ (Probability of Type II Error) are fixed in advance.

Therefore, the problem now is to determine what should be the sample size to achieve the desired value of $\beta$?

Here is what I progressed:

The power function is given by
$$
w(\mu)
=
1 +
\Phi
\left(
k-z_{\alpha/2}
\right)

\Phi
\left(
k+z_{\alpha/2}
\right),
$$

where
$$
k = \frac{\mu_0-\mu}{\sigma/\sqrt{n}}.
$$

We also know that
$$
w(\mu) = 1 – \beta(\mu),
$$

where $\beta(\mu)$ is the probability of making Type II error when the true parameter value is $\mu$.

Now, it is evident that in order to achieve the desired value of $\beta$, we need to set up the equation
$$
1-\beta = w(\mu),
$$

and solve this equation for $n$.

But I am not sure how to solve this equation for $n$.

I just found on one of the textbooks without any work that
the minimum sample size should be
$$
n \ge
\left[
\frac{\sigma(z_{\beta} + z_{\alpha/2})}
{\mu_0-\mu}
\right]^2
$$

as an approximated solution.

But again how do we get this approximated solution?

Thank you!

Best Answer

The approximated solution can be derived as below.

\begin{align*} & {\qquad} 1-\beta = w(\mu) \\ & {\qquad} = 1 + \Phi \left( k-z_{\alpha/2} \right) - \Phi \left( k+z_{\alpha/2} \right) \\ & {\qquad} = P(Z \ge z_{\alpha/2}-|k|) + P(Z \ge z_{\alpha/2}+|k|) \\ \Rightarrow & {\qquad} 1-\beta \approx P(Z \ge z_{\alpha/2}-|k|), \quad \mbox{assuming} \quad P(Z \ge z_{\alpha/2}+|k|) \approx 0 \\ \iff & {\qquad} z_{1-\beta} \approx z_{\alpha/2}-|k| \\ \iff & {\quad} -z_{\beta} \approx z_{\alpha/2}-|k| \\ \iff & {\quad} |k| \approx z_{\alpha/2}+z_{\beta}, \end{align*} this gives $$ n \approx \left[ \frac{\sigma(z_{\beta} + z_{\alpha/2})} {\mu_0-\mu} \right]^2, $$ as desired.

Related Question