Jump to content

Statistics/Hypothesis Testing

From Wikibooks, open books for an open world

Introduction

[edit | edit source]

In previous chapters, we have discussed two methods for estimating unknown parameters, namely point estimation and interval estimation. Estimating unknown parameters is an important area in statistical inference, and in this chapter we will discuss another important area, namely hypothesis testing, which is related to decision making. Indeed, the concepts of confidence intervals and hypothesis testing are closely related, as we will demonstrate.

Basic concepts and terminologies

[edit | edit source]

Before discussing how to conduct hypothesis testing, and evaluate the "goodness" of a hypothesis test, let us introduce some basic concepts and terminologies related to hypothesis testing first.

Definition. (Hypothesis) A (statistical) hypothesis is a statement about population parameter(s).

There are two terms that classify hypotheses:

Definition. (Simple and composite hypothesis) A hypothesis is a simple hypothesis if it completely specifies the distribution of the population (that is, the distribution is completely known, without any unknown parameters involved), and is a composite hypothesis otherwise.

Sometimes, it is not immediately clear that whether a hypothesis is simple or composite. To understand the classification of hypotheses more clearly, let us consider the following example.

Example. Consider a distribution with parameter θ, taking values in the parameter space Θ=[0,∞). Determine whether each of the following hypotheses is simple or composite.

(a) θ=1.

(b) θ=θ0 where θ0∈Θ is known.

(c) θ>1.

(d) θ>θ0 where θ0∈Θ is known.

(e) θ≤θ0 where θ0∈Θ is known.

(f) θ∈Θ0 where Θ0 is a nonempty subset of Θ. [1]

Solution.

  • (a) and (b) are simple hypotheses, since they all completely specifies the distribution.
  • (c), (d) and (e) are composite hypotheses, since the parameter θ is not completely specified, then so is the distribution.
  • (f) may be simple hypothesis or composite hypothesis, depending on Θ0. If Θ0 contains exactly one element, then it is simple hypothesis. Otherwise, it is composite hypothesis.

In hypothesis tests, we consider two hypotheses:

Definition. (Null hypothesis and alternative hypothesis) In hypothesis testing, the hypothesis being tested is the null hypothesis (denoted by H0) and another complementary hypothesis (to H0) is the alternative hypothesis (denoted by H1).

Remark.

  • H1 is complementary hypothesis to H0 in the sense that if H0 is true (false), then H1 is false (true) (exactly one of H0 and H1 is true). Because of this, we usually say H0 is tested against H1 (so we often write H0vs.H1).
  • Usually, H0 usually corresponds to the status quo ("no effect"), and H1 corresponds to some interesting "research findings" (So, H1 is sometimes also called research hypothesis.).
  • Since H0 often corresponds to the status quo, we usually assume H0 is true, unless there are sufficient evidences against it.
  • This is somehow analogous to the legal principle of presumption of innocence which states that every person accused of any crime is considered innocent (H0 is assumed to be true), until proven guilty (there are sufficient evidences against H0).

A general form of H0 and H1 is H0:θ∈Θ0 and H1:θ∈Θ1 where Θ1=Θ0c, which is the complement of Θ0 (with respect to Θ), i.e., Θ0c=Θ∖Θ0 (Θ is the parameter space, containing all possible values of θ). The reason for choosing the complement of Θ0 in H1 is that H1 is the complementary hypothesis to H0, as suggested in the above definition.

Remark.

  • In some books, it is only required that Θ0 and Θ1 to be disjoint (nonempty) subsets of the parameter space Θ, and it is not necessary that Θ0∪Θ1=Θ.
  • However, usually it is still assumed that exactly one of H0 and H1 is true, so it means that θ is not supposed to take values outside the set Θ0∪Θ1 (otherwise, none of H0 and H1 will be true).
  • Thus, in this case, we may actually say the parameter space is indeed Θ0∪Θ1. With this parameter space (since θ is assumed to take value in this union), then Θ1 is the complement of Θ0.
  • Alternatively, some may view the parameter space to be "linked" with a distribution, and so for a given distribution, the parameter space is fixed to be the one suggested by the distribution itself. So, in this case, Θ1 is not the complement of Θ0 (with respect to the parameter space).
  • Despite the different definitions of Θ0 and Θ1, a common feature is that we assume exactly one of H0 and H1 is true.

Example. Suppose your friend gives you a coin for tossing, and we do not know whether it is fair or not. However, since the coin is given by your friend, you believe that the coin is fair unless there are sufficient evidences suggesting otherwise. What is the null hypothesis and alternative hypothesis in this context (suppose the coin never land on edge)?

Solution. Let p be the probability for landing on heads after tossing the coin. The null hypothesis is H0:p=12. The alternative hypothesis is H1:p≠12.

Clipboard

Exercise. Suppose we replace "coin" with "six-faced dice" in the above question. What is the null and alternative hypothesis? (Hint: You may let p1,p2,…,p6 be the probability for "1","2",...,"6" coming up after rolling the dice respectively.)

Solution

Let p1,p2,…,p6 be the probability for "1","2",...,"6" coming up after rolling the dice respectively. The null hypothesis is H0:p1=p2=⋯=p6=16, and the alternative hypothesis is H1:at least one of p1,…,p6≠16 (In fact, when one of p1,…,p6 is not 16, it must cause at least one other probability to be different from 16.)


We have mentioned that exactly one of H0 and H1 is assumed to be true. To make a decision, we need to decide which hypothesis should be regarded as true. Of course, as one may expect, this decision is not perfect, and we will have some errors involved in our decision. So, we cannot say we "prove that" a particular hypothesis is true (that is, we cannot be certain that a particular hypothesis is true). Despite this, we may "regard" (or "accept") a particular hypothesis as true (but not prove it as true) when we have sufficient evidences that lead us to make this decision (ideally, with small errors [2]).

Remark.

  • Philosophically, "not rejecting H0" is different from "accepting H0", since the phrase "not rejecting H0" can mean that we actually do not regard H0 as true but just do not have sufficient evidences to reject H0, instead of meaning that we regard H0 as true. On the other hand, the phrase "accepting H0" should mean that we regard H0 as true.
  • In spite of this, we will not handle these philosophical issues, and we will just assume that whenever there are not sufficient evidences to reject H0 (i.e., we do not reject H0), then we will act as if H0 is true, that is, still accept H0, even if we may not actually "believe" in H0.
  • Of course, in some other places, the saying of "accepting null hypothesis" is avoided because of these philosophical issues.

