next up previous
Next: Hypothesis tests to compare Up: Statistical Decisions Previous: Hypothesis tests for a

Hypothesis tests for a population mean

For this problem we use the same sampling theory derived for confidence intervals of population means. If the population is approximately normally distributed or if the sample size is large, then the sampling distribution of

\begin{displaymath}
t = \frac{\overline{X} - \mu_0}{s/\sqrt{n}}
\end{displaymath}

is a t-distribution with n-1 degrees of freedom.

  1. $H_0:\ \mu \le \mu_0$
    $H_1:\ \mu > \mu_0$
    The burden of proof is to show that $\mu > \mu_0$, where $\mu_0$ is the reference value for the population mean that is initially assumed to be true. The test statistic for this test is

    \begin{displaymath}
t = \frac{\overline{X} - \mu_0}{s/\sqrt{n}}.
\end{displaymath}

    The p-value is P(T > t), the area to the right of t under the t-density with n-1 d.f.


  2. $H_0:\ \mu \ge \mu_0$
    $H_1:\ \mu < \mu_0$
    The test statistic for this test is

    \begin{displaymath}
t = \frac{\overline{X} - \mu_0}{s/\sqrt{n}}.
\end{displaymath}

    The p-value is P(T < t), the area to the left of t under the t-density with n-1 d.f.

  3. For the two-sided test,
    $H_0:\ \mu = \mu_0$
    $H_1:\ \mu \ne \mu_0$
    the test statistic is |t| and the p-value is the total area under both tails of the t-density,

    \begin{displaymath}
P(T < -\vert t\vert) + P(T > \vert t\vert),
\end{displaymath}

More advanced tools are required to obtain the power function of the t-test. The theory behind this power function is illustrated here by a large sample approximation. First consider a one-sided test of the hypotheses:
$H_0:\ \mu \le \mu_0$
$H_1:\ \mu > \mu_0$
with level of significance $\alpha$. We would reject the null hypothesis if the t-statistic,

\begin{displaymath}
T = \frac{\overline{X} - \mu_0}{s/\sqrt{n}},
\end{displaymath}

is greater than or equal to the critical value, $t_{n-1,1-\alpha}$, chosen so that the area to the right of this value under the t-distribution with n-1 degrees of freedom equals $\alpha$. In the large sample case, this critical value is approximately equal to the corresponding value from the standard normal distribution. In R the approximate critical value can be obtained by

\begin{displaymath}
t_{n-1,1-\alpha} = qt(1-\alpha,n-1) \approx z_{1-\alpha} = qnorm(1-\alpha).
\end{displaymath}

This is equivalent to rejecting the null hypothesis if

\begin{displaymath}
\overline{X} \ge \mu_0 + z_{1-\alpha}s/\sqrt{n}.
\end{displaymath}

Therefore, the power function for this test is given by

\begin{displaymath}
P_\mu(\overline{X} \ge \mu_0 + z_{1-\alpha}s/\sqrt{n}),
\end{displaymath}

where $\mu$ represents the actual population mean. In the large sample case, we can use the standard normal distribution to approximate the distribution of

\begin{displaymath}
T = \frac{\overline{X} - \mu}{s/\sqrt{n}},
\end{displaymath}

This gives

\begin{eqnarray*}
{\rm Power}(\mu) &=& P_\mu(\overline{X} \ge \mu_0 + z_{1-\alph...
...\
&=& 1 - pnorm(\frac{\mu_0 - \mu}{s/\sqrt{n}} + z_{1-\alpha})
\end{eqnarray*}

Suppose we have a random sample of size n=80 with sample mean 65, sample s.d. 12, and we wish to test
$H_0:\ \mu \le 60$
$H_1:\ \mu > 60$
at 5% level of significance. In R a plot of this power function can be obtained by
s = 12
n = 80
alpha = .05
mu0 = 60
criticalValue = qnorm(1-alpha)
mu = seq(58,68,length=201)
power = 1 - pnorm(criticalValue + (mu0 - mu)*sqrt(n)/s)
plot(mu,power,type="l",xlab=expression(mu),ylab="Power")
title("Power Function of One-sided T-test")
abline(h=alpha,col="red")
abline(h=.9,col="blue")
points(mu0,alpha,pch=19,col="red")
text(mu0,alpha,paste("Power(60) =",alpha),adj=c(-.1,1.2))
beta = .1
mu1 = max(mu[power <= 1-beta])
points(mu1,1-beta,pch=19,col="blue")
text(mu1,1-beta,paste("Power(",round(mu1,2),") = ",1-beta,sep=""),adj=c(-.1,1.2))
Note that the power function at the null hypothesis is always equal to the level of significance. This plot also shows that if the population mean is 63.9, then the probability this test will reject the null hypothesis is 0.9.

R has a function for power of t-tests that uses the exact distribution of the test statistic which is the non-central t-distribution. This function, power.t.test() can be used to obtain power, sample sizes, and observable differences for t-tests. For the example above, the power function is obtained by

pwr = power.t.test(n, delta=mu-mu0, sd=s, type="one.sample", alternative="one.sided")$power
# add this to previous plot
lines(mu,pwr,col="green")
Note that the result is essentially the same as the large sample approximation because the sample size is relatively large. Now suppose the sample size had been smaller, say 20 instead of 80.
s = 12
n = 20
alpha = .05
mu0 = 60
criticalValue = qnorm(1-alpha)
mu = seq(58,72,length=201)
power = 1 - pnorm(criticalValue + (mu0 - mu)*sqrt(n)/s)
plot(mu,power,type="l",xlab=expression(mu),ylab="Power",ylim=c(0,1))
title("Power Function of One-sided T-test")
abline(h=alpha,col="red")
abline(h=.9,col="blue")
pwr = power.t.test(n, delta=mu-mu0, sd=s, type="one.sample", alternative="one.sided")$power
# add this to previous plot
lines(mu,pwr,col="green")

Note that the power function involves four basic components of the test: sample size, delta, sigma, and power. The power.t.test function is written so that if three of those components are specified, then the function returns the fourth. For example, suppose we would like to determine the sample size needed to give a 90% probability that the null hypothesis would be rejected when $\mu = 63$ using the same s.d. as before. This is obtained as follows.

mu1 = 63
n1 = power.t.test(delta=mu1-mu0, sd=s, power=.9, type="one.sample", alternative="one.sided")$n
cat("Required sample size =",round(n1),"\n")
Another example: what values of the mean can be detected with 80% probability if the sample size is 100 and the population s.d. is 15?
n = 100
s = 15
pwr = 0.8
del = power.t.test(n, sd=s, power=pwr, type="one.sample", alternative="one.sided")$delta
mu1 = mu0 + del
cat(paste("Detectable mean when n = ",n,",sigma = ",s,", power = ",pwr,":",sep=""),"\n")
cat("mu1 =",round(mu1,1),"\n")


next up previous
Next: Hypothesis tests to compare Up: Statistical Decisions Previous: Hypothesis tests for a
ammann
2017-12-04