StatlectThe Digital Textbook
Index > Fundamentals of statistics > Hypothesis testing

Hypothesis tests about the mean

This lecture presents some examples of Hypothesis testing, focusing on tests of hypothesis about the mean, i.e., on using a sample to perform tests of hypothesis about the mean of an unknown distribution.

Table of Contents

Normal IID samples - Known variance

In this example we make the same assumptions we made in the example of set estimation of the mean entitled Set estimation of the mean - Normal IID samples. The reader is strongly advised to read that example before reading this one.

The sample

In this example, the sample $xi _{n}$ is made of n independent draws from a normal distribution having unknown mean mu and known variance sigma^2. Specifically, we observe n realizations $x_{1}$, ..., $x_{n}$ of n independent random variables X_1, ..., X_n, all having a normal distribution with unknown mean mu and known variance sigma^2. The sample is the n-dimensional vector [eq1], which is a realization of the random vector [eq2].

The null hypothesis

We test the null hypothesis that the mean mu is equal to a specific value $mu _{0}$:[eq3]

The alternative hypothesis

We assume that the parameter space is the whole real line, i.e., $mu in U{211d} $. Therefore, the alternative hypothesis is[eq4]

The test statistic

To construct a test statistic, we use the sample mean[eq5]

The test statistic is[eq6]This test statistic is often called z-statistic or normal z-statistic and a test of hypothesis based on this statistic is called z-test or normal z-test.

The critical region

Let [eq7]. We reject the null hypothesis $H_{0}$ if $Z_{n}>z$ or if $Z_{n}<-z$. In other words, the critical region is[eq8]Thus, the critical values of the test are $-z$ and $z$.

The power function

The power function of the test is[eq9]where Z is a standard normal random variable and the notation $QTR{rm}{P}_{mu }$ is used to indicate the fact that the probability of rejecting the null hypothesis is computed under the hypothesis that the true mean is equal to mu.

Proof

The power function can be written as[eq10]where we have defined[eq11]As demonstrated in the lecture entitled Point estimation of the mean, the sample mean Xbar_n has a normal distribution with mean mu and variance $sigma ^{2}/n$, given the assumptions on the sample $xi _{n}$ we made above. Subtracting the mean of a normal random variable from the random variable itself and dividing it by the square root of its variance, one obtains a standard normal random variable. Therefore, the variable Z has a standard normal distribution.

The size of the test

When evaluated at the point $mu =mu _{0}$, the power function is equal to the probability of committing a Type I error, i.e., the probability of rejecting the null hypothesis when the null hypothesis is true. This probability is called the size of the test and it is equal to [eq12]where Z is a standard normal random variable (this is trivially obtained by substituting mu with $mu _{0}$ in the formula for the power function found above).

Normal IID samples - Unknown variance

This example is similar to the previous one. The only difference is that we now relax the assumption that the variance of the distribution is known.

The sample

In this example, the sample $xi _{n}$ is made of n independent draws from a normal distribution having unknown mean mu and unknown variance sigma^2. Specifically, we observe n realizations $x_{1}$, ..., $x_{n}$ of n independent random variables X_1, ..., X_n, all having a normal distribution with unknown mean mu and unknown variance sigma^2. The sample is the n-dimensional vector [eq13], which is a realization of the random vector [eq2].

The null hypothesis

We test the null hypothesis that the mean mu is equal to a specific value $mu _{0}$:[eq3]

The alternative hypothesis

We assume that the parameter space is the whole real line, i.e., $mu in U{211d} $. Therefore, the alternative hypothesis is[eq16]

The test statistic

We construct two test statistics, by using the sample mean[eq5]and either the unadjusted sample variance[eq18]or the adjusted sample variance[eq19]

The two test statistics are[eq20]where the superscripts $u$ and a indicate whether the test statistic is based on the unadjusted or the adjusted sample variance. These two test statistics are often called t-statistics or Student's t-statistics and tests of hypothesis based on these statistics are called t-tests or Student's t-tests.

The critical region

Let [eq7]. We reject the null hypothesis $H_{0}$ if $Z_{n}^{i}>z$ or if $Z_{n}^{i}<-z$ (for $i=u$ or $i=a$). In other words, the critical region is[eq22]Thus, the critical values of the test are $-z$ and $z$.

The power function

The power function of the test based on the unadjusted sample variance is[eq23]where the notation $QTR{rm}{P}_{mu }$ is used to indicate the fact that the probability of rejecting the null hypothesis is computed under the hypothesis that the true mean is equal to mu and $W_{n-1}$ is a non-central standard Student's t distribution with $n-1$ degrees of freedom and non-centrality parameter equal to[eq24]

Proof

The power function can be written as[eq25]where we have defined[eq26]Given the assumptions on the sample $xi _{n}$ we made above, the sample mean Xbar_n has a normal distribution with mean mu and variance $sigma ^{2}/n$ (see Point estimation of the mean), so that the random variable[eq27]has a standard normal distribution. Furthermore, the unadjusted sample variance $S_{n}^{2}$ has a Gamma distribution with parameters $n-1$ and [eq28] (see Point estimation of the variance), so that the random variable[eq29]has a Gamma distribution with parameters $n-1$ and 1. Adding a constant $c$ to a standard normal distribution and dividing the sum thus obtained by the square root of a Gamma random variable with parameters $n-1$ and 1, one obtains a non-central standard Student's t distribution with $n-1$ degrees of freedom and non-centrality parameter $c$. Therefore, the random variable $W_{n-1}$ has a non-central standard Student's t distribution with $n-1$ degrees of freedom and non-centrality parameter[eq30]