Now, we are facing with two questions. First, what evidences should we consider? Second, what is meant by "sufficient"? For the first question, a natural answer is that we should consider the observed samples, right? This is because we are making hypothesis about the population, and the samples are taken from, and thus closely related to the population, which should help us make the decision.

To answer the second question, we need the concepts in hypothesis testing. In particular, in hypothesis testing, we will construct a so-called rejection region or critical region to help us determining that whether we should reject the null hypothesis (i.e., regard H0 as false), and hence (naturally) regard H1 as true ("accept" H1) (we have assumed that exactly one of H0 and H1 is true, so when we regard one of them as false, we should regard another of them as true). In particular, when we do not reject H0, we will act as if, or accept H0 as true (and thus should also reject H1 since exactly one of H0 of H1 is true).

Let us formally define the terms related to hypothesis testing in the following.

Definition. (Hypothesis test) A hypothesis test is a rule that specifies for which observed sample values we (do not reject and) accept H0 as true (and thus reject H1), and for which observed sample values we reject H0 and accept H1.

Remark.

  • Hypothesis test is sometimes simply written as "test" for simplicity. We also sometimes use the Greek letters "φ", "ψ", etc. to denote tests.

Definition. (Rejection and acceptance regions) Let S be the set containing all possible observations of a random sample X1,…,Xn, {𝐱}={(x1,…,xn)}. The rejection region (denoted by R) is the subset of S for which H0 is rejected. The complement of rejection region (with respect to the set S) (Rc) is the acceptance region (it is thus the subset of S for which H0 is accepted).

Remark.

  • Graphically, it looks like
    S
*------------*
|///|........|
|///\........|
|////\.......| 
|/////\......|
*------------*

*--*
|//|: R
*--*

*--*
|..|: R^c
*--*

Typically, we use test statistic (a statistic for conducting a hypothesis test) to specify the rejection region. For instance, if the random sample is X1,…,Xn and the test statistic is X‾, the rejection region may be, say, R={𝐱:x‾<2} (where x1,…,xn and x‾ is observed value of X1,…,Xn and X‾ respectively). Through this, we can directly construct a hypothesis test: when 𝐱∈R, we reject H0 and accept H1. Otherwise, if 𝐱∈Rc, we accept H0. So, in general, to specify the rule in a hypothesis test, we just need a rejection region. After that, we will apply the test on testing H0 against H1. There are some terminologies related to the hypothesis tests constructed in this way:

Definition. (Left-, Right- and two-tailed tests) Let T(𝐱)=T(x1,…,xn) be an observed test statistic for a hypothesis test, and x1,…,xn be the realizations of random samples.

  • If the rejection region is in the form of {𝐱:T(𝐱)≤k1}, then the hypothesis test is called a left-tailed test (or lower-tailed test).
  • If the rejection region is in the form of {𝐱:T(𝐱)≥k2}, then the hypothesis test is called a right-tailed test (or upper-tailed test).
  • If the rejection region is in the form of {𝐱:T(𝐱)≤k3 or T(𝐱)≥k4}, then the hypothesis test is called a two-tailed test.

Remark.

  • The inequality signs can be strict, i.e., the above inequality signs can be replaced "<" and ">".
  • We use the terminology "tail" since the rejection region includes the values that are located at the "extreme portions" (i.e., very left (with small values) or very right (with large values) portions) (called tails) of distributions.
  • When k3=−k4, we may say the two-tailed test is equal-tailed. In this case, we can also express the rejection region as {𝐱:|T(𝐱)|≥k4}.
  • We sometimes also call upper-tailed and lower-tailed tests as one-sided tests, and two-tailed tests as two-sided tests.

Example. Suppose the rejection region is R={(x1,x2,x3):x1+x2+x3>6}, and it is observed that x1=1,x2=2,x3=3. Which hypothesis, H0 or H1, should we accept?

Solution. Since (x1,x2,x3)∈Rc, we should (not reject and) accept H0.

Clipboard

Exercise. What is the type of this hypothesis test?

Solution

Right-tailed test.


As we have mentioned, the decisions made by hypothesis test should not be perfect, and errors occur. Indeed, when we think carefully, there are actually two types of errors, as follows:

Definition. (Type I and II errors) A type I error is the rejection of H0 when H0 is true. A type II error is the acceptance of H0 when H0 is false.

We can illustrate these two types of errors more clearly using the following table.

Type I and II errors
Accept H0 Reject H0
H0 is true Correct decision Type I error
H0 is false Type II error Correct decision

We can express H0:θ∈Θ0 and H1:θ∈Θ0c. Also, assume the rejection region is R=R(𝐗) (i.e., the rejection region with "x" replaced by "X"). In general, when "R" is put together with "X", we assume R=R(𝐗).

Then we have some notations and expressions for probabilities of making type I and II errors: (let X1,…,Xn be a random sample and 𝐗=(X1,…,Xn))

  • The probability of making a type I error, denoted by α(θ), is ℙθ(𝐗∈R) if θ∈Θ0.
  • The probability of making a type II error, denoted by β(θ), is ℙθ(𝐗∈Rc)=1−ℙθ(𝐗∈R) if θ∈Θ0c.

Remark.

  • Remark on notations: In some other places, α(θ) may be expressed as "ℙ(𝐗∈R|θ∈Θ0)", "ℙ(𝐗∈R|H0)" or "ℙ(𝐗∈R|H0 is true)". We should be careful that these notations are not supposed to interpret as conditional probabilities [3]. Instead, they are just some notations. This applies similarly to β(θ).
  • When Θ0 contains a single value only, we simply denote the type I error probability by α. Similarly, when Θ1 contains a single value only, we simply denote the type II error probability by β.

