# Hypothesis tests about the mean

This lecture explains how to conduct hypothesis tests about the mean of a normal distribution.

We tackle two different cases:

• when we know the variance of the distribution, then we use a z-statistic to conduct the test;

• when the variance is unknown, then we use the t-statistic.

In each case we derive the power and the size of the test.

We conclude with two solved exercises on size and power.

## Known variance: the z-test

The assumptions are the same we made in the lecture on confidence intervals for the mean.

### The sample

The sample is made of independent draws from a normal distribution.

Specifically, we observe the realizations of independent random variables , ..., , all having a normal distribution with:

• unknown mean ;

• known variance .

### The null hypothesis

We test the null hypothesis that the mean is equal to a specific value :

### The test statistic

To construct a test statistic, we use the sample mean

The test statistic, called z-statistic, is

A test of hypothesis based on it is called z-test.

We prove below that has a normal distribution with zero mean and unit variance.

### The critical region

The critical region iswhere .

Thus, the critical values of the test are and . How they are chosen is explained below.

### The decision

The null hypothesis is rejected if , that is, if

Otherwise, it is not rejected.

### The power function

The power function of the test iswhere is a standard normal random variable.

The notation indicates that the probability of rejecting the null is computed under the alternative hypothesis that the true mean is equal to .

Proof

The power function can be written aswhere we have definedAs demonstrated in the lecture entitled Point estimation of the mean, the sample mean has a normal distribution with mean and variance , given the assumptions we made above. If we de-mean a normal random variable and we divide it by the square root of its variance, the resulting variable ( in this case) has a standard normal distribution.

### The size of the test

When evaluated at the point , the power function is equal to the probability of committing a Type I error, that is, of rejecting the null hypothesis when it is true.

This probability, called the size of the test, is equal to where the test statistic is a standard normal random variable.

Proof

Substite with in the power function and note that when .

### How to choose the critical value

As usual, the critical value is chosen so as to achieve a desired size .

In other words, we fix the size and then we find the critical value that solves

We explain how to do this in the page on critical values.

## Unknown variance: the t-test

This case 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

We observe the realizations of independent random variables , ..., , all having a normal distribution with

• unknown mean ;

• unknown variance .

### The null hypothesis

We test the null hypothesis that the mean is equal to a specific value :

### The test statistic

We construct the test statistic by using the sample meanand the adjusted sample variance

The test statistics, called t-statistic, is

The test of hypothesis based on it is called t-test.

We prove below that has a standard Student's t distribution with degrees of freedom.

### The critical region

The critical region iswhere .

Thus, the critical values of the test are and . How they are chosen is explained below.

### The decision

We reject the null hypothesis if

Otherwise, we do not reject it.

### The power function

The power function of the test is

where:

• the notation indicates that the probability of rejecting the null is computed under the alternative hypothesis that the true mean is equal to ;

• is a non-central standard Student's t distribution with degrees of freedom and non-centrality parameter equal to

Proof

The power function can be written aswhere we have definedGiven the assumptions made above, the sample mean has a normal distribution with mean and variance (see Point estimation of the mean), so that the random variablehas a standard normal distribution. Furthermore, the adjusted sample variance has a Gamma distribution with parameters and (see Point estimation of the variance). It follows thathas a Gamma distribution with parameters and . If we add a constant to a standard normal distribution and we divide the sum thus obtained by the square root of a Gamma variable with parameters and , we obtain a non-central standard Student's t distribution with degrees of freedom and non-centrality parameter . The variable has exactly this distribution, with parameter

### The size of the test

The size of the test is equal to where the test statistic has a standard Student's t distribution with degrees of freedom.

Proof

The size of the test is obtained by evaluating the power function at the point :The statistic has a non-central standard Student's t distribution with degrees of freedom and non-centrality parameter equal toWhen , the non-centrality parameter is equal to and has a standard Student's t distribution.

### How to choose the critical values

As before, we choose the critical value so as to achieve a desired size .

Therefore, the critical value needs to solve the equation

The page on critical values explains how this equation is solved.

## Solved exercises

Below you can find some exercises with explained solutions.

### Exercise 1

Denote by the distribution function of a non-central standard Student's t distribution with degrees of freedom and non-centrality parameter equal to .

Suppose that 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.

Find the probability 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 as the critical value.

Express the probability in terms of .

Solution

The probability of rejecting the null hypothesis is obtained by evaluating the power function of the test at :The notation indicates that the probability of rejecting the null is computed under the alternative hypothesis that the true mean is equal to . The variable has a non-central standard Student's t distribution with degrees of freedom and non-centrality parameterThus, the probability of rejecting the null hypothesis is equal to

### Exercise 2

Denote by the distribution function of a standard Student's t distribution with degrees of freedom, and by its inverse.

A statistician observes 100 independent realizations of a normal random variable.

She performs a t-test of the null hypothesis that the mean of the variable is equal to zero.

What critical value should she use in order to incur into a Type I error with 10% probability? Express it in terms of .

Solution

A Type I error is committed when the null hypothesis is true, but it is rejected. The probability of rejecting the null hypothesis is where is the critical value, and is a standard Student's t distribution with degrees of freedom. This probability can be expressed aswhere: in step we have used the fact that the density of a standard Student's t distribution is symmetric around zero. Thus, we need to set in such a way thatThis is accomplished by