The power function of the test based on the adjusted sample variance is[eq31]where the notation $QTR{rm}{P}_{mu }$ is used to indicate the fact that the probability of rejecting the null hypothesis is computed under the hypothesis that the true mean is equal to mu and $W_{n-1}$ is a non-central standard Student's t distribution with $n-1$ degrees of freedom and non-centrality parameter equal to[eq32]

Proof

The power function can be written as[eq33]where we have defined[eq34]Given the assumptions on the sample $xi _{n}$ we made above, the sample mean Xbar_n has a normal distribution with mean mu and variance $sigma ^{2}/n$ (see Point estimation of the mean), so that the random variable[eq27]has a standard normal distribution. Furthermore, the adjusted sample variance $s_{n}^{2}$ has a Gamma distribution with parameters $n-1$ and sigma^2 (see Point estimation of the variance), so that the random variable[eq36]has a Gamma distribution with parameters $n-1$ and 1. Adding a constant $c$ to a standard normal distribution and dividing the sum thus obtained by the square root of a Gamma random variable with parameters $n-1$ and 1, one obtains a non-central standard Student's t distribution with $n-1$ degrees of freedom and non-centrality parameter $c$. Therefore, the random variable $W_{n-1}$ has a non-central standard Student's t distribution with $n-1$ degrees of freedom and non-centrality parameter[eq30]

Note that, for a fixed $z$, the test based on the unadjusted sample variance is more powerful than the test based on the adjusted sample variance, i.e.,[eq38]because[eq39]and, as a consequence[eq40]

The size of the test

The size of the test based on the unadjusted sample variance is equal to [eq41]where $W_{n-1}$ is a standard Student's t distribution with $n-1$ degrees of freedom.

Proof

When evaluated at the point $mu =mu _{0}$, the power function is equal to the size of the test, i.e. the probability of committing a Type I error. The power function evaluated at $mu _{0}$ is[eq41]where $W_{n-1}$ is a non-central standard Student's t distribution with $n-1$ degrees of freedom and non-centrality parameter equal to[eq43]Therefore, when $mu =mu _{0}$, the non-centrality parameter is equal to 0 and $W_{n-1}$ is just a standard Student's t distribution.

The size of the test based on the adjusted sample variance is equal to [eq44]where $W_{n-1}$ is a standard Student's t distribution with $n-1$ degrees of freedom.

Proof

When evaluated at the point $mu =mu _{0}$, the power function is equal to the size of the test, i.e. the probability of committing a Type I error. The power function evaluated at $mu _{0}$ is[eq45]where $W_{n-1}$ is a non-central standard Student's t distribution with $n-1$ degrees of freedom and non-centrality parameter equal to[eq43]Therefore, when $mu =mu _{0}$, the non-centrality parameter is equal to 0 and $W_{n-1}$ is just a standard Student's t distribution.

Note that, for a fixed $z$, the test based on the unadjusted sample variance has a greater size than the test based on the adjusted sample variance, because, as demonstrated above, the former also has a greater power than the latter for any value of the true parameter mu.

Solved exercises

Below you can find some exercises with explained solutions.

Exercise 1

Denote by [eq47] the distribution function of a non-central standard Student's t distribution with n degrees of freedom and non-centrality parameter equal to k. Suppose a statistician observes $100$ independent realizations of a normal random variable. The mean and the variance of the random variable, which the statistician does not know, are equal to 1 and $4$ respectively. What is the probability, expressed in terms of [eq48], that the statistician will reject the null hypothesis that the mean is equal to zero if she runs a t-test based on the $100$ observed realizations, she sets $z=2$ as the critical value, and she uses the adjusted sample variance to compute the t-statistic?

Solution

The probability of rejecting the null hypothesis $mu _{0}=0$ is obtained by evaluating the power function of the test at $mu =1$:[eq49]where the notation $QTR{rm}{P}_{mu }$ is used to indicate the fact that the probability of rejecting the null hypothesis is computed under the hypothesis that the true mean is equal to $mu =1$, and $W_{99}$ is a non-central standard Student's t distribution with $99$ degrees of freedom and non-centrality parameter[eq50]Thus, the probability of rejecting the null hypothesis is equal to[eq51]

Exercise 2

Denote by [eq52] the distribution function of a standard Student's t distribution with n degrees of freedom, and by [eq53] its inverse. Suppose that a statistician observes $100$ independent realizations of a normal random variable, and she performs a t-test of the null hypothesis that the mean of the variable is equal to zero, based on the $100$ observed realizations, and using the unadjusted sample variance to compute the t-statistic. What critical value should she use in order to incur into a Type I error with 10% probability? Express it in terms of [eq54].

Solution

A Type I error is committed when the null hypothesis is true, but it is rejected. The probability of rejecting the null hypothesis $mu _{0}=0$ is [eq55]where $z$ is the critical value, and $W_{99}$ is a standard Student's t distribution with $99$ degrees of freedom. This probability can be expressed as[eq56]where: in step $box{A}$ we have used the fact that the density of a standard Student's t distribution is symmetric around zero. Thus, we need to set $z$ in such a way that[eq57]This is accomplished by[eq58]

The book

Most of the learning materials found on this website are now available in a traditional textbook format.