Notice that we have a common expression in both α(θ) and β(θ), which is "ℙθ((X1,…,Xn)∈R)". Indeed, we can also write this expression as ℙθ((X1,…,Xn)∈R)={α(θ),θ∈Θ0;1−β(θ),θ∈Θ0c. Through this, we can observe that this expression contains all informations about the probabilities of making errors, given a hypothesis test with rejection R. Hence, we will give a special name to it:

Definition. (Power function) Let R be a rejection region of a hypothesis test, and X1,…,Xn be a random sample. Then, the power function of the hypothesis test is π(θ)=ℙθ((X1,…,Xn)∈R) where θ∈Θ.

Remark.

  • "π" can be thought of as the Greek letter "p". We choose π instead of p since "p" is sometimes used to denote probability (mass or density) functions.
  • The power function will be our basis in evaluating the goodness of a test or comparing two different tests.

Example. Suppose we toss a (fair or unfair) coin 5 times (suppose the coin never land on edge), and we have the following hypotheses: H0:p≤12vs.H1:p>12 where p is the probability for landing on heads after tossing the coin. Let X1,…,X5 be the random sample for the 5 times of coin tossing, and x1,…,x5 be the corresponding realizations. Also, the value of a random sample is 1 if heads come up and 0 otherwise. Suppose we will reject H0 if and only if heads come up in all 5 coin tosses.

(a) Determine the rejection region R.

(b) What is the power function π(p) (express in terms of p)?

(c) Calculate α(1/2) and β(2/3).

Solution.

(a) The rejection region R={(x1,…,x5):x1+⋯+x5=5}.

(b) The power function is π(p)={ℙθ((X1,…,X5)∈R)=p5,p≤12;1−ℙθ((X1,…,X5)∈R)=1−p5,p>12.

(c) We have α(1/2)=(12)5=0.03125 and β(2/3)=1−(23)5≈0.8683. (Notice that although the probability of type I error can be low, the probability of type II error can be quite high. This is because, intuitively, it is quite "hard" to reject H0 due to the strict requirement. So, even if H0 is false, it may not be rejected, causing a type II error.)

Clipboard

Exercise. Does maxp≤12π(p) exist? If yes, calculate it.

Solution

maxp≤12π(p) exists, and maxp≤12π(p)=maxp≤12p5=(12)5=132 (notice that y=x5 is a strictly increasing function).

You notice that the type II error of this hypothesis test can be quite large, so you want to revise the test to lower the type II error.

(a) What is β(p) in the above hypothesis test?

(b) Suppose the rejection region is modified to {(x1,…,x5):x1+⋯+x5≥3}. Calculate α(1/2) and β(2/3). (Hint: consider binomial distribution.)

(c) Suppose the rejection region is modified to {(x1,…,x5):x1+⋯+x5≥2}. Calculate α(1/2) and β(2/3).

(d) α(1/2)+β(2/3) is minimized at which hypothesis test: the original one, the one in (b), or the one in (c)?

Solution

(a) β(p)=p5 if p>12.

(b) In this case, we have α(1/2)=(53)(12)3(12)2+(54)(12)4(12)+(12)5=0.5, and β(2/3)=1−(53)(23)3(13)2+(54)(23)4(13)+(23)5≈0.2099.

(c) In this case, we have α(1/2)=0.5+(52)(12)2(12)3=0.8125 and β(2/3)≈0.2099−(52)(23)2(13)3≈0.0453.

(d) At the original one, α(1/2)+β(2/3)≈0.89955, at the one in (b), α(1/2)+β(2/3)≈0.7099, and at the one in (c), α(1/2)+β(2/3)≈0.8578. So, α(1/2)+β(2/3) is minimized at the one in (b).


Example. Let X1,…,Xn be a random sample from the normal distribution 𝒩(μ,σ2) where σ2 is known. Consider the following hypotheses: H0:μ≤μ0vs.μ>μ0 where μ0 is a constant. We use the test statistic T=X‾−μ0σ/n∼𝒩(0,1) for the hypothesis testing, and we reject H0 if and only if T≥k.

Find the power function π(μ), limμ→−∞π(μ), and limμ→∞π(μ).

Solution. The power function is π(μ)=ℙμ(T≥k)=ℙμ(X‾−μ0σ/n≥k)=ℙμ(X‾−μ+μ−μ0σ/n≥k)=ℙμ(X‾−μσ/n≥k+μ0−μσ/n)=ℙ(Z≥k+μ0−μσ/n).(Z∼𝒩(0,1), which is independent from μ,so we can drop the subscript `μ' for ℙ) Thus, limμ→−∞π(μ)=ℙ(Z≥∞)=0 and limμ→∞π(μ)=ℙ(Z≥−∞)=1 (some abuse of notations), by the definition of cdf. (Indeed, π(μ) is a strictly increasing function of μ.)

Clipboard

Exercise. Show that π(μ0)=α if ℙ(Z≥k)=α.

Solution

Proof. Assume ℙ(Z≥k)=α. Then, π(μ0)=ℙ(Z≥k+0)=ℙ(Z≥k)=α.

◻



Ideally, we want to make both α(θ) and β(θ) arbitrarily small. But this is generally impossible. To understand this, we can consider the following extreme examples:

  • Set the rejection region R to be S={𝐱}, which is the set of all possible observations of random samples. Then, π(θ)=1 for each θ∈Θ. From this, of course we have β(θ)=0, which is nice. But the serious problem is that α(θ)=1 due to the mindless rejection.
  • Another extreme is setting the rejection region R to be the empty set ∅. Then, π(θ)=0 for each θ∈Θ. From this, we have α(θ)=0, which is nice. But, again the serious problem is that β(θ)=1 due to the mindless acceptance.

We can observe that to make α(θ) (β(θ)) to be very small, it is inevitable that β(θ) (α(θ)) will increase consequently, due to accepting (rejecting) "too much". As a result, we can only try to minimize the probability of making one type of error, holding the probability of making another type of error controlled.

Now, we are interested in knowing that which type of errors should be controlled. To motivate the choice, we can again consider the analogy of legal principle of presumption of innocence. In this case, type I error means proving an innocent guilty, and type II error means acquitting a guilty person. Then, as suggested by Blackstone's ratio, type I error is more serious and important than type II error. This motivates us to control the probability of type I error, i.e., α(θ), at a specified small value α∗, so that we can control the probability of making this more serious error. After that, we consider the tests that "control the type I error probability at this level", and the one with the smallest β(θ) is the "best" one (in the sense of probability of making errors).

To describe "control the type I error probability at this level" in a more precise way, let us define the following term.

Definition. (Size of a test) A test with power function π(θ) is a size α test if supθ∈Θ0π(θ)=α where 0≤α≤1.

Remark.

  • Supremum is similar to maximum, and in "nice" situations (you may assume the situations here are "nice"), supremum is the same as maximum. Hence, choosing the supremum of π(θ) over θ∈Θ0 as the size of a test means that the size of a test gives its maximum probability of type I error (reject H0 when H0 is true), considering all situations, i.e., all different possible values of θ that makes H0 true.
  • Intuitively, we choose the maximum probability of type I error to be the size so that the size can tell us how probable type I error occurs in the worst situation, to show that how "well" can the test control the type I error [4].
  • Special case: if Θ0 contains a single parameter only, say (a known value) θ0 (i.e., H0 is a simple hypothesis which states that θ=θ0), then α=π(θ0).
  • α is also called the level of significance or significance level (these terms are related to the concept of statistical (in)significance, which is in turn related to the concept of p-value. We will discuss these later.).
  • The "α" here and the "α" in the confidence coefficient can actually be interpreted as the "same", by connecting confidence intervals with hypothesis testing. We will discuss these later.
  • Because of this definition, the null hypothesis conventionally contains an equality (i.e. in the form of θ=θ0,θ≥θ0 or θ≤θ0), since the size of the test can be calculated more conveniently if this is the case.

So, using this definition, controlling the type I error probability at a particular level α means that the size of the test should not exceed α, i.e., supθ∈Θ0π(θ)≤α (in some other places, such test is called a level α test.

Example. Consider the normal distribution 𝒩(μ,1) (with the parameter space: Θ={μ:μ=20 or 21}) , and the hypotheses H0:μ=20vs.H1:μ=21 Let X1,…,X10 be a random sample from the normal distribution 𝒩(μ,1), and the corresponding realizations are x1,…,x10. Suppose the rejection region is {(x1,…,x10):x‾≥k}.

(a) Find k such that the significance level of the test is α=0.05.

(b) Calculate the type II error probability β. To have the type II error probability β≤0.05, what is the minimum sample size (with the same rejection region)?

Solution.

(a) In order for the significance level to be 0.05, we need to have supμ∈Θ0π(μ)=0.05. But Θ0={20}. So, this means 0.05=π(20)=ℙμ=20(X‾≥k)=ℙ(X‾−201/10≥k−201/10)=ℙ(Z≥10(k−20)) where Z∼𝒩(0,1). We then have 10(k−20)=z0.05≈1.64⟹k≈20.51861.

(b) The type II error probability is β≈1−ℙμ=21(X‾≥20.51861)=1−ℙ(X‾−211/10≥20.51861−211/10)≈1−ℙ(Z≥−1.522)=ℙ(Z<−1.522)≈0.06426. (Z∼𝒩(0,1)) With the sample size n, the type II error probability is β≈ℙ(Z<n(20.51861−21)) When the sample size n increases, n(20.51861−21) will become more negative, and hence the type II error probability decreases. It follows that ℙ(Z<n∗(20.51861−21)≤0.05⟹n(20.51861−21)≥−1.64⟹n≥11.603. Hence, the minimum sample size is 12.

Clipboard

Exercise. Calculate the type I error probability and type II error probability when the sample size is 12 (the rejection region remains unchanged).

Solution

The type II error probability is ℙ(Z<12(20.51861−21))≈ℙ(Z<−1.668)≈0.04746. The type I error probability is ℙ(Z≥12(20.51861−20))≈ℙ(Z≥1.797)≈0.0359. So, with the same rejection region and different sample size, the significance level (type I error probability in this case) of the test changes.


For now, we have focused on using rejection region to conduct hypothesis tests. But this is not the only way. Alternatively, we can make use of p-value.

Definition. (p-value) Let T(𝐱) be an observed value of a test statistic T(𝐗)=T(X1,…,Xn) in a hypothesis test.

  • Case 1: The test is left-tailed. Then, the p-value is supθ∈Θ0ℙθ(T(𝐗)≤T(𝐱)).
  • Case 2: The test is right-tailed. Then, the p-value is supθ∈Θ0ℙθ(T(𝐗)≥T(𝐱)).
  • Case 3: The test is two-tailed.
  • Subcase 1: The distribution of T is symmetric about zero (when H0 is true). Then, the p-value is supθ∈Θ0ℙθ(|T(𝐗)|≥|T(𝐱)|).
  • Subcase 2: The distribution of T is not symmetric about zero (when H0 is true). Then, the p-value is 2min⁡{supθ∈Θ0ℙθ(T(𝐗)≤T(𝐱)),supθ∈Θ0ℙθ(T(𝐗)≥T(𝐱))}.

Remark.

  • p-value can be interpreted as the probability of a test statistic to be at least as "extreme" as the observed test statistic in a hypothesis test, when H0 is true. Here, "extreme" is in favour of H1, i.e., the "direction of extreme" is towards the "direction of tail" for the test (when the test statistic is more towards the tail direction, it is more likely to fall in the rejection region, and therefore reject H0 and accept H1).
  • So, when the p-value is small, it implies that the observed value of the test statistic is already very "extreme", causing the test statistic to be unlikely to be even more "extreme" than the observed value.
  • In general, it can be quite difficult to compute p-values manually. Thus, p-values are often computed using software, e.g. R.
  • For case 3 subcase 1, consider the following diagram:
            pdf of T(X)
             |
           *---*
          /  |  \
         /   |   \
        /    |    \
       /|    |    |\
      /#|    |    |#\
     /##|    |    |##\    
 ---*###|    |    |###*---
 #######|    |    |#######
-------------*-------------
      ^            ^
<---->|   =====>   |<---->             T(x)<0
     T(x)         -T(x) 
"more extreme"          "more extreme"

T(X)<=T(x)          T(X)>=-T(x)          ====> |T(X)|>=|T(x)| ( T(x)=-|T(x)|, -T(x)=|T(x)|)

<-->^                ^<-->
    |                |                 T(x)>0
   -T(x)            T(x) 

T(X)<=-T(x)         T(X)>=T(x)            ====> |T(X)|>=|T(x)| (-T(x)=-|T(x)|, T(x)=|T(x)|)
  • For case 3 subcase 2, consider the following diagram:
                  pdf of T
    |
    |     /*----*
    |    /|      \
    |   /#|       \
    |  /##|        \       
    | /###|         *---|--------*
    |/####|             |#########\
----*------------------------------
        ^                      
        |
        T(x)
    |---|-------------------------|
  T(X)<=T(x)   T(X)>=T(x)       &&&&&: T(X)>= -T(x)
  choose
                              ^
                              |
                              t
    |-------------------------|---|
            T(X)<=T(x)      T(X)>=T(x)
     &&&:                      choose
    T(X)<=-T(x)
We can observe that the observed value t may lie at the left tail or right tail. In either case, for T to be "more extreme", the resulting inequality corresponds to the one with smaller probability. Thus, we have "min". But we also need to consider the "extreme" in another tail. It is intuitive to say that when T is more extreme than −t (in another tail), then T should be also considered as "more extreme". Thus, there is a "2×"

The following theorem allows us to use p-value for hypothesis testing.

Theorem. Let T(𝐱)=T(x1,…,xn) be an observed value of a test statistic T(𝐗)=T(X1,…,Xn) in a hypothesis test. The null hypothesis H0 is rejected at the significance level α if and only if the p-value is less than or equal to α.

Proof. (Partial) We can prove "if" and "only if" directions at once. Let us first consider the case 1 in the definition of p-value. By definitions, p-value is supθ∈Θ0ℙθ(T(𝐗)≤T∗(𝐱)) and α=supθ∈Θ0π(θ)=supθ∈Θ0ℙθ(T(𝐗)≤T∗(𝐱)) (Define T∗(𝐗) such that T(𝐗)≤T∗(𝐱)⟺(X1,…,Xn)∈R.). Then, we have p-value≤α⟺supθ∈Θ0ℙθ(T(𝐗)≤T(𝐱))≤supθ∈Θ0ℙθ(T(𝐗)≤T∗(𝐱))⟺T(𝐱)≤T∗(𝐱)(by some omitted arguments and the monotonicity of cdf)⟺(x1,…,xn)∈{(y1,…,yn):T(y1,…,yn)≤T∗(𝐱)}(x1,…,xn are realizations of X1,…,Xn respectively)⟺(x1,…,xn)∈R(defined above)⟺H0 is rejected at significance level α.(the test with power function π(θ) is size α test) For other cases, the idea is similar (just the directions of inequalities for T are different).

◻

Remark.

  • From this, we can observe that p-value can be used to report the test result in a more "continuous" scale, instead of just a single decision "accept H0" or "reject H0", in the sense that if p-value is "much smaller" than the significance level α, then we have a "stronger" evidence for rejecting H0 (stronger in the sense that even if the significance level is very low (a very strict requirement on type I error), H0 can still be rejected).
  • Also, reporting a p-value allows readers to choose an appropriate significance level α themselves, and compare the p-value with α, and therefore make their own decisions, which are not necessary the same as the decisions made in the test report (since readers may choose a different significance level from that of the report).
  • Here, let us also mention about the concept of statistical significance. An observation has statistical significance if it is "unlikely" to happen (i.e., the observed value is quite "extreme") when the null hypothesis is true. To be more precise, in terms of p-value, this means an observed value of a test statistic is statistically significant if p-value is less than or equal to α, and we say that the observed value is statistically insignificant otherwise. Thus, α can be interpreted as the benchmark of "significant" or "extremeness", and hence the name significance level.

Example. Recall the setting of a previous example: consider the normal distribution 𝒩(μ,1) (with the parameter space for μ: Θ={20,21}) , and the hypotheses H0:μ=20vs.H1:μ=21 Let X1,…,X10 be a random sample from the normal distribution 𝒩(μ,1), and the corresponding realizations are x1,…,x10.

At the significance level α=0.05, we have determined that the rejection region is R={(y1,…,y10):y‾≥20.51861}. Suppose it is observed that x‾=20.5.

(a) Use the rejection region to determine whether we should reject H0.

(b) Use p-value to determine whether we should reject H0.

Solution.

(a) Since x‾=20.5<20.51861, we have (x1,…,x10)∈Rc. Thus, we should not reject H0.

(b) Since the test is right-tailed, the p-value is supμ∈{20}ℙμ(X‾≥x‾)=ℙμ=20(X‾≥20.5)=ℙ(X‾−201/10≥20.5−201/10)≈ℙ(Z≥1.581)≈0.05705>α=0.05 where Z∼𝒩(0,1). Thus, H0 should not be rejected.

Clipboard

Exercise.

Choose the significance level(s) for which H0 is rejected based on the observation.

0.01
0.04
0.06
0.08
0.1

Remark.

  • From this, we can notice that one can "manipulate" the decision by changing the significance level. In fact, if one sets the significance level to be 1 , then H0 must be rejected (since p-value is a probability which must be less than or equal to 1). But such significance level is meaningless, since it means that the type I error probability can be as high as 1, so such test has a large error and the result is not reliable anyway.
  • On the other hand, if one sets the significance level to be 0, then H0 must not be rejected (unless the p-value is exactly zero, which is very unlikely, since zero p-value means that the observation is the most extreme one, so it is (almost) never for the test statistic to be at least as extreme as the observation.).



Evaluating a hypothesis test

[edit | edit source]

After discussing some basic concepts and terminologies, let us now study some ways to evaluate goodness of a hypothesis test. As we have previously mentioned, we want the probability of making type I errors and type II errors to be small, but we have mentioned that it is generally impossible to make both probabilities to be arbitrarily small. Hence, we have suggested to control the type I error, using the size of a test, and the "best" test should the one with the smallest probability of making type II error, after controlling the type I error.

These ideas lead us to the following definitions.

Definition. (Power of a test) The power of a test is the probability of rejecting H0 when H0 is false. That is, the power is 1−β, if the probability of making type II error is β.

Using this definition, instead of saying "best" test (test with the smallest type II error probability), we can say "a test with the most power", or in other words, the "most powerful test".

Definition. (Uniformly most powerful test) A test φ with rejection region R is a uniformly most powerful (UMP) test with size α for testing H0:θ∈Θ0vs.H1:θ∈Θ1 (Θ1=Θ0c) if

  • (size of φ) supθ∈Θ0πφ(θ0)=α, and
  • (UMP) πφ(θ1)≥πψ(θ1) for each θ∈Θ1 and for each test ψ with rejection region R∗≠R and πψ(θ0)≤α (πψ(⋅) is the power function of the test ψ).

(πφ(⋅) and πψ(⋅) are the power functions of the tests φ and ψ respectively.)

Remark.

  • The rejection region R is sometimes called a best rejection region of size α.
  • In other words, a test is UMP with size α if it has size α and its power is the largest among all other tests with size less than or equal to α, for each θ∈Θ1. The adverb "uniformly" emphasizes that this is true for each θ∈Θ1.
  • Since the power is largest for each value of θ∈Θ1, the rejection region R of the UMP test does not depend on the choice of θ∈Θ1, that is, regardless of the chosen value of θ∈Θ1, the rejection region is the same. This is expected since the rejection region R is not supposed to be changed when the choice of θ∈Θ1 is different. The rejection region R (fixed) should always be the best, for each θ∈Θ1.
  • If H1 is simple, we may simply call the UMP test as the most powerful (MP) test.

Constructing a hypothesis test

[edit | edit source]

There are many ways of constructing a hypothesis test, but of course not all are good (i.e., "powerful"). In the following, we will provide some common approaches to construct hypothesis tests. In particular, the following lemma is very useful for constructing a MP test with size α.

Neyman-Pearson lemma

[edit | edit source]

Lemma. (Neyman-Pearson lemma) Let X1,…,Xn be a random sample from a population with pdf or pmf f(x;θ) (θ may be a parameter vector, and the parameter space is Θ={θ0,θ1}). Let ℒ(⋅) be the likelihood function. Then a test φ with rejection region R={(x1,…,xn):ℒ(θ0;𝐱)ℒ(θ1;𝐱)≤k} and size α is the MP test with size α for testing H0:θ=θ0vs.H1:θ=θ1 where k is a value determined by the size α.

Proof. Let us first consider the case where the underlying distribution is continuous. With the assumption that the size of φ is α, the "size" requirement for being a UMP test is satisfied immediately. So, it suffices to show that φ satisfies the "UMP" requirement for being a MP test.

Notice that in this case, "Θ1" is simply {θ1}. So, for every test ψ with rejection region R∗≠R and πψ(θ0)≤α, we will proceed to show that πφ(θ1)≥πψ(θ1).

Since πφ(θ1)−πψ(θ1)=ℙθ1((X1,…,Xn)∈R)−ℙθ1((X1,…,Xn)∈R∗)=∫⋯∫Rℒ(θ1;𝐱)dxn⋯dx1−∫⋯∫R∗ℒ(θ1;𝐱)dxn⋯dx1=∫⋯∫Rℒ(θ1;𝐱)dxn⋯dx1−∫⋯∫R∩R∗ℒ(θ1;𝐱)dxn⋯dx1−(∫⋯∫R∗ℒ(θ1;𝐱)dxn⋯dx1−∫⋯∫R∩R∗ℒ(θ1;𝐱)dxn⋯dx1)=∫⋯∫R∖R∗ℒ(θ1;𝐱)dxn⋯dx1−∫⋯∫R∗∖Rℒ(θ1;𝐱)dxn⋯dx1≥1k∫⋯∫R∖R∗ℒ(θ0;𝐱)dxn⋯dx1−1k∫⋯∫R∗∖Rℒ(θ0;𝐱)dxn⋯dx1(In R,ℒ(θ1;𝐱)≥1kℒ(θ0;𝐱). In Rc,ℒ(θ1;𝐱)<1kℒ(θ0;𝐱)⟺−ℒ(θ1;𝐱)>−1kℒ(θ0;𝐱))=1k∫⋯∫R∖R∗ℒ(θ0;𝐱)dxn⋯dx1+1k∫⋯∫R∩R∗ℒ(θ0;𝐱)dxn⋯dx1−(1k∫⋯∫R∗∖Rℒ(θ0;𝐱)dxn⋯dx1+1k∫⋯∫R∩R∗ℒ(θ0;𝐱)dxn⋯dx1)=1k∫⋯∫Rℒ(θ0;𝐱)dxn⋯dx1−1k∫⋯∫R∗ℒ(θ0;𝐱)dxn⋯dx1=1k(ℙθ0((X1,…,Xn)∈R)⏟=α−ℙθ0((X1,…,Xn)∈R∗)⏟≤α)≥1k(α−α)=0, we have πϕ(θ1)≥πψ(θ1) as desired.

For the case where the underlying distribution is discrete, the proof is very similar (just replace the integrals with sums), and hence omitted.

◻

Remark.

  • Sometimes, we call ℒ(θ0;𝐱)ℒ(θ1;𝐱) as the likelihood ratio.
  • In fact, the MP test constructed by Neyman-Pearson lemma is a variant from the likelihood-ratio test, which is more general in the sense that the likelihood-ratio test can also be constructed for composite null and alternative hypotheses, apart from simple null and alternative hypotheses directly. But, the likelihood-ratio test may not be (U)MP. We will discuss likelihood-ratio test later.
  • For the discrete distribution, it may be impossible to determine a k for the rejection R for some α. In this case, we call such α to be not attainable.
  • Intuitively, this test means that we should reject H0 when "likelihood" of H0 (ℒ(θ0;𝐱)) is not as large as the "likelihood" of H1 (ℒ(θ1;𝐱)) (ℒ(θ0;𝐱)≤kℒ(θ0;𝐱)), with respect to the observed samples. For the meaning of "not as large as", it depends on the size α.
  • Intuitively, we will expect that k should be a positive value that is strictly less than 1, so that H0 is "less likely" than H1. This is usually, but not necessarily, the case. Particularly, when the size α is large, k may be greater than 1.
  • Typically, to determine the value of k, we need to transform "ℒ(θ0;𝐱)ℒ(θ1;𝐱)≤k" to another equivalent inequality for which the probability under H0 is easier to be calculated.
  • It must be equivalent, so that its probability under H0 is the same as probability of "ℒ(θ0;𝐱)ℒ(θ1;𝐱)≤k" under H0. As a result, during the process of the transformation, it is better to use "⟺", instead of just "⟹", or even writing different inequalities line by line.
  • If θ is a vector, then θ0 and θ1 should also be vectors.

Even if the hypotheses involved in the Neyman-Pearson lemma are simple, with some conditions, we can use the lemma to construct a UMP test for testing composite null hypothesis against composite alternative hypothesis. The details are as follows: For testing H0:θ≤θ0vs.H1:θ>θ0

  1. Find a MP test φ with size α, for testing H0:θ=θ0vs.H1:θ=θ1>θ0 using the Neyman-Pearson lemma, where θ1 is an arbitrary value such that θ1>θ0.
  2. If the rejection region R does not depend on θ1, then the test φ has the greatest power for each θ∈Θ1={ϑ:ϑ>θ0}. So, the test φ is a UMP test with size α for testing H0:θ=θ0vs.H1:θ>θ0
  3. If we can further show that supθ≤θ0πφ(θ)=α=πφ(θ0), then it means that the size of the test φ is still α, even if the null hypothesis is changed to H0:θ≤θ. So, after changing H0:θ=θ0 to H0:θ≤θ0 and not changing H1 (also adjusting the parameter space) for the test φ, the test φ still satisfies the "MP" requirement (because of not changing H1, so the result in step 2 still applies), and also the test φ will satisfy the "size" requirement (because of changing H0 in this way). Hence, the test φ is a UMP test with size α for testing H0:θ≤θ0vs.H1:θ>θ0.

For testing H0:θ≥θ0vs.H1:θ<θ0, the steps are similar. But in general, there is no UMP test for testing H0:θ=θ0vs.H1:θ≠θ0.

Of course, when the condition in step 3 holds but that in step 2 does not hold, the test φ in step 1 is a UMP test with size α for testing H0:θ≤θ0vs.H1:θ=θ1 where θ1 is a constant (which is larger than θ0, or else H1 and H0 are not disjoint). However, the hypotheses are generally not in this form.

Example. Let X1,…,X10 be a random sample from the normal distribution 𝒩(μ,1).

(a) Construct a MP test φ with size 0.05 for testing H0:μ=20vs.H1:μ=21.

(b) Hence, show that the test φ is also a UMP test with size 0.05 for testing H0:μ=20vs.H1:μ>20.

(c) Hence, show that the test φ is also a UMP test with size 0.05 for testing H0:μ≤20vs.H1:μ>20.

Solution. (a) We can use the Neyman-Pearson lemma. First, consider the likelihood ratio ℒ(20)ℒ(21)=(12π(1))10∏i=110exp⁡(−(xi−20)22)(12π(1))10∏i=110exp⁡(−(xi−21)22)=exp⁡(−12∑i=110[(xi−20)2−(xi−21)2])=exp⁡(−12∑i=110[xi2−40xi+400−xi2+42xi−441])=exp⁡(−12∑i=110[2xi−41])=exp⁡(412−∑i=110xi). Now, we have ℒ(20)ℒ(21)≤k′⟺exp⁡(412−10x‾)≤k′⟺−10x‾≤k″⟺x‾≥k where k,k′,k″ are some constants. To find k, consider the size 0.05: 0.05=ℙμ=20(X‾≥k)=ℙμ=20(X‾−201/10≥k−201/10)=ℙ(Z≥10(k−20)). (Z∼𝒩(0,1)) Hence, we have 10(k−20)≈1.64⟹k≈20.51861. Now, we can construct the rejection region: R={(x1,…,xn):x‾≥20.51861}, and the test φ with the rejection region R is a MP test with size 0.05 for testing H0:μ=20vs.μ=21.

(b)

Proof. Let μ1 be an arbitrary value such that μ1>20. Then, we can show that (see the following exercise) ℒ(20)ℒ(μ1)≤k′⟺x‾≥k where k,k′ are some constants (may be different from the above constants). Since H0 here is the same as H0 in (a), the rejection region constructed is also R={(x1,…,xn):x‾≥20.51861}. Notice that R does not depend on the value of μ1. It follows that the test φ is a UMP test with size 0.05 for testing H0:μ=20vs.μ>20.

◻


(c)

Proof. It suffices to show that supμ≤20πφ(μ)=0.05=(a)πφ(20). First let us consider the power function πφ(μ)=ℙμ(X‾≥20.51861)=ℙμ(Z≥10(20.51861−μ))=1−Φ(10(20.51861−μ)) where Φ(⋅) is the cdf of Z∼𝒩(0,1). Now, since when μ increases, 10(20.51861−μ) decreases and hence Φ(10(20.51861−μ)) decreases, it follows that the power function πφ(μ) is a strictly increasing function of μ. Hence, supμ≤20πφ(μ)=maxμ≤20πφ(μ)=πφ(20)=0.05. Then, the result follows.

◻

Clipboard

Exercise. Show that ℒ(20)ℒ(μ1)≤k′⟺x‾≥k for every μ1>20.

Solution

Proof. First, consider the likelihood ratio ℒ(20)ℒ(μ1)=exp⁡(−12∑i=110[(xi−20)2−(xi−μ1)2])=exp⁡(−12∑i=110[xi2−40xi+400−xi2+2μ1xi−μ12])=exp⁡(−12∑i=110[(2μ1−40)xi+400−μ12])=exp⁡(μ12−4002−(μ1−20)∑i=110xi). Then, we have ℒ(20)ℒ(μ1)≤k′⟺exp⁡(μ12−4002−(μ1−20)nx‾)≤k′⟺−(μ1−20)nx‾≤k″⟺x‾≥k. (The last equivalence follows since μ1>20.)

◻



Remark.

  • This rejection region has appeared in a previous example.

Now, let us consider another example where the underlying distribution is discrete.

Example. Let X be a discrete random variable. Its pmf is given by θx123456780f(x;θ)00.020.020.020.020.020.020.881f(x;θ)0.010.020.030.040.0500.060.79 (Notice that the sum of values in each row is 1. The parameter space is Θ={0,1}.) Given a single observation x, construct a MP test with size 0.1 for testing H0:θ=0vs.H1:θ=1.

Solution. We use the Neyman-Pearson lemma. First, we calculate the likelihood ratio f(x;0)/f(x;1) for each value of x: x12345678f(x;0)f(x;1)010.6670.50.4undefined0.3331.114 For convenience, let us sort the likelihood ratios in ascending order (we put the undefined value at the last): x17543286f(x;0)f(x;1)00.3330.40.50.66711.114undefined By Neyman-Pearson lemma, the MP test with size 0.1 for testing H0:θ=0vs.H1:θ=1 is a test with size 0.1 and rejection region R={x:f(x;0)f(x;1)≤k}. So, it remains to determine R. Since the size is 0.1, we have 0.1=α(0)=ℙθ=0(X∈R). Notice that ℙθ=0(X=1)+ℙθ=0(X=7)+ℙθ=0(X=5)+ℙθ=0(X=4)+ℙθ=0(X=3)+ℙθ=0(X=2)=0+0.02+0.02+0.02+0.02+0.02=0.1. So, we can choose k∈[1,1.114) (approximately), so that rejection region is {x:f(x;0)f(x;1)≤k}={1,7,5,4,3,2}.

Clipboard

Exercise. Calculate the probability of making type II error for the above test.

Solution

The probability is β(1)=ℙθ=1(X∈Rc)=ℙθ=1(X=8)+ℙθ=1(X=6)=0.79. (Notice that although the test is MP, the type II error probability is still quite large in this case.)

Use Neyman-Pearson lemma to construct another MP test with size 0.05 for testing H0:θ=0vs.H1:θ=1.

Solution

It is impossible to construct the MP test with this size using Neyman-Pearson lemma, since we are unable to choose a k such that ℙθ=0(X∈R). We can choose k∈[0.333,0.4) (approximately) for the size to be 0.04, or choose k∈[0.4,0.5) for the size to be 0.06, but we are impossible to choose a k for the size to be 0.05.



Likelihood-ratio test

[edit | edit source]

Previously, we have suggested using the Neyman-Pearson lemma to construct MPT for testing simple null hypothesis against simple alternative hypothesis. However, when the hypotheses are composite, we may not be able to use the Neyman-Pearson lemma. So, in the following, we will give a general method for constructing tests for any hypotheses, not limited to simple hypotheses. But we should notice that the tests constructed are not necessarily UMPT.

Definition. (Likelihood ratio test) Let λ(𝐱)=supθ∈Θ0ℒ(θ;𝐱)supθ∈Θℒ(θ;𝐱). The likelihood ratio test with size α for testing H0:θ∈Θ0vs.H1:θ∈Θ1 (Θ1=Θ0c, and θ may be a vector) has the rejection region {𝐱:λ(𝐱)≤k} where k is a constant determined by the size α.

Remark.

  • When maxθ∈Θ0ℒ(θ;𝐱) and maxθ∈Θℒ(θ;𝐱) exist, we have λ(𝐱)=ℒ(θ̂R;𝐱)ℒ(θ̂;𝐱) where θ̂R is the restricted maximum likelihood estimate of θ in Θ0, and θ̂ is the maximum likelihood estimate of θ in Θ. We can assume the existence in the following.
  • Since Θ0⊆Θ, ℒ(θ̂R;𝐱)≤ℒ(θ̂;𝐱), so we have λ(𝐱)≤1.
  • Intuitively, when λ(𝐱) is very small, i.e., ℒ(θ̂R;𝐱)≪ℒ(θ̂;𝐱), it suggests that there are many θ falling Θ1 that are more likely than all θ in Θ0. So, H0 should be intuitively rejected.
  • On the other hand, when λ(𝐱) is very close to 1, i.e., ℒ(θ̂R;𝐱)≲ℒ(θ̂;𝐱), it suggests that there are very few θ falling in Θ1 that are more likely than all θ in Θ0. So, H0 should be intuitively not rejected.
  • When the simple and alternative hypotheses are simple, the likelihood ratio test will be the same as the test suggested in the Neyman-Pearson lemma.


Relationship between hypothesis testing and confidence intervals

[edit | edit source]

We have mentioned that there are similarities between hypothesis testing and confidence intervals. In this section, we will introduce a theorem suggesting how to construct a hypothesis test from a confidence interval (or in general, confidence set), and vice versa.

Theorem. For each θ0∈Θ, let R(θ0) be the rejection region of a size α test for testing H0:θ=θ0vs.H1:θ≠θ0. Also, let x1,…,xn be the corresponding realizations of a random sample X1,…,Xn from the underlying distribution. Furthermore, let 𝐱=(x1,…,xn) and 𝐗=(X1,…,Xn).

Define a set C(𝐱)={θ0:𝐱∈R(θ0)c}. Then, the random set C(𝐗) is a 1−α confidence set of θ0.

Conversely, let a set C∗(𝐗) be a 1−α confidence set of an unknown parameter θ. For each θ0∈Θ, define R(θ0)={𝐱:θ0∉C∗(𝐱)}. Then, R(θ0) is the rejection region of a size α test for testing H0:θ=θ0vs.H1:θ≠θ0.

Proof. For the first part, since R(θ0) is the rejection region of the size α test, we have ℙθ0(𝐗∈R)=α. Hence, the coverage probability for the random set C(𝐗) is ℙθ0(θ0∈C(𝐗))=ℙθ0(𝐗∈Rc)=1−α, which means that the random set C(𝐗) is a 1−α confidence set of θ0.

For the second part, by assumption, we have ℙθ(θ∈C∗(𝐗))=1−α. So, the size of the test with the rejection region R(θ0) is ℙθ=θ0(𝐗∈R(θ0))=ℙθ=θ0(θ0=θ∉C∗(𝐗))=1−(1−α)=α.

◻

Remark.

  • The "θ0" can take arbitrary value in Θ. So, one can take θ0 as the unknown parameter of a distribution.
  • Usually, the first result is more useful. But, the second result justifies our intuition that given a confidence interval of an unknown parameter θ, if a particular value θ0 lies in the confidence interval, then we are "1−α" confident that θ=θ0. Now, from this theorem, we know that we can interpret "being 1−α confident that θ=θ0" as "accepting θ=θ0 at the significance level α".
  • For example, if a 95% confidence interval of θ is [−1,1], and since 0∈[−1,1], we intuitively say that we are 95% confident that θ=0. Now, we can say, more formally, we accept θ=0 at the significance level α=0.05.
  • So, the relationship between the confidence coefficient 1−α and the significance level α is now clear.
  • In some places, given some observed values, when a 1−α confidence interval of θ−θ′ includes zero, then θ has only statistically insignificant difference from θ′. This saying is natural when we consider the relationship between confidence coefficient and the significance level.
  • Since 0 is included in the confidence interval, we accept (and do not reject) θ−θ′=0⟹θ=θ′ at the significance level α=0.05. This means that the observed values are statistically insignificant. Hence, we have such saying.


  1. ↑ If Θ0 is empty, then this hypothesis has no meaning at all, so we are not interested in this case.
  2. ↑ Thus, a natural measure of "goodness" of a hypothesis test is its "size of errors". We will discuss these later in this chapter.
  3. ↑ This is because it is meaningless to condition on "θ∈Θ0" or "H0 (is true)" which are not random, and hence has probability zero or one. When the probability is zero, the "conditional probability" is not defined. When the probability is one, conditional on it is the same as not conditional on it.
  4. ↑ Even when a test has low probability of making type I error for most parameter values in Θ0, if the test has a high probability of making type I error for a certain parameter value in Θ0, then this intuitively means that the test does not control the type I error well, right?