Springer Texts in Statistics

All of StatisticsA Concise Course in Statistical Inference

Larry Wasserman1

(1)

Department of Statistics, Carnegie Mellon University, Baker Hall 228A, 15213-3890, Pittsburgh, PA, USA

Larry Wasserman

Email: larry@stat.cmu.edu

ISSN 1431-875X

ISBN 978-1-4419-2322-6ISBN 978-0-387-21736-9 (eBook)

DOI 10.1007/978-0-387-21736-9

© Springer Science+Business Media New York 2004

Originally published by Springer Science+Business Media, Inc in 2004

Softcover reprint of the hardcover 1st edition 2004

All rights reserved. This work may not be translated or copied in whole or in part without the written permission of the publisher (Springer Science+Business Media, LLC), except for brief excerpts in connection with reviews or scholarly analysis.

Use in connection with any form of information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed is forbidden.

The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights.

www.springer.com

Preface

Taken literally, the title “All of Statistics” is an exaggeration. But in spirit, the title is apt, as the book does cover a much broader range of topics than a typical introductory book on mathematical statistics.

This book is for people who want to learn probability and statistics quickly. It is suitable for graduate or advanced undergraduate students in computer science, mathematics, statistics, and related disciplines. The book includes modern topics like nonparametric curve estimation, bootstrapping, and classification, topics that are usually relegated to follow-up courses. The reader is presumed to know calculus and a little linear algebra. No previous knowledge of probability and statistics is required.

Statistics, data mining, and machine learning are all concerned with collecting and analyzing data. For some time, statistics research was conducted in statistics departments while data mining and machine learning research was conducted in computer science departments. Statisticians thought that computer scientists were reinventing the wheel. Computer scientists thought that statistical theory didn’t apply to their problems.

Things are changing. Statisticians now recognize that computer scientists are making novel contributions while computer scientists now recognize the generality of statistical theory and methodology. Clever data mining algorithms are more scalable than statisticians ever thought possible. Formal statistical theory is more pervasive than computer scientists had realized.

Students who analyze data, or who aspire to develop new methods for analyzing data, should be well grounded in basic probability and mathematical statistics. Using fancy tools like neural nets, boosting, and support vector machines without understanding basic statistics is like doing brain surgery before knowing how to use a band-aid.

But where can students learn basic probability and statistics quickly? Nowhere. At least, that was my conclusion when my computer science colleagues kept asking me: “Where can I send my students to get a good understanding of modern statistics quickly?” The typical mathematical statistics course spends too much time on tedious and uninspiring topics (counting methods, two dimensional integrals, etc.) at the expense of covering modern concepts (bootstraping, curve estimation, graphical models, etc.). So I set out to redesign our undergraduate honors course on probability and mathematical statistics. This book arose from that course. Here is a summary of the main features of this book.

1.

The book is suitable for graduate students in computer science and honors undergraduates in math, statistics, and computer science. It is also useful for students beginning graduate work in statistics who need to fill in their background on mathematical statistics.

2.

I cover advanced topics that are traditionally not taught in a first course. For example, nonparametric regression, bootstrapping, density estimation, and graphical models.

3.

I have omitted topics in probability that do not play a central role in statistical inference. For example, counting methods are virtually absent.

4.

Whenever possible, I avoid tedious calculations in favor of emphasizing concepts.

5.

I cover nonparametric inference before parametric inference.

6.

I abandon the usual “First Term = Probability” and “Second Term = Statistics” approach. Some students only take the first half and it would be a crime if they did not see any statistical theory. Furthermore, probability is more engaging when students can see it put to work in the context of statistics. An exception is the topic of stochastic processes which is included in the later material.

7.

The course moves very quickly and covers much material. My colleagues joke that I cover all of statistics in this course and hence the title. The course is demanding but I have worked hard to make the material as intuitive as possible so that the material is very understandable despite the fast pace.

8.

Rigor and clarity are not synonymous. I have tried to strike a good balance. To avoid getting bogged down in uninteresting technical details, many results are stated without proof. The bibliographic references at the end of each chapter point the student to appropriate sources.

9.

On my website are files with R code which students can use for doing all the computing. The website is:
http://www.stat.cmu.edu/~larry/all-of-statistics
However, the book is not tied to R and any computing language can be used.

Part I of the text is concerned with probability theory, the formal language of uncertainty which is the basis of statistical inference. The basic problem that we study in probability is:

Given a data generating process, what are the properties of the outcomes?

Part II is about statistical inference and its close cousins, data mining and machine learning. The basic problem of statistical inference is the inverse of probability:

Given the outcomes, what can we say about the process that generated the data?

These ideas are illustrated in Figure 1. Prediction, classification, clustering, and estimation are all special cases of statistical inference. Data analysis, machine learning and data mining are various names given to the practice of statistical inference, depending on the context.

FIGURE 1.

Probability and inference.

Part III applies the ideas from Part II to specific problems such as regression, graphical models, causation, density estimation, smoothing, classification, and simulation. Part III contains one more chapter on probability that covers stochastic processes including Markov chains.

I have drawn on other books in many places. Most chapters contain a section called Bibliographic Remarks which serves both to acknowledge my debt to other authors and to point readers to other useful references. I would especially like to mention the books by DeGroot and Schervish (2002) and Grimmett and Stirzaker (1982) from which I adapted many examples and exercises.

As one develops a book over several years it is easy to lose track of where presentation ideas and, especially, homework problems originated. Some I made up. Some I remembered from my education. Some I borrowed from other books. I hope I do not offend anyone if I have used a problem from their book and failed to give proper credit. As my colleague Mark Schervish wrote in his book (Schervish (1995)),

“.... the problems at the ends of each chapter have come from many sources. ... These problems, in turn, came from various sources unknown to me ... If I have used a problem without giving proper credit, please take it as a compliment.”

I am indebted to many people without whose help I could not have written this book. First and foremost, the many students who used earlier versions of this text and provided much feedback. In particular, Liz Prather and Jennifer Bakal read the book carefully. Rob Reeder valiantly read through the entire book in excruciating detail and gave me countless suggestions for improvements. Chris Genovese deserves special mention. He not only provided helpful ideas about intellectual content, but also spent many, many hours writing for the book. The best aspects of the book’s layout are due to his hard work; any stylistic deficiencies are due to my lack of expertise. David Hand, Sam Roweis, and David Scott read the book very carefully and made numerous suggestions that greatly improved the book. John Lafferty and Peter Spirtes also provided helpful feedback. John Kimmel has been supportive and helpful throughout the writing process. Finally, my wife Isabella Verdinelli has been an invaluable source of love, support, and inspiration.

Larry Wasserman

Pittsburgh, Pennsylvania

July 2003

Statistics/Data Mining Dictionary

Statisticians and computer scientists often use different language for the same thing. Here is a dictionary that the reader may want to return to throughout the course.

Statistics

Computer Science

Meaning

estimation

learning

using data to estimate an unknown quantity

classification

supervised learning

predicting a discrete Y from X

clustering data covariates classifier

unsupervised learning training sample features hypothesis

putting data into groups (X₁, Y₁), ..., (Xn, Yn) the Xi’s a map from covariates to outcomes

hypothesis

—

subset of a parameter space Ɵ

confidence interval

—

interval that contains an unknown quantity with given frequency

directed acyclic graph

Bayes net

multivariate distribution with given conditional independence relations

Bayesian inference

Bayesian inference

statistical methods for using data to update beliefs

frequentist inference

—

statistical methods with guaranteed frequency behavior

large deviation bounds

PAC learning

uniform bounds on probability of errors

Part I
Probability

1
Probability

Larry Wasserman1

(1)

Department of Statistics, Carnegie Mellon University, Baker Hall 228A, 15213-3890, Pittsburgh, PA, USA

Larry Wasserman

Email: larry@stat.cmu.edu

1.1 Introduction

Probability is a mathematical language for quantifying uncertainty. In this Chapter we introduce the basic concepts underlying probability theory. We begin with the sample space, which is the set of possible outcomes.

1.2 Sample Spaces and Events

The sample space Ω is the set of possible outcomes of an experiment. Points ω in Ω are called sample outcomes, realizations, or elements. Subsets of Ω are called Events.

1.1 Example. If we toss a coin twice then Ω = {HH, HT, TH, TT}. The event that the first toss is heads is A = {HH, HT}. ■

1.2 Example. Let ω be the outcome of a measurement of some physical quantity, for example, temperature. Then Ω = ℝ = (−∞, ∞). One could argue that taking Ω = ℝ is not accurate since temperature has a lower bound. But there is usually no harm in taking the sample space to be larger than needed. The event that the measurement is larger than 10 but less than or equal to 23 is A = (10, 23]. ■

1.3 Example. If we toss a coin forever, then the sample space is the infinite set

Let E be the event that the first head appears on the third toss. Then

Given an event A, let Ac = {ω ∈ Ω: ω ∉ A} denote the complement of A. Informally, Ac can be read as “not A.” The complement of Ω is the empty set . The union of events A and B is defined

which can be thought of as “A or B.” If A₁, A₂, ... is a sequence of sets then

The intersection of A and B is

read “A and B.” Sometimes we write A ∩ B as AB or (A, B). If A₁, A₂, ... is a sequence of sets then

The set difference is defined by A − B = {ω: ω ∈ A, ω ∉ B}. If every element of A is also contained in B we write A ⊂ B or, equivalently, B ⊃ A. If A is a finite set, let |A| denote the number of elements in A. See the following table for a summary.

Summary of Terminology

Ω

sample space

ω

outcome (point or element)

A

event (subset of Ω)

Ac

complement of A (not A)

A ∪ B

union (A or B)

A ∩ B or AB

intersection (A and B)

A − B

set difference (ω in A but not in B)

A ⊂ B

set inclusion

null event (always false)

Ω

true event (always true)

We say that A₁, A₂, ... are disjoint or are mutually exclusive if Ai ∩ Aj = whenever i ≠ j. For example, A₁ = [0, 1), A₂ = [1, 2), A₃ = [2, 3), ... are disjoint. A partition of Ω is a sequence of disjoint sets A₁, A₂, ... such that . Given an event A, define the indicator function of A by

A sequence of sets A₁, A₂, ... is monotone increasing if A₁ ⊂ A₂ ⊂ ⋯ and we define . A sequence of sets A₁, A₂, ... is monotone decreasing if A₁ ⊃ A₂ ⊃ ⋯ and then we define limn→∞ An = . In either case, we will write An → A.

1.4 Example. Let Ω = ℝ and let Ai = [0, 1/i) for i = 1, 2, ... . Then [0, 1) and = {0}. If instead we define Ai = (0, 1/i) then (0, 1) and . ■

1.3 Probability

We will assign a real number ℙ(A) to every event A, called the probability of A.¹ We also call ℙ a probability distribution or a probability measure. To qualify as a probability, ℙ must satisfy three axioms:

1.5 Definition. A function ℙ that assigns a real number ℙ(A) to each event A is a probability distribution or a probability measure if it satisfies the following three axioms:

Axiom 1:

ℙ(A) ≥ 0 for every A

Axiom 2:

ℙ(Ω) = 1

Axiom 3:

If A₁, A₂, ... are disjoint then

There are many interpretations of ℙ(A). The two common interpretations are frequencies and degrees of beliefs. In the frequency interpretation, ℙ(A) is the long run proportion of times that A is true in repetitions. For example, if we say that the probability of heads is 1/2, we mean that if we flip the coin many times then the proportion of times we get heads tends to 1/2 as the number of tosses increases. An infinitely long, unpredictable sequence of tosses whose limiting proportion tends to a constant is an idealization, much like the idea of a straight line in geometry. The degree-of-belief interpretation is that ℙ(A) measures an observer’s strength of belief that A is true. In either interpretation, we require that Axioms 1 to 3 hold. The difference in interpretation will not matter much until we deal with statistical inference. There, the differing interpretations lead to two schools of inference: the frequentist and the Bayesian schools. We defer discussion until Chapter 11.

One can derive many properties of ℙ from the axioms, such as:

(1.1)

A less obvious property is given in the following Lemma.

1.6 Lemma. For any events A and B,

Proof . Write A ∪ B = (ABc) ∪ (AB) ∪ (AcB) and note that these events are disjoint. Hence, making repeated use of the fact that ℙ is additive for disjoint events, we see that

1.7 Example. Two coin tosses. Let H₁ be the event that heads occurs on toss 1 and let H₂ be the event that heads occurs on toss 2. If all outcomes are equally likely, then ■

1.8 Theorem (Continuity of Probabilities). If An → A then

as n → ∞.

Proof. Suppose that An is monotone increasing so that A₁ ⊂ A₂ ⊂ ⋯. Let . Define B₁ = A₁, B₂ = {ω ∈ Ω: ω ∈ A₂, ω ∉ A₁}, B₃ = {ω ∈ Ω: ω ∈ A₃, ω ∉ A₂, ω ∉ A₁}, ... It can be shown that B₁, B₂, ... are disjoint, for each n and . (See exercise 1.) From Axiom 3,

and hence, using Axiom 3 again,

1.4 Probability on Finite Sample Spaces

Suppose that the sample space Ω = {ω₁, ..., ωn} is finite. For example, if we toss a die twice, then Ω has 36 elements: Ω = {(i, j); i, j ∈ {1, ... 6}}. If each outcome is equally likely, then ℙ(A) = |A|/36 where |A| denotes the number of elements in A. The probability that the sum of the dice is 11 is 2/36 since there are two outcomes that correspond to this event.

If Ω is finite and if each outcome is equally likely, then

which is called the uniform probability distribution. To compute probabilities, we need to count the number of points in an event A. Methods for counting points are called combinatorial methods. We needn’t delve into these in any great detail. We will, however, need a few facts from counting theory that will be useful later. Given n objects, the number of ways of ordering these objects is n! = n(n − 1)(n − 2) ⋯ 3 · 2 · 1. For convenience, we define 0! = 1. We also define

(1.2)

read “n choose k”, which is the number of distinct ways of choosing k objects from n. For example, if we have a class of 20 people and we want to select a committee of 3 students, then there are

possible committees. We note the following properties:

1.5 Independent Events

If we flip a fair coin twice, then the probability of two heads is ½ × ½. We multiply the probabilities because we regard the two tosses as independent. The formal definition of independence is as follows:

1.9 Definition. Two events A and B are independent if

(1.3)

and we write A ∐ B. A set of events {Ai: i ∈ I} is independent if

for every finite subset J of I. If A and B are not independent, we write

Independence can arise in two distinct ways. Sometimes, we explicitly assume that two events are independent. For example, in tossing a coin twice, we usually assume the tosses are independent which reflects the fact that the coin has no memory of the first toss. In other instances, we derive independence by verifying that ℙ(AB) = ℙ(A)ℙ(B) holds. For example, in tossing a fair die, let A = {2, 4, 6} and let B = {1, 2, 3, 4}. Then, A ∩ B = {2, 4}, ℙ(AB) = 2/6 = ℙ(A)ℙ(B) = (1/2) × (2/3) and so A and B are independent. In this case, we didn’t assume that A and B are independent — it just turned out that they were.

Suppose that A and B are disjoint events, each with positive probability. Can they be independent? No. This follows since ℙ(A)ℙ(B) > 0 yet ℙ(AB) = ℙ() = 0. Except in this special case, there is no way to judge independence by looking at the sets in a Venn diagram.

1.10 Example. Toss a fair coin 10 times. Let A = “at least one head.” Let Tj be the event that tails occurs on the jth toss. Then

1.11 Example. Two people take turns trying to sink a basketball into a net. Person 1 succeeds with probability 1/3 while person 2 succeeds with probability 1/4. What is the probability that person 1 succeeds before person 2? Let E denote the event of interest. Let Aj be the event that the first success is by person 1 and that it occurs on trial number j. Note that A₁, A₂, ... are disjoint and that . Hence,

Now, ℙ(A₁) = 1/3. A₂ occurs if we have the sequence person 1 misses, person 2 misses, person 1 succeeds. This has probability ℙ(A₂) = (2/3) (3/4) (1/3) = (1/2) (1/3). Following this logic we see that ℙ(Aj) = (1/2)j−1 (1/3). Hence,

Here we used that fact that, if 0 < r < 1 then . ■

Summary of Independence

1.

A and B are independent if and only if ℙ(AB) = ℙ(A)ℙ(B).

2.

Independence is sometimes assumed and sometimes derived.

3.

Disjoint events with positive probability are not independent.

1.6 Conditional Probability

Assuming that ℙ(B) > 0, we define the conditional probability of A given that B has occurred as follows:

1.12 Definition. If ℙ(B) > 0 then the conditional probability of A given B is

(1.4)

Think of ℙ(A|B) as the fraction of times A occurs among those in which B occurs. For any fixed B such that ℙ(B) > 0, ℙ(· |B) is a probability (i.e., it satisfies the three axioms of probability). In particular, ℙ(A|B) ≥ 0, ℙ(Ω|B) = 1 and if A₁, A₂, ... are disjoint then . But it is in general not true that ℙ(A|B ∪ C) = ℙ(A|B) + ℙ(A|C). The rules of probability apply to events on the left of the bar. In general it is not the case that ℙ(A|B) = ℙ(B|A). People get this confused all the time. For example, the probability of spots given you have measles is 1 but the probability that you have measles given that you have spots is not 1. In this case, the difference between ℙ(A|B) and ℙ(B|A) is obvious but there are cases where it is less obvious. This mistake is made often enough in legal cases that it is sometimes called the prosecutor’s fallacy.

1.13 Example. A medical test for a disease D has outcomes + and −. The probabilities are:

From the definition of conditional probability,

and

Apparently, the test is fairly accurate. Sick people yield a positive 90 percent of the time and healthy people yield a negative about 90 percent of the time. Suppose you go for a test and get a positive. What is the probability you have the disease? Most people answer .90. The correct answer is

The lesson here is that you need to compute the answer numerically. Don’t trust your intuition. ■

The results in the next lemma follow directly from the definition of conditional probability.

1.14 Lemma. If A and B are independent events then ℙ(A|B) = ℙ(A). Also, for any pair of events A and B,

From the last lemma, we see that another interpretation of independence is that knowing B doesn’t change the probability of A. The formula ℙ(AB) = ℙ(A)ℙ(B|A) is sometimes helpful for calculating probabilities.

1.15 Example. Draw two cards from a deck, without replacement. Let A be the event that the first draw is the Ace of Clubs and let B be the event that the second draw is the Queen of Diamonds. Then ℙ(AB) = ℙ(A)ℙ(B|A) = (1/52) × (1/51). ■

Summary of Conditional Probability

1.

If ℙ(B) > 0, then

2.

ℙ(·|B) satisfies the axioms of probability, for fixed B. In general, ℙ (A|·) does not satisfy the axioms of probability, for fixed A.

3.

In general, ℙ(A|B) ≠ ℙ(B|A).

4.

A and B are independent if and only if ℙ(A|B) = ℙ(A).

1.7 Bayes’ Theorem

Bayes’ theorem is the basis of “expert systems” and “Bayes’ nets,” which are discussed in Chapter 17. First, we need a preliminary result.

1.16 Theorem (The Law of Total Probability). Let Al, ..., Ak be a partition of Ω. Then, for any event B,

Proof. Define Cj = BAj and note that C₁, ..., Ck are disjoint and that . Hence,

since ℙ(BAj) = ℙ(B|Aj)ℙ(Aj) from the definition of conditional probability.

1.17 Theorem (Bayes’ Theorem). Let A₁, ..., Ak be a partition of Ω such that ℙ(Ai) > 0 for each i. If ℙ(B) > 0 then, for each i = 1, ..., k,

(1.5)

1.18 Remark. We call ℙ(Ai) the prior probability of A and ℙ(Ai|B) the posterior probability of A.

Proof. We apply the definition of conditional probability twice, followed by the law of total probability:

1.19 Example. I divide my email into three categories: A₁ = “spam,” A₂ = “low priority” and A₃ = “high priority.” From previous experience I find that ℙ(A₁) = .7, ℙ(A₂) = .2 and ℙ(A₃) = . 1. Of course, .7 + .2 + .1 = 1. Let B be the event that the email contains the word “free.” From previous experience, ℙ(B|A₁) = .9, ℙ(B|A₂) = .01, ℙ(B|A₁) = .01. (Note: .9 + .01 + .01 ≠ 1 .) I receive an email with the word “free.” What is the probability that it is spam? Bayes’ theorem yields,

1.8 Bibliographic Remarks

The material in this chapter is standard. Details can be found in any number of books. At the introductory level, there is DeGroot and Schervish (2002); at the intermediate level, Grimmett and Stirzaker (1982) and Karr (1993); at the advanced level there are Billingsley (1979) and Breiman (1992). I adapted many examples and exercises from DeGroot and Schervish (2002) and Grimmett and Stirzaker (1982).

1.9 Appendix

Generally, it is not feasible to assign probabilities to all subsets of a sample space Ω. Instead, one restricts attention to a set of events called a σ-algebra or a σ-field which is a class that satisfies:

(i)

∈ ,

(ii)

if A₁, A₂, ..., ∈ then and

(iii)

A ∈ implies that Ac ∈ .

The sets in are said to be measurable. We call (Ω, ) a measurable space. If ℙ is a probability measure defined on , then (Ω, , ℙ) is called a probability space. When Ω is the real line, we take to be the smallest σ-field that contains all the open subsets, which is called the Borel σ-field.

1.10 Exercises

1.

Fill in the details of the proof of Theorem 1.8. Also, prove the monotone decreasing case.

2.

Prove the statements in equation (1.1).

3.

Let Ω be a sample space and let A₁, A₂, ..., be events. Define Bn = and .

(a)

Show that B₁ ⊃ B₂ ⊃ ⋯ and that C₁ ⊂ C₂ ⊂ ⋯.

(b)

Show that if and only if ω belongs to an infinite number of the events A₁, A₂, ....

(c)

Show that if and only if ω belongs to all the events A₁, A₂ ... except possibly a finite number of those events.

4.

Let {Ai: i ∈ I} be a collection of events where I is an arbitrary index set. Show that

Hint: First prove this for I = {1, ..., n}.

5.

Suppose we toss a fair coin until we get exactly two heads. Describe the sample space S. What is the probability that exactly k tosses are required?

6.

Let Ω = {0, 1, ...,}. Prove that there does not exist a uniform distribution on Ω (i .e., if ℙ(A) = ℙ(B) whenever |A| = |B|, then ℙ cannot satisfy the axioms of probability).

7.

Let A₁, A₂, ... be events. Show that

Hint: Define . Then show that the Bn are disjoint and that .

8.

Suppose that ℙ(Ai) = 1 for each i. Prove that

9.

For fixed B such that ℙ(B) > 0, show that ℙ(· |B) satisfies the axioms of probability.

10.

You have probably heard it before. Now you can solve it rigorously. It is called the “Monty Hall Problem.” A prize is placed at random behind one of three doors. You pick a door. To be concrete, let’s suppose you always pick door 1. Now Monty Hall chooses one of the other two doors, opens it and shows you that it is empty. He then gives you the opportunity to keep your door or switch to the other unopened door. Should you stay or switch? Intuition suggests it doesn’t matter. The correct answer is that you should switch. Prove it. It will help to specify the sample space and the relevant events carefully. Thus write Ω = {(ω₁, ω₂): ωi ∈ {1, 2, 3}} where ω₁ is where the prize is and ω₂ is the door Monty opens.

11.

Suppose that A and B are independent events. Show that Ac and Bc are independent events.

12.

There are three cards. The first is green on both sides, the second is red on both sides and the third is green on one side and red on the other. We choose a card at random and we see one side (also chosen at random). If the side we see is green, what is the probability that the other side is also green? Many people intuitively answer 1/2. Show that the correct answer is 2/3.

13.

Suppose that a fair coin is tossed repeatedly until both a head and tail have appeared at least once.

(a)

Describe the sample space Ω.

(b)

What is the probability that three tosses will be required?

14.

Show that if ℙ(A) = 0 or ℙ(A) = 1 then A is independent of every other event. Show that if A is independent of itself then ℙ(A) is either 0 or 1.

15.

The probability that a child has blue eyes is 1/4. Assume independence between children. Consider a family with 3 children.

(a)

If it is known that at least one child has blue eyes, what is the probability that at least two children have blue eyes?

(b)

If it is known that the youngest child has blue eyes, what is the probability that at least two children have blue eyes?

16.

Prove Lemma 1.14.

17.

Show that

18.

Suppose k events form a partition of the sample space Ω, i.e., they are disjoint and . Assume that ℙ(B) > 0. Prove that if ℙ(A₁ |B) < ℙ(A₁) then ℙ(Ai|B) > ℙ(Ai) for some i = 2, ..., k.

19.

Suppose that 30 percent of computer owners use a Macintosh, 50 percent use Windows, and 20 percent use Linux. Suppose that 65 percent of the Mac users have succumbed to a computer virus, 82 percent of the Windows users get the virus, and 50 percent of the Linux users get the virus. We select a person at random and learn that her system was infected with the virus. What is the probability that she is a Windows user?

20.

A box contains 5 coins and each has a different probability of showing heads. Let p₁, ..., p₅ denote the probability of heads on each coin. Suppose that

Let H denote “heads is obtained” and let Ci denote the event that coin i is selected.

(a)

Select a coin at random and toss it. Suppose a head is obtained. What is the posterior probability that coin i was selected (i = 1, ..., 5)? In other words, find ℙ(Ci |H) for i = 1, ..., 5.

(b)

Toss the coin again. What is the probability of another head? In other words find ℙ(H₂ |H₁) where Hj = “heads on toss j.”

Now suppose that the experiment was carried out as follows: We select a coin at random and toss it until a head is obtained.

(c)

Find ℙ(Ci |B₄) where B₄ = “first head is obtained on toss 4.”

21.

(Computer Experiment.) Suppose a coin has probability p of falling heads up. If we flip the coin many times, we would expect the proportion of heads to be near p. We will make this formal later. Take p = .3 and n = 1, 000 and simulate n coin flips. Plot the proportion of heads as a function of n. Repeat for p = .03.

22.

(Computer Experiment.) Suppose we flip a coin n times and let p denote the probability of heads. Let X be the number of heads. We call X a binomial random variable, which is discussed in the next chapter. Intuition suggests that X will be close to np. To see if this is true, we can repeat this experiment many times and average the X values. Carry out a simulation and compare the average of the X’s to n p. Try this for p = .3 and n = 10, n = 100, and n = 1, 000.

23.

(Computer Experiment.) Here we will get some experience simulating conditional probabilities. Consider tossing a fair die. Let A = {2, 4, 6} and B = {1, 2, 3, 4}. Then, ℙ(A) = 1/2, ℙ(B) = 2/3 and ℙ(AB) = 1/3. Since ℙ(AB) = ℙ(A)ℙ(B), the events A and B are independent. Simulate draws from the sample space and verify that where is the proportion of times A occurred in the simulation and similarly for and . Now find two events A and B that are not independent. Compute and . Compare the calculated values to their theoretical values. Report your results and interpret.

¹

It is not always possible to assign a probability to every event A if the sample space is large, such as the whole real line. Instead, we assign probabilities to a limited class of set called a σ-field. See the appendix for details.

2
Random Variables

Larry Wasserman1

(1)

Department of Statistics, Carnegie Mellon University, Baker Hall 228A, 15213-3890, Pittsburgh, PA, USA

Larry Wasserman

Email: larry@stat.cmu.edu

2.1 Introduction

Statistics and data mining are concerned with data. How do we link sample spaces and events to data? The link is provided by the concept of a random variable.

2.1 Definition. A random variable is a mapping¹

that assigns a real number X(ω) to each outcome ω.

At a certain point in most probability courses, the sample space is rarely mentioned anymore and we work directly with random variables. But you should keep in mind that the sample space is really there, lurking in the background.

2.2 Example. Flip a coin ten times. Let X(ω) be the number of heads in the sequence ω. For example, if ω = HHTHHTHHTT, then X(ω) = 6. ■

2.3 Example. Let Ω = {(x, y); x² + y² ≤ 1} be the unit disk. Consider drawing a point at random from Ω. (We will make this idea more precise later.) A typical outcome is of the form ω = (x, y). Some examples of random variables are X(ω) = x, Y(ω) = y, Z(ω) = x + y, and ■

Given a random variable X and a subset A of the real line, define X⁻¹ (A) = {ω ∈ Ω : X(ω) ∈ A} and let

Notice that X denotes the random variable and x denotes a particular value of X.

2.4 Example. Flip a coin twice and let X be the number of heads. Then, ℙ(X = 0) = ℙ({TT}) = 1/4, ℙ(X = 1) = ℙ({HT, TH}) = 1/2 and ℙ(X = 2) = ℙ({HH}) = 1/4. The random variable and its distribution can be summarized as follows:

Try generalizing this to n flips. ■

2.2 Distribution Functions and Probability Functions

Given a random variable X, we define the cumulative distribution function (or distribution function) as follows.

2.5 Definition. The cumulative distribution function, or cdf, is the function FX : ℝ → [0, 1] defined by

(2.1)

We will see later that the cdf effectively contains all the information about the random variable. Sometimes we write the cdf as F instead of FX.

2.6 Example. Flip a fair coin twice and let X be the number of heads. Then ℙ(X = 0) = ℙ(X = 2) = 1/4 and ℙ(X = 1) = 1/2. The distribution function is

The cdf is shown in Figure 2.1. Although this example is simple, study it carefully. cdf’s can be very confusing. Notice that the function is right continuous, non-decreasing, and that it is defined for all x, even though the random variable only takes values 0, 1, and 2. Do you see why FX(1.4) = .75? ■

FIGURE 2.1.

cdf for flipping a coin twice (Example 2.6.)

The following result shows that the cdf completely determines the distribution of a random variable.

2.7 Theorem. Let X have cdf F and let Y have cdf G. If F(x) = G(x) for all x, then ℙ(X ∈ A) = ℙ(Y ∈ A) for all A.²

2.8 Theorem. A function F mapping the real line to [0, 1] is a cdf for some probability ℙ if and only if F satisfies the following three conditions:

(i)

F is non-decreasing: x₁ < x₂ implies that F(x₁) ≤ F(x₂).

(ii)

F is normalized:

and

(iii)

F is right-continuous: F(x) = F(x⁺) for all x, where

Proof. Suppose that F is a cdf. Let us show that (iii) holds. Let x be a real number and let y₁, y₂,... be a sequence of real numbers such that y₁ > y₂ > ⋯ and limi yi = x. Let Ai = (−∞, yi] and let A = (−∞, x]. Note that and also note that A₁ ⊃ A₂ ⊃ ⋯. Because the events are monotone, limi ℙ(Ai) = ℙ(∩i Ai). Thus,

Showing (i) and (ii) is similar. Proving the other direction — namely, that if F satisfies (i), (ii), and (iii) then it is a cdf for some random variable — uses some deep tools in analysis. ■

2.9 Definition. X is discrete if it takes countably³ many values {x₁, x₂,...}. We define the probability function or probability mass function for X by fX(x) = ℙ(X = x).

Thus, fX(x) ≥ 0 for all x ∈ ℝ and ∑i fX(xi) = 1. Sometimes we write f instead of fX. The cdf of X is related to fX by

2.10 Example. The probability function for Example 2.6 is

See Figure 2.2. ■

FIGURE 2.2.

Probability function for flipping a coin twice (Example 2.6).

2.11 Definition. A random variable X is continuous if there exists a function fX such that fX(x) ≥ 0 for all x, and for every a ≤ b,

(2.2)

The function fX is called the probability density function (pdf). We have that

and at all points x at which FX is differentiable.

Sometimes we write ∫ f(x)dx or ∫ f to mean .

2.12 Example. Suppose that X has pdf

Clearly, fX(x) ≥ 0 and ∫ fX(x)dx = 1. A random variable with this density is said to have a Uniform (0, 1) distribution. This is meant to capture the idea of choosing a point at random between 0 and 1. The cdf is given by

See Figure 2.3. ■

FIGURE 2.3.

cdf for Uniform (0, 1).

2.13 Example. Suppose that X has pdf

Since ∫ f(x)dx = 1, this is a well-defined pdf. ■

Warning! Continuous random variables can lead to confusion. First, note that if X is continuous then ℙ(X = x) = 0 for every x. Don’t try to think of f(x) as ℙ(X = x). This only holds for discrete random variables. We get probabilities from a pdf by integrating. A pdf can be bigger than 1 (unlike a mass function). For example, if f(x) = 5 for x ∈ [0, 1/5] and 0 otherwise, then f(x) ≥ 0 and ∫ f(x)dx = 1 so this is a well-defined pdf even though f(x) = 5 in some places. In fact, a pdf can be unbounded. For example, if f(x) = (2/3)x−1/3 for 0 < x < 1 and f(x) = 0 otherwise, then ∫ f(x)dx = 1 even though f is not bounded.

2.14 Example. Let

This is not a pdf since . ■

2.15 Lemma. Let F be the cdf for a random variable X. Then:

1.

ℙ(X = x) = F(x) − F(x⁻) where F(x⁻) = limy↑x F(y);

2.

ℙ(x < X ≤ y) = F(y) − F(x);

3.

ℙ(X > x) = 1 − F(x);

4.

If X is continuous then

It is also useful to define the inverse cdf (or quantile function).

2.16 Definition. Let X be a random variable with cdf F. The inverse CDF or quantile function is defined by⁴

for q ∈ [0, 1]. If F is strictly increasing and continuous then F⁻¹(q) is the unique real number x such that F(x) = q.

We call F⁻¹ (1/4) the first quartile, F⁻¹ (1/2) the median (or second quartile), and F⁻¹(3/4) the third quartile.

Two random variables X and Y are equal in distribution — written for all x. This does not mean that X and Y are equal. Rather, it means that all probability statements about X and Y will be the same. For example, suppose that ℙ(X = 1) = ℙ(X = −1) = 1/2. Let Y = −X. Then ℙ(Y = 1) = ℙ(Y = −1) = 1/2 and so . But X and Y are not equal. In fact, ℙ(X = Y) = 0.

2.3 Some Important Discrete Random Variables

Warning About Notation! It is traditional to write X ∼ F to indicate that X has distribution F. This is unfortunate notation since the symbol ∼ is also used to denote an approximation. The notation X ∼ F is so pervasive that we are stuck with it. Read X ∼ F as “X has distribution F” not as “X is approximately F”.

The Point Mass Distribution. X has a point mass distribution at a, written X ∼ δa, if ℙ(X = a) = 1 in which case

The probability mass function is f(x) = 1 for x = a and 0 otherwise.

The Discrete Uniform Distribution. Let k > 1 be a given integer. Suppose that X has probability mass function given by

We say that X has a uniform distribution on {1,..., k}.

The Bernoulli Distribution. Let X represent a binary coin flip. Then ℙ(X = 1) = p and ℙ(X = 0) = 1 − p for some p ∈ [0, 1]. We say that X has a Bernoulli distribution written X ∼ Bernoulli(p). The probability function is f(x) = px(1 − p)1 − x for x ∈ {0, 1}.

The Binomial Distribution. Suppose we have a coin which falls heads up with probability p for some 0 ≤ p ≤ 1. Flip the coin n times and let X be the number of heads. Assume that the tosses are independent. Let f(x) = ℙ(X = x) be the mass function. It can be shown that

A random variable with this mass function is called a Binomial random variable and we write X ∼ Binomial(n, p). If X₁ ∼ Binomial(n₁, p) and X₂ ∼ Binomial(n₂, p) then X₁ + X₂ ∼ Binomial(n₁ + n₂, p).

Warning! Let us take this opportunity to prevent some confusion. X is a random variable; x denotes a particular value of the random variable; n and p are parameters, that is, fixed real numbers. The parameter p is usually unknown and must be estimated from data; that’s what statistical inference is all about. In most statistical models, there are random variables and parameters: don’t confuse them.

The Geometric Distribution. X has a geometric distribution with parameter p ∈ (0, 1), written X ∼ Geom(p), if

We have that

Think of X as the number of flips needed until the first head when flipping a coin.

The Poisson Distribution. X has a Poisson distribution with parameter λ, written X ∼ Poisson(λ) if

Note that

The Poisson is often used as a model for counts of rare events like radioactive decay and traffic accidents. If X₁ ∼ Poisson(λ₁) and X₂ ∼ Poisson(λ₂) then X₁ + X₂ ∼ Poisson(λ₁ + λ₂).

Warning! We defined random variables to be mappings from a sample space Ω to ℝ but we did not mention the sample space in any of the distributions above. As I mentioned earlier, the sample space often “disappears” but it is really there in the background. Let’s construct a sample space explicitly for a Bernoulli random variable. Let Ω = [0, 1] and define ℙ to satisfy ℙ([a, b]) = b − a for 0 ≤ a ≤ b ≤ 1. Fix p ∈ [0, 1] and define

Then ℙ(X = 1) = ℙ(ω ≤ p) = ℙ([0, p]) = p and ℙ(X = 0) = 1 − p. Thus, X ∼ Bernoulli(p). We could do this for all the distributions defined above. In practice, we think of a random variable like a random number but formally it is a mapping defined on some sample space.

2.4 Some Important Continuous Random Variables

The Uniform Distribution. X has a Uniform(a, b) distribution, written X Uniform(a, b), if

where a < b. The distribution function is

Normal (Gaussian). X has a Normal (or Gaussian) distribution with parameters μ and σ, denoted by X ∼N(μ, σ²), if

(2.3)

where μ ∈ ℝ and σ > 0. The parameter μ is the “center” (or mean) of the distribution and σ is the “spread” (or standard deviation) of the distribution. (The mean and standard deviation will be formally defined in the next chapter.) The Normal plays an important role in probability and statistics. Many phenomena in nature have approximately Normal distributions. Later, we shall study the Central Limit Theorem which says that the distribution of a sum of random variables can be approximated by a Normal distribution.

We say that X has a standard Normal distribution if μ = 0 and σ = 1. Tradition dictates that a standard Normal random variable is denoted by Z. The pdf and cdf of a standard Normal are denoted by ϕ(z) and Φ(z). The pdf is plotted in Figure 2.4. There is no closed-form expression for Φ. Here are some useful facts:

(i)

If X ∼N(μ, σ²), then Z = (X− μ)/σ ∼N(0, 1).

(ii)

If Z ∼ N(0, 1), then X = μ + σZ ∼N(μ, σ²).

(iii)

If , i = 1,..., n are independent, then

It follows from (i) that if X ∼N(μ, σ²), then

FIGURE 2.4.

Density of a standard Normal.

Thus we can compute any probabilities we want as long as we can compute the cdf Φ(z) of a standard Normal. All statistical computing packages will compute Φ(z) and Φ⁻¹(q). Most statistics texts, including this one, have a table of values of Φ(z).

2.17 Example. Suppose that X ∼N(3, 5). Find ℙ(X > 1). The solution is

Now find q = Φ⁻¹ (0. 2). This means we have to find q such that ℙ(X < q) = 0.2. We solve this by writing

From the Normal table, Φ(−0. 8416) = 0.2. Therefore,

and hence . ■

Exponential Distribution. X has an Exponential distribution with parameter β, denoted by X ∼ Exp(β), if

where β > 0. The exponential distribution is used to model the lifetimes of electronic components and the waiting times between rare events.

Gamma Distribution. For α > 0, the Gamma function is defined by . X has a Gamma distribution with parameters α and β, denoted by X ∼ Gamma(α, β), if

where α, β > 0. The exponential distribution is just a Gamma(1, β) distribution. If Xi ∼ Gamma(αi, β) are independent, then .

The Beta Distribution. X has a Beta distribution with parameters α > 0 and β > 0, denoted by X ∼ Beta(α, β), if

t and Cauchy Distribution. X has a t distribution with ν degrees of freedom — written X ∼ tν — if

The t distribution is similar to a Normal but it has thicker tails. In fact, the Normal corresponds to a t with ν = ∞. The Cauchy distribution is a special case of the t distribution corresponding to ν = 1. The density is

To see that this is indeed a density:

The χ² Distribution. X has a χ² distribution with p degrees of freedom — written X ∼ — if

If Z₁,..., Zp are independent standard Normal random variables then .

2.5 Bivariate Distributions

Given a pair of discrete random variables X and Y, define the joint mass function by f(x, y) = ℙ(X = x and Y = y). From now on, we write ℙ(X = x and Y = y) as ℙ(X = x, Y = y). We write f as fX,Y when we want to be more explicit.

2.18 Example. Here is a bivariate distribution for two random variables X and Y each taking values 0 or 1:

Thus, f(1, 1) = ℙ(X = 1, Y = 1) = 4/9. ■

2.19 Definition. In the continuous case, we call a function f(x, y) a pdf for the random variables (X, Y) if

(i)

f(x, y) ≥ 0 for all (x, y),

(ii)

and,

(iii)

for any set A ⊂ ℝ × ℝ, ℙ((X, Y) ∈ A) = ∫ ∫A f(x, y)dxdy.

In the discrete or continuous case we define the joint cdf as FX,Y (x, y) = ℙ(X ≤ x, Y ≤ y).

2.20 Example. Let (X, Y) be uniform on the unit square. Then,

Find ℙ(X < 1/2, Y < 1/2). The event A = {X < 1/2, Y < 1/2} corresponds to a subset of the unit square. Integrating f over this subset corresponds, in this case, to computing the area of the set A which is 1/4. So, ℙ(X < 1/2, Y < 1/2) = 1/4. ■

2.21 Example. Let (X, Y) have density

Then

which verifies that this is a pdf ■

2.22 Example. If the distribution is defined over a non-rectangular region, then the calculations are a bit more complicated. Here is an example which I borrowed from DeGroot and Schervish (2002). Let (X, Y) have density

Note first that −1 ≤ x ≤ 1. Now let us find the value of c. The trick here is to be careful about the range of integration. We pick one variable, x say, and let it range over its values. Then, for each fixed value of x, we let y vary over its range, which is x² ≤ y ≤ 1. It may help if you look at Figure 2.5. Thus,

Hence, c = 21/4. Now let us compute ℙ(X ≥ Y). This corresponds to the set A = {(x, y); 0 ≤ x ≤ 1, x² ≤ y ≤ x}. (You can see this by drawing a diagram.) So,

FIGURE 2.5.

The light shaded region is x² ≤ y ≤ 1. The density is positive over this region. The hatched region is the event X ≥ Y intersected with x² ≤ y ≤ 1.

2.6 Marginal Distributions

2.23 Definition. If (X, Y) have joint distribution with mass function fX,Y, then the marginal mass function for X is defined by

(2.4)

and the marginal mass function for Y is defined by

(2.5)

2.24 Example. Suppose that fX,Y is given in the table that follows. The marginal distribution for X corresponds to the row totals and the marginal distribution for Y corresponds to the columns totals.

For example, fX(0) = 3/10 and fX(1) = 7/10. ■

2.25 Definition. For continuous random variables, the marginal densities are

(2.6)

The corresponding marginal distribution functions are denoted by FX and FY.

2.26 Example. Suppose that

for x, y ≥ 0. Then . ■

2.27 Example. Suppose that

Then

2.28 Example. Let (X, Y) have density

Thus,

for −1 ≤ x ≤ 1 and fX(x) = 0 otherwise. ■

2.7 Independent Random Variables

2.29 Definition. Two random variables X and Y are independent if, for every A and B,

(2.7)

and we write X ∐ Y. Otherwise we say that X and Y are dependent and we write .

In principle, to check whether X and Y are independent we need to check equation (2.7) for all subsets A and B. Fortunately, we have the following result which we state for continuous random variables though it is true for discrete random variables too.

2.30 Theorem. Let X and Y have joint pdf fX,Y. Then X ∐ Y if and only if fX,Y (x, y) = fX (x) fY(y) for all values x and y.⁵

2.31 Example. Let X and Y have the following distribution:

Then, fX(0) = fX(1) = 1/2 and fY(0) = fY(1) = 1/2. X and Y are independent because fX(0) fY(0) = f(0, 0), fX(0) fY(1) = f(0, 1), fX(1) fY(0) = f(1, 0), fX(1) fY(1) = f(1, 1). Suppose instead that X and Y have the following distribution:

These are not independent because fX(0) fY(1) = (1/2)(1/2) = 1/4 yet f(0, 1) = 0. ■

2.32 Example. Suppose that X and Y are independent and both have the same density

Let us find ℙ(X + Y ≤ 1). Using independence, the joint density is

Now,

The following result is helpful for verifying independence.

2.33 Theorem. Suppose that the range of X and Y is a (possibly infinite) rectangle. If f(x, y) = g(x)h(y) for some functions g and h (not necessarily probability density functions) then X and Y are independent.

2.34 Example. Let X and Y have density

The range of X and Y is the rectangle (0, ∞) × (0, ∞). We can write f(x, y) = g(x)h(y) where g(x) = 2e−x and h(y) = e−2y. Thus, X ∐ Y. ■

2.8 Conditional Distributions

If X and Y are discrete, then we can compute the conditional distribution of X given that we have observed Y = y. Specifically, ℙ(X = x|Y = y) = ℙ(X = x, Y = y)/ℙ(Y = y). This leads us to define the conditional probability mass function as follows.

2.35 Definition. The conditional probability mass function is

if fY (y) > 0.

For continuous distributions we use the same definitions.⁶ The interpretation differs: in the discrete case, fX|Y(x|y) is ℙ(X = x|Y = y), but in the continuous case, we must integrate to get a probability.

2.36 Definition. For continuous random variables, the conditional probability density function is

assuming that fY(y) > 0. Then,

2.37 Example. Let X and Y have a joint uniform distribution on the unit square. Thus, fX|Y(x|y) = 1 for 0 ≤ x ≤ 1 and 0 otherwise. Given Y = y, X is Uniform(0, 1). We can write this as X|Y = y ∼ Uniform(0, 1). ■

From the definition of the conditional density, we see that fX,Y(x, y) = fX|Y(x|y)fY(y) = fY|X(y|x)fX(x). This can sometimes be useful as in example 2.39.

2.38 Example. Let

Let us find ℙ(X < 1/4|Y = 1/3). In example 2.27 we saw that fY(y) = y + (1/2). Hence,

So,

2.39 Example. Suppose that X ∼ Uniform(0, 1). After obtaining a value of X we generate Y|X = x ∼ Uniform(x, 1). What is the marginal distribution of Y? First note that,

and

So,

The marginal for Y is

for 0 < y < 1. ■

2.40 Example. Consider the density in Example 2.28. Let’s find fX|Y(y|x). When X = x, y must satisfy x² ≤ y ≤ 1. Earlier, we saw that fX(x) = (21/8)x²(1 − x⁴). Hence, for x² ≤ y ≤ 1,

Now let us compute ℙ(Y ≥ 3/4|X = 1/2). This can be done by first noting that fY|X(y|1/2) = 32y/15. Thus,

2.9 Multivariate Distributions and iid Samples

Let X = (X₁,..., Xn) where X₁,..., Xn are random variables. We call X a random vector. Let f(x₁,..., xn) denote the pdf. It is possible to define their marginals, conditionals etc. much the same way as in the bivariate case. We say that X₁,..., Xn are independent if, for every A₁,..., An,

(2.8)

It suffices to check that .

2.41 Definition. If X₁,..., Xn are independent and each has the same marginal distribution with cdf F, we say that X₁,..., Xn are iid (independent and identically distributed) and we write

If F has density f we also write X₁,...Xn ∼ f. We also call X₁,..., Xn a random sample of size n from F.

Much of statistical theory and practice begins with iid observations and we shall study this case in detail when we discuss statistics.

2.10 Two Important Multivariate Distributions

Multinomial. The multivariate version of a Binomial is called a Multinomial. Consider drawing a ball from an urn which has balls with k different colors labeled “color 1, color 2,..., color k.” Let p = (p₁,..., pk) where pj ≥ 0 and = 1 and suppose that pj is the probability of drawing a ball of color j. Draw n times (independent draws with replacement) and let X = (X₁,..., Xk) where Xj is the number of times that color j appears. Hence, . We say that X has a Multinomial (n,p) distribution written X ∼ Multinomial(n, p). The probability function is

(2.9)

where

2.42 Lemma. Suppose that X ∼ Multinomial(n, p) where X = (X₁,..., Xk) and p = (p₁,..., pk). The marginal distribution of Xj is Binomial (n, pj).

Multivariate Normal. The univariate Normal has two parameters, μ and σ. In the multivariate version, μ is a vector and σ is replaced by a matrix Σ. To begin, let

where Z₁,..., Zk ∼ N(0, 1) are independent. The density of Z is ⁷

We say that Z has a standard multivariate Normal distribution written Z ∼N(0, I) where it is understood that 0 represents a vector of k zeroes and I is the k × k identity matrix.

More generally, a vector X has a multivariate Normal distribution, denoted by X ∼ N(μ, Σ), if it has density ⁸

(2.10)

where |Σ| denotes the determinant of Σ, μ is a vector of length k and Σ is a k × k symmetric, positive definite matrix. ⁹ Setting μ = 0 and Σ = I gives back the standard Normal.

Since Σ is symmetric and positive definite, it can be shown that there exists a matrix Σ1/2 — called the square root of Σ — with the following properties: (i) Σ1/2 is symmetric, (ii) Σ = Σ1/2Σ1/2 and (iii) Σ1/2Σ−1/2 = Σ−1/2Σ1/2 = I where Σ−1/2 = (Σ1/2)⁻¹.

2.43 Theorem. If Z ∼ N(0, I) and X = μ + Σ1/2Z then X ∼ N(μ, Σ). Conversely, if X ∼N(μ, Σ), then Σ−1/2 (X− μ) ∼N(0, I).

Suppose we partition a random Normal vector X as X = (Xa, Xb) We can similarly partition μ = (μa, μb) and

2.44 Theorem. Let X ∼ N(µ, Σ). Then:

(1)

The marginal distribution of Xa is Xa ∼N(μa, Σaa).

(2)

The conditional distribution of Xb given Xa = xa is

(3)

If a is a vector then aTX ∼ N(aTμ, aTΣa).

(4)

.

2.11 Transformations of Random Variables

Suppose that X is a random variable with pdf fX and cdf FX. Let Y = r(X) be a function of X, for example, Y = X² or Y = eX. We call Y = r(X) a transformation of X. How do we compute the pdf and cdf of Y? In the discrete case, the answer is easy. The mass function of Y is given by

2.45 Example. Suppose that ℙ(X = −1) = ℙ(X = 1) = 1/4 and ℙ(X = 0) = 1/2. Let Y = X². Then, ℙ(Y = 0) = ℙ(X = 0) = 1/2 and ℙ(Y = 1) = ℙ(X = 1) + ℙ (X = −1) = 1/2. Summarizing:

Y takes fewer values than X because the transformation is not one-to-one. ■

The continuous case is harder. There are three steps for finding fY:

Three Steps for Transformations

1.

For each y, find the set Ay = {x : r(x) ≤ y}.

2.

Find the cdf

(2.11)

3.

The pdf is .

2.46 Example. Let fX(x) = e−x for x > 0. Hence, = 1 − e−x. Let Y = r(X) = log X. Then, Ay = {x : x ≤ ey} and

Therefore, fY(y) = eye−ey for y ∈ ℝ. ■

2.47 Example. Let X ∼ Uniform(−1, 3). Find the pdf of Y = X². The density of X is

Y can only take values in (0, 9). Consider two cases: (i) 0 < y < 1 and (ii) 1 ≤ y < 9. For case (i), and . For case (ii), and . Differentiating F we get

When r is strictly monotone increasing or strictly monotone decreasing then r has an inverse s = r⁻¹ and in this case one can show that

(2.12)

2.12 Transformations of Several Random Variables

In some cases we are interested in transformations of several random variables. For example, if X and Y are given random variables, we might want to know the distribution of X/Y, X + Y, max{X, Y} or min{X, Y}. Let Z = r(X, Y) be the function of interest. The steps for finding fZ are the same as before:

Three Steps for Transformations

1.

For each z, find the set Az = {(x, y) : r(x, y) ≤ z}.

2.

Find the cdf

3.

Then .

2.48 Example. Let X₁, X₂ ∼ Uniform(0, 1) be independent. Find the density of Y = X₁ + X₂. The joint density of (X₁, X₂) is

Let r(x₁, x₂) = x₁ + x₂. Now,

Now comes the hard part: finding Ay. First suppose that 0 < y ≤ 1. Then Ay is the triangle with vertices (0, 0), (y, 0) and (0, y). See Figure 2.6. In this case, ∫ ∫Ay f(x₁, x₂)dx₁dx₂ is the area of this triangle which is y²/2. If 1 < y < 2, then Ay is everything in the unit square except the triangle with vertices (1, y − 1), (1, 1), (y − 1, 1). This set has area 1 − (2 − y)²/2. Therefore,

By differentiation, the pdf is

FIGURE 2.6.

The set Ay for example 2.48. Ay consists of all points (x₁, x₂) in the square below the line x₂ = y − x₁.

2.13 Appendix

Recall that a probability measure ℙ is defined on a σ-field of a sample space Ω. A random variable X is a measurable map X : Ω → ℝ. Measurable means that, for every x, {ω : X(ω) ≤ x} ∈.

2.14 Exercises

1.

Show that

2.

Let X be such that ℙ(X = 2) = ℙ(X = 3) = 1/10 and ℙ(X = 5) = 8/10. Plot the cdf F. Use F to find ℙ(2 < X ≤ 4. 8) and ℙ(2 ≤ X ≤ 4. 8).

3.

Prove Lemma 2.15.

4.

Let X have probability density function

(a)

Find the cumulative distribution function of X.

(b)

Let Y = 1/X. Find the probability density function fY(y) for Y.

Hint: Consider three cases: ⅕ ≤ y ≤ ⅓, ⅓ ≤ y ≤ 1, and y ≥ 1.

5.

Let X and Y be discrete random variables. Show that X and Y are independent if and only if fX,Y (x, y) = fX(x)fY(y) for all x and y.

6.

Let X have distribution F and density function f and let A be a subset of the real line. Let IA(x) be the indicator function for A:

Let Y = IA(X). Find an expression for the cumulative distribution of Y. (Hint: first find the probability mass function for Y.)

7.

Let X and Y be independent and suppose that each has a Uniform(0, 1) distribution. Let Z = min{X, Y}. Find the density fZ(z) for Z. Hint: It might be easier to first find ℙ(Z > z).

8.

Let X have cdf F. Find the cdf of X⁺ = max{0, X}.

9.

Let X ∼ Exp(β). Find F(x) and F⁻¹(q).

10.

Let X and Y be independent. Show that ɡ(X) is independent of h(Y) where ɡ and h are functions.

11.

Suppose we toss a coin once and let p be the probability of heads. Let X denote the number of heads and let Y denote the number of tails.

(a)

Prove that X and Y are dependent.

(b)

Let N ∼ Poisson(λ) and suppose we toss a coin N times. Let X and Y be the number of heads and tails. Show that X and Y are independent.

12.

Prove Theorem 2.33.

13.

Let X ∼ N(0, 1) and let Y = eX.

(a)

Find the pdf for Y. Plot it.

(b)

(Computer Experiment.) Generate a vector x = (x₁,..., x10,000) consisting of 10,000 random standard Normals. Let y = (y₁,..., y10,000) where yi = exi. Draw a histogram of y and compare it to the pdf you found in part (a).

14.

Let (X, Y) be uniformly distributed on the unit disk {(x, y): x² + y² ≤ 1}. Let . Find the cdf and pdf of R.

15.

(A universal random number generator.) Let X have a continuous, strictly increasing cdf F. Let Y = F(X). Find the density of Y. This is called the probability integral transform. Now let U ∼ Uniform(0, 1) and let X = F⁻¹ (U). Show that X ∼ F. Now write a program that takes Uniform (0, 1) random variables and generates random variables from an Exponential (β) distribution.

16.

Let X ∼ Poisson(λ) and Y ∼ Poisson(μ) and assume that X and Y are independent. Show that the distribution of X given that X + Y = n is Binomial(n, π) where π = λ/(λ + μ).
Hint 1: You may use the following fact: If X ∼ Poisson(λ) and Y ∼ Poisson(μ), and X and Y are independent, then X + Y ∼ Poisson(μ + λ).
Hint 2: Note that {X = x, X + Y = n} = {X = x, Y = n − x}.

17.

Let

Find P(X < ½ | Y = ½).

18.

Let X ∼N(3, 16). Solve the following using the Normal table and using a computer package.

(a)

Find ℙ(X < 7).

(b)

Find ℙ(X > −2).

(c)

Find x such that ℙ(X > x) = .05.

(d)

Find ℙ(0 ≤ X < 4).

(e)

Find x such that ℙ(|X| > |x|) = .05.

19.

Prove formula (2.12).

20.

Let X, Y ∼ Uniform(0, 1) be independent. Find the pdf for X − Y and X/Y.

21.

Let X₁,..., Xn ∼ Exp(β) be iid. Let Y = max{X₁,..., Xn}. Find the pdf of Y. Hint: Y ≤ y if and only if Xi ≤ y for i = 1,..., n.

¹

Technically, a random variable must be measurable. See the appendix for details.

²

Technically, we only have that ℙ(X ∈ A) = ℙ(Y ∈ A) for every measurable event A.

³

A set is countable if it is finite or it can be put in a one-to-one correspondence with the integers. The even numbers, the odd numbers, and the rationals are countable; the set of real numbers between 0 and 1 is not countable.

⁴

If you are unfamiliar with “inf”, just think of it as the minimum.

⁵

The statement is not rigorous because the density is defined only up to sets of measure 0.

⁶

We are treading in deep water here. When we compute ℙ(X ∈ A|Y = y) in the continuous case we are conditioning on the event {Y = y} which has probability 0. We avoid this problem by defining things in terms of the pdf. The fact that this leads to a well-defined theory is proved in more advanced courses. Here, we simply take it as a definition.

⁷

If a and b are vectors then .

⁸

Σ⁻¹ is the inverse of the matrix Σ.

⁹

A matrix Σ is positive definite if, for all nonzero vectors x, xT Σx > 0.

3
Expectation

Larry Wasserman1

(1)

Department of Statistics, Carnegie Mellon University, Baker Hall 228A, 15213-3890, Pittsburgh, PA, USA

Larry Wasserman

Email: larry@stat.cmu.edu

3.1 Expectation of a Random Variable

The mean, or expectation, of a random variable X is the average value of X.

3.1 Definition. The expected value, or mean, or first moment, of X is defined to be

(3.1)

assuming that the sum (or integral) is well defined. We use the following notation to denote the expected value of X:

(3.2)

The expectation is a one-number summary of the distribution. Think of (X) as the average of a large number of iid draws X₁,..., Xn. The fact that is actually more than a heuristic; it is a theorem called the law of large numbers that we will discuss in Chapter 5.

The notation ∫ xdF(x) deserves some comment. We use it merely as a convenient unifying notation so we don’t have to write ∑xxf(x) for discrete random variables and ∫ xf(x)dx for continuous random variables, but you should be aware that ∫ xdF(x) has a precise meaning that is discussed in real analysis courses.

To ensure that (X) is well defined, we say that (X) exists if ∫x |x|dFX(x) < ∞. Otherwise we say that the expectation does not exist.

3.2 Example. Let X ∼ Bernoulli(p). Then p)) + (1 + p) = p. ■

3.3 Example. Flip a fair coin two times. Let X be the number of heads. Then, (X) = ∫ xdFX(x) = ∑x xfX(x) = (0 × f(0)) + (1 × f(1)) + (2 × f(2)) = (0 × (1/4)) + (1 × (1/2)) + (2 × (1/4)) = 1. ■

3.4 Example. Let X ∼ Uniform(−1, 3). Then, (X) = ∫ xdFX(x) = ∫ xfX(x)dx = . ■

3.5 Example. Recall that a random variable has a Cauchy distribution if it has density fX(x) = {π(1 + x²)}⁻¹. Using integration by parts, (set u = x and υ = tan⁻¹ x),

so the mean does not exist. If you simulate a Cauchy distribution many times and take the average, you will see that the average never settles down. This is because the Cauchy has thick tails and hence extreme observations are common. ■

From now on, whenever we discuss expectations, we implicitly assume that they exist.

Let Y = r(X). How do we compute (Y)? One way is to find fY(y) and then compute (Y) = ∫ yfY(y)dy. But there is an easier way.

3.6 Theorem (The Rule of the Lazy Statistician). Let Y = r(X). Then

(3.3)

This result makes intuitive sense. Think of playing a game where we draw X at random and then I pay you Y = r(X). Your average income is r(x) times the chance that X = x, summed (or integrated) over all values of x. Here is a special case. Let A be an event and let r(x) = IA(x) where IA(x) = 1 if x ∈ A and IA(x) = 0 if x ∉ A. Then

In other words, probability is a special case of expectation.

3.7 Example. Let X ∼ Unif(0, 1). Let Y = r(X) = eX. Then,

Alternatively, you could find fY(y) which turns out to be fY(y) = 1/y for 1 < y < e. Then, . ■

3.8 Example. Take a stick of unit length and break it at random. Let Y be the length of the longer piece. What is the mean of Y? If X is the break point then X ∼ Unif(0, 1) and Y = r(X) = max{X, 1 − X}. Thus, r(x) = 1 − x when 0 < x < 1/2 and r(x) = x when 1/2 ≤ x < 1. Hence,

■

Functions of several variables are handled in a similar way. If Z = r(X, Y) then

(3.4)

3.9 Example. Let (X, Y) have a jointly uniform distribution on the unit square. Let Z = r(X, Y) = X² + Y². Then,

The kth moment of X is defined to be (Xk) assuming that (|X|k) < ∞.

3.10 Theorem. If the kth moment exists and if j < k then the jth moment exists.

Proof. We have

The kth central moment is defined to be ((X − μ)k).

3.2 Properties of Expectations

3.11 Theorem. If X₁,..., Xn are random variables and a₁,..., an are constants, then

(3.5)

3.12 Example. Let X ∼ Binomial(n, p). What is the mean of X? We could try to appeal to the definition:

but this is not an easy sum to evaluate. Instead, note that where Xi = 1 if the ith toss is heads and Xi = 0 otherwise. Then (Xi) = (p × 1) + ((1 − p) × 0) = p and (X) = (∑iXi) = ∑i(Xi) = np. ■

3.13 Theorem. Let X₁,..., Xn be independent random variables. Then,

(3.6)

Notice that the summation rule does not require independence but the multiplication rule does.

3.3 Variance and Covariance

The variance measures the “spread” of a distribution.¹

3.14 Definition. Let X be a random variable with mean μ. The variance of X — denoted by σ² or or (X) or X — is defined by

(3.7)

assuming this expectation exists. The standard deviation is and is also denoted by σ and σX.

3.15 Theorem. Assuming the variance is well defined, it has the following properties:

1.

(X) = (X²) − μ².

2.

If a and b are constants then (aX + b) = a²(X).

3.

If X₁,..., Xn are independent and a₁,..., an are constants, then

(3.8)

3.16 Example. Let X ∼ Binomial(n, p). We write X = ∑iXi where Xi = 1 if toss i is heads and Xi = 0 otherwise. Then X = ∑i Xi and the random variables are independent. Also, ℙ(Xi = 1) = p and ℙ(Xi = 0) = 1 − p. Recall that

Now,

Therefore, . Finally, (X) = (∑iXi) = ∑i(Xi) = ∑ip(1 − p) = np(1 − p). Notice that (X) = 0 if p = 1 or p = 0. Make sure you see why this makes intuitive sense. ■

If X₁,..., Xn are random variables then we define the sample mean to be

(3.9)

and the sample variance to be

(3.10)

3.17 Theorem. Let X₁,..., Xn be iid and let μ = (Xi), σ² = (Xi). Then

If X and Y are random variables, then the covariance and correlation between X and Y measure how strong the linear relationship is between X and Y.

3.18 Definition. Let X and Y be random variables with means μX and μY and standard deviations σX and σY. Define the covariance between X and Y by

(3.11)

and the correlation by

(3.12)

3.19 Theorem. The covariance satisfies:

The correlation satisfies:

If Y= aX + b for some constants a and b then ρ(X, Y) = 1 if a > 0 and ρ(X, Y) = −1 if a < 0. If X and Y are independent, then Cov(X, Y) = ρ = 0. The converse is not true in general.

3.20 Theorem. (X + Y) = (X) + (Y) + 2Cov(X, Y) and (X − Y) = (X) +(Y) − 2Cov(X,Y). More generally, for random variables X₁,..., Xn,

3.4 Expectation and Variance of Important Random Variables

Here we record the expectation of some important random variables:

Distribution

Mean

Variance

Point mass at a

a

0

Bernoulli(p)

p

p(1 − p)

Binomial(n, p)

np

np(1 − p)

Geometric(p)

1/p

(1 − p)/p²

Poisson(λ)

λ

λ

Uniform(a, b)

(a + b)/2

(b − a)²/12

Normal(μ, σ²)

μ

σ²

Exponential(β)

β

β²

Gamma(α, β)

αβ

αβ²

Beta(α, β)

α/(α + β)

αβ/((α + β)²(α + β + 1))

tv

0 (if v > 1)

v/(v − 2) (if v > 2)

p

2p

Multinomial(n, p)

np

see below

Multivariate Normal(μ, ∑)

μ

∑

We derived (X) and (X) for the Binomial in the previous section. The calculations for some of the others are in the exercises.

The last two entries in the table are multivariate models which involve a random vector X of the form

The mean of a random vector X is defined by

The variance-covariance matrix ∑ is defined to be

If X ∼ Multinomial(n, p) then (X) = np = n(p₁,..., pk) and

To see this, note that the marginal distribution of any one component of the vector Xi ∼ Binomial(n, pi). Thus, (Xi) = npi and (Xi) = npi (1 − pi). Note also that Xi + Xj ∼ Binomial(n, pi + pj). Thus, (Xi + Xj) = n(pi + pj) (1 − [pi + pj]). On the other hand, using the formula for the variance of a sum, we have that (Xi + Xj) = (Xi) + (Xj) + 2Cov(Xi, Xj) = npi (1 − pi) + npj (1 − pj) + 2Cov(Xi, Xj). If we equate this formula with n(pi + pj) (1 − [pi + pj]) and solve, we get Cov(Xi, Xj) = −npipj.

Finally, here is a lemma that can be useful for finding means and variances of linear combinations of multivariate random vectors.

3.21 Lemma. If a is a vector and X is a random vector with mean μ and variance ∑, then (aTX) = aTμ and (aTX) = aT∑a. If A is a matrix then (AX) = Aμ and (AX) = A∑AT.

3.5 Conditional Expectation

Suppose that X and Y are random variables. What is the mean of X among those times when Y = y? The answer is that we compute the mean of X as before but we substitute fX|Y(x|y) for fX(x) in the definition of expectation.

3.22 Definition. The conditional expectation of X given Y = y is

(3.13)

If r(x, y) is a function of x and y then

(3.14)

Warning! Here is a subtle point. Whereas (X) is a number, (X|Y = y) is a function of y. Before we observe Y, we don’t know the value of (X|Y = y) so it is a random variable which we denote (X|Y). In other words, (X|Y) is the random variable whose value is (X|Y = y) when Y = y. Similarly, (r(X, Y)|Y) is the random variable whose value is (r(X, Y)|Y = y) when Y = y. This is a very confusing point so let us look at an example.

3.23 Example. Suppose we draw X ∼ Unif(0, 1). After we observe X = x, we draw Y|X = x ∼ Unif(x, 1). Intuitively, we expect that (Y|X = x) = (1 + x)/2. In fact, fY|X(y|x) = 1/(1 − x) for x < y < 1 and

as expected. Thus, (Y|X) =(1 + X)/2. Notice that (Y|X) = (1 + X)/2 is a random variable whose value is the number (Y|X = x) = (1 + x)/2 once X = x is observed. ■

3.24 Theorem (The Rule of Iterated Expectations). For random variables X and Y, assuming the expectations exist, we have that

(3.15)

More generally, for any function r(x, y) we have

(3.16)

Proof. We’ll prove the first equation. Using the definition of conditional expectation and the fact that f(x, y) = f(x)f(y|x),

3.25 Example. Consider example 3.23. How can we compute (Y)? One method is to find the joint density f(x, y) and then compute (Y) = ∫ ∫ yf(x, y)dxdy. An easier way is to do this in two steps. First, we already know that (Y|X) = (1 + X)/2. Thus,

3.26 Definition. The conditional variance is defined as

(3.17)

where μ(x) = (Y|X = x).

3.27 Theorem. For random variables X and Y,

3.28 Example. Draw a county at random from the United States. Then draw n people at random from the county. Let X be the number of those people who have a certain disease. If Q denotes the proportion of people in that county with the disease, then Q is also a random variable since it varies from county to county. Given Q = q, we have that X ∼ Binomial(n, q). Thus, (X|Q = q) = nq and (X|Q = q) = nq(1 − q). Suppose that the random variable Q has a Uniform (0,1) distribution. A distribution that is constructed in stages like this is called a hierarchical model and can be written as

Now, (X) = (X|Q) = (nQ) = n(Q) = n/2. Let us compute the variance of X. Now, (X) = (X|Q) + (X|Q). Let’s compute these two terms. First, (X|Q) = [nQ(1 − Q)] = n(Q(1 − Q)) = n ∫ q(1 − . Next, (X|Q) = (nQ) = n²(Q) = n² ∫(q − (1/2)) ²dq = n²/12. Hence, (X) = (n/6) + (n²/12). ■

3.6 Moment Generating Functions

Now we will define the moment generating function which is used for finding moments, for finding the distribution of sums of random variables and which is also used in the proofs of some theorems.

3.29 Definition. The moment generating function mgf, or Laplace transform, of X is defined by

where t varies over the real numbers.

In what follows, we assume that the mgf is well defined for all t in some open interval around t = 0. ²

When the mgf is well defined, it can be shown that we can interchange the operations of differentiation and “taking expectation.” This leads to

By taking k derivatives we conclude that ψ(k)(0) = (Xk). This gives us a method for computing the moments of a distribution.

3.30 Example. Let X ∼ Exp(1). For any t < 1,

The integral is divergent if t ≥ 1. So, ψX(t) = 1/(1 − t) for all t < 1. Now, ψ′ (0) = 1 and ψ″ (0) = 2. Hence, (X) = 1 and (X) = (X²) − μ² = 2 − 1 = 1. ■

3.31 Lemma. Properties of the mgf.

(1) If Y = aX + b, then ψY(t) = ebtψX(at).

(2) If X₁,..., Xn are independent and Y = ∑i Xi, then ψY(t) = ∏i ψi (t) where ψi is the mgf of Xi.

3.32 Example. Let X ∼ Binomial(n, p). We know that X = where ℙ(Xi = 1) = p and ℙ(Xi = 0) = 1 − p. Now ψi(t) = eXit = (p × et) + ((1 − p)) = pet + q where q = 1 − p. Thus, ψX(t) = ∏i ψi (t) = (pet + q)n. ■

Recall that X and Y are equal in distribution if they have the same distribution function and we write .

3.33 Theorem. Let X and Y be random variables. If ψX (t) = ψY(t) for all t in an open interval around 0, then .

3.34 Example. Let X₁ ∼ Binomial(n₁, p) and X₂ ∼ Binomial(n₂, p) be independent. Let Y = X₁ + X₂. Then,

and we recognize the latter as the mgf of a Binomial(n₁ + n₂, p) distribution. Since the mgf characterizes the distribution (i.e., there can’t be another random variable which has the same mgf) we conclude that Y ∼ Binomial(n₁ + n₂, p). ■

Moment Generating Functions for Some Common Distributions

Distribution

MGF ψ(t)

Bernoulli(p)

pet + (1 − p)

Binomial(n, p)

(pet + (1 − p))n

Poisson(λ)

eλ(et − 1)

Normal(μ, σ)

Gamma(α, β)

for t < 1/β

3.35 Example. Let Y₁ ∼ Poisson(λ₁) and Y₂ ∼ Poisson(λ₂) be independent. The moment generating function of Y = Y₁ + Y + 2 is ψY(t) = ψY₁(t)ψY₂(t)eλ₁(et − 1)eλ₂(et − 1) = e(λ₁ + λ₂)(et − 1) which is the moment generating function of a Poisson(λ₁ + λ₂). We have thus proved that the sum of two independent Poisson random variables has a Poisson distribution. ■

3.7 Appendix

Expectation as an Integral. The integral of a measurable function r(x) is defined as follows. First suppose that r is simple, meaning that it takes finitely many values a₁,..., ak over a partition A₁,..., Ak. Then define

The integral of a positive measurable function r is defined by ∫ r(x)dF(x) = limi ∫ ri(x)dF(x) where ri is a sequence of simple functions such that ri (x) ≤ r(x) and ri (x) → r(x) as i → ∞. This does not depend on the particular sequence. The integral of a measurable function r is defined to be ∫ r(x)dF(x) = ∫ r ⁺(x)dF(x) − ∫ r⁻(x)dF(x) assuming both integrals are finite, where r⁺(x) = max{r(x), 0} and r⁻(x) = − min{r(x), 0}.

3.8 Exercises

1.

Suppose we play a game where we start with c dollars. On each play of the game you either double or halve your money, with equal probability. What is your expected fortune after n trials?

2.

Show that (X) = 0 if and only if there is a constant c such that P(X = c) = 1.

3.

Let X₁,..., Xn ∼ Uniform(0, 1) and let Yn = max{X₁,..., Xn}. Find (Yn).

4.

A particle starts at the origin of the real line and moves along the line in jumps of one unit. For each jump the probability is p that the particle will jump one unit to the left and the probability is 1 − p that the particle will jump one unit to the right. Let Xn be the position of the particle after n units. Find (Xn) and (Xn). (This is known as a random walk.)

5.

A fair coin is tossed until a head is obtained. What is the expected number of tosses that will be required?

6.

Prove Theorem 3.6 for discrete random variables.

7.

Let X be a continuous random variable with cdf F. Suppose that P(X > 0) = 1 and that (X) exists. Show that x)dx.
Hint: Consider integrating by parts. The following fact is helpful: if (X) exists then limx→∞x[1 − F(x) = 0].

8.

Prove Theorem 3.17.

9.

(Computer Experiment.) Let X₁, X₂,..., Xn be N(0, 1) random variables and let . Plot versus n for n = 1,..., 10,000. Repeat for X₁, X₂,..., Xn ∼ Cauchy. Explain why there is such a difference.

10.

Let X ∼ N(0, 1) and let Y = eX. Find (Y) and (Y).

11.

(Computer Experiment: Simulating the Stock Market.) Let Y₁, Y₂,... be independent random variables such that P(Yi = 1) = P(Yi = −1) = 1/2. Let . Think of Yi = 1 as “the stock price increased by one dollar”, Yi = −1 as “the stock price decreased by one dollar”, and Xn as the value of the stock on day n.

(a)

Find (Xn) and (Xn).

(b)

Simulate Xn and plot Xn versus n for n = 1, 2,..., 10,000. Repeat the whole simulation several times. Notice two things. First, it’s easy to “see” patterns in the sequence even though it is random. Second, you will find that the four runs look very different even though they were generated the same way. How do the calculations in (a) explain the second observation?

12.

Prove the formulas given in the table at the beginning of Section 3.4 for the Bernoulli, Poisson, Uniform, Exponential, Gamma, and Beta. Here are some hints. For the mean of the Poisson, use the fact that . To compute the variance, first compute (X(X − 1)). For the mean of the Gamma, it will help to multiply and divide by Γ(α + 1) /βα+1 and use the fact that a Gamma density integrates to 1. For the Beta, multiply and divide by Γ(α + 1)Γ(β)/Γ(α + β + 1).

13.

Suppose we generate a random variable X in the following way. First we flip a fair coin. If the coin is heads, take X to have a Unif(0,1) distribution. If the coin is tails, take X to have a Unif(3,4) distribution.

(a)

Find the mean of X.

(b)

Find the standard deviation of X.

14.

Let X₁,..., Xm and Y₁,..., Yn be random variables and let a₁,..., am and b₁,..., bn be constants. Show that

15.

Let

Find (2X − 3Y + 8).

16.

Let r(x) be a function of x and let s(y) be a function of y. Show that

Also, show that (r(X)|X) = r(X).

17.

Prove that

Hint: Let m = (Y) and let b(x) = (Y|X = x). Note that (b(X)) = (Y|X) = (Y) = m. Bear in mind that b is a function of x. Now write (Y) = (Y − m) ² = ((Y − b(X)) + (b(X) −m)) ². Expand the square and take the expectation. You then have to take the expectation of three terms. In each case, use the rule of the iterated expectation: (stuff) = ((stuff|X)).

18.

Show that if (X|Y = y) = c for some constant c, then X and Y are uncorrelated.

19.

This question is to help you understand the idea of a sampling distribution. Let X₁,..., Xn be iid with mean μ and variance σ². Let . Then is a statistic, that is, a function of the data. Since is a random variable, it has a distribution. This distribution is called the sampling distribution of the statistic. Recall from Theorem 3.17 that () = μ and () = σ²n. Don’t confuse the distribution of the data fX and the distribution of the statistic . To make this clear, let X₁,..., Xn ∼ Uniform(0, 1). Let fX be the density of the Uniform(0, 1). Plot fX. Now let . Find () and (). Plot them as a function of n. Interpret. Now simulate the distribution of for n = 1, 5, 25, 100. Check that the simulated values of () and () agree with your theoretical calculations. What do you notice about the sampling distribution of as n increases?

20.

Prove Lemma 3.21.

21.

Let X and Y be random variables. Suppose that (Y|X) = X. Show that Cov(X, Y) = (X).

22.

Let X ∼ Uniform(0, 1). Let 0 < a < b < 1. Let

and let

(a)

Are Y and Z independent? Why/Why not?

(b)

Find (Y|Z). Hint: What values z can Z take? Now find (Y|Z = z).

23.

Find the moment generating function for the Poisson, Normal, and Gamma distributions.

24.

Let X₁,..., Xn ∼ Exp(β). Find the moment generating function of Xi. Prove that ∼ Gamma(n, β).

¹

We can’t use (X− μ) as a measure of spread since (X − μ) = − μ = μ − μ = 0. We can and sometimes do use |X − μ| as a measure of spread but more often we use the variance.

²

A related function is the characteristic function, defined by (eitX) where . This function is always well defined for all t.

4
Inequalities

Larry Wasserman1

(1)

Department of Statistics, Carnegie Mellon University, Baker Hall 228A, 15213-3890, Pittsburgh, PA, USA

Larry Wasserman

Email: larry@stat.cmu.edu

4.1 Probability Inequalities

Inequalities are useful for bounding quantities that might otherwise be hard to compute. They will also be used in the theory of convergence which is discussed in the next chapter. Our first inequality is Markov’s inequality.

4.1 Theorem (Markov’s inequality). Let X be a non-negative random variable and suppose that exists. For any t > 0,

(4.1)

Proof. Since X > 0,

4.2 Theorem (Chebyshev’s inequality). Let and . Then,

(4.2)

where Z = (X − μ)/σ. In particular, ℙ(|Z| > 2) ≤ 1/4 and ℙ(|Z| > 3) ≤ 1/9.

Proof. We use Markov’s inequality to conclude that

The second part follows by setting t = kσ. ■

4.3 Example. Suppose we test a prediction method, a neural net for example, on a set of n new test cases. Let Xi = 1 if the predictor is wrong and Xi = 0 if the predictor is right. Then is the observed error rate. Each Xi may be regarded as a Bernoulli with unknown mean p. We would like to know the true — but unknown — error rate p. Intuitively, we expect that should be close to p. How likely is to not be within ϵ of p? We have that and

since p(1 − p) ≤ ¼ for all p. For ϵ = .2 and n = 100 the bound is .0625. ■

Hoeffding’s inequality is similar in spirit to Markov’s inequality but it is a sharper inequality. We present the result here in two parts.

4.4 Theorem (Hoeffding’s Inequality). Let Y₁,..., Yn be independent observations such that
and ai ≤ Yi ≤ bi. Let ϵ > 0. Then, for any t > 0,

(4.3)

4.5 Theorem. Let X₁,..., Xn ∼ Bernoulli(p). Then, for any ϵ > 0,

(4.4)

where .

4.6 Example. Let X₁,..., Xn ∼ Bernoulli(p). Let n = 100 and ϵ = .2. We saw that Chebyshev’s inequality yielded

According to Hoeffding’s inequality,

which is much smaller than .0625. ■

Hoeffding’s inequality gives us a simple way to create a confidence interval for a binomial parameter p. We will discuss confidence intervals in detail later (see Chapter 6) but here is the basic idea. Fix α > 0 and let

By Hoeffding’s inequality,

Let . Then, . Hence, ℙ(p ∈ C) ≥ 1 − α, that is, the random interval C traps the true parameter value p with probability 1 − α; we call C a 1 − α confidence interval. More on this later.

The following inequality is useful for bounding probability statements about Normal random variables.

4.7 Theorem (Mill’s Inequality). Let Z ∼ N(0, 1). Then,

4.2 Inequalities For Expectations

This section contains two inequalities on expected values.

4.8 Theorem (Cauchy-Schwartz inequality). If X and Y have finite variances then

(4.5)

Recall that a function ɡ is convex if for each x, y and each α ∈ [0, 1],

If ɡ is twice differentiable and ɡ″(x) ≥ 0 for all x, then ɡ is convex. It can be shown that if ɡ is convex, then ɡ lies above any line that touches ɡ at some point, called a tangent line. A function ɡ is concave if −ɡ is convex. Examples of convex functions are ɡ(x) = x² and ɡ(x) = ex. Examples of concave functions are ɡ(x) = −x² and ɡ(x) = log x.

4.9 Theorem (Jensen’s inequality). If ɡ is convex, then

(4.6)

If ɡ is concave, then

(4.7)

Proof. Let L(x) = a + bx be a line, tangent to ɡ(x) at the point . Since ɡ is convex, it lies above the line L(x). So,

From Jensen’s inequality we see that and if X is positive, then . Since log is concave .

4.3 Bibliographic Remarks

Devroye et al. (1996) is a good reference on probability inequalities and their use in statistics and pattern recognition. The following proof of Hoeffding’s inequality is from that text.

4.4 Appendix

Proof of Hoeffding’s Inequality. We will make use of the exact form of Taylor’s theorem: if ɡ is a smooth function, then there is a number ξ ∈ (0, u) such that .

Proof of Theorem 4.4. For any t > 0, we have, from Markov’s inequality, that

(4.8)

Since ai ≤ Yi ≤ bi, we can write Yi as a convex combination of ai and bi, namely, Yi = αbi + (1 − α)ai where α = (Y − ai)/(bi − ai). So, by the convexity of ety we have

Take expectations of both sides and use the fact that to get

(4.9)

where u = t(bi − ai), ɡ(u) = −γu + log(1 − γ + γeu) and γ = −ai/(bi − ai).

Note that ɡ(0) = ɡ′(0) = 0. Also, ɡ″(u) ≤ 1/4 for all u > 0. By Taylor’s theorem, there is a ξ ∈ (0, u) such that

Hence,

The result follows from (4.8). ■

Proof of Theorem 4.5. Let Yi = (1/n)(Xi − p). Then and a ≤ Yi ≤ b where a = −p/n and b = (1 − p)/n. Also, (b − a)² = 1/n². Applying Theorem 4.4 we get

The above holds for any t > 0. In particular, take t = 4nϵ and we get p > ϵ) ≤ e−2nϵ². By a similar argument we can show that e−2nϵ². Putting these together we get . ■

4.5 Exercises

1.

Let X ∼ Exponential(β). Find ℙ(|X − μX| ≥ kσX for k > 1. Compare this to the bound you get from Chebyshev’s inequality.

2.

Let X ∼ Poisson(λ). Use Chebyshev’s inequality to show that ℙ(X ≥ 2λ) ≤ 1/λ.

3.

Let X₁,..., Xn ∼ Bernoulli(p) and . Bound p| > ϵ) using Chebyshev’s inequality and using Hoeffding’s inequality. Show that, when n is large, the bound from Hoeffding’s inequality is smaller than the bound from Chebyshev’s inequality.

4.

Let X₁,..., Xn ∼ Bernoulli(p).

(a)

Let α > 0 be fixed and define

Let . Define . Use Hoeffding’s inequality to show that

In practice, we truncate the interval so it does not go below 0 or above 1.

(b)

(Computer Experiment.) Let’s examine the properties of this confidence interval. Let α = 0.05 and p = 0.4. Conduct a simulation study to see how often the interval contains p (called the coverage). Do this for various values of n between 1 and 10000. Plot the coverage versus n.

(c)

Plot the length of the interval versus n. Suppose we want the length of the interval to be no more than .05. How large should n be?

5.

Prove Mill’s inequality, Theorem 4.7. Hint. Note that ℙ(|Z| > t) = 2ℙ(Z > t). Now write out what ℙ(Z > t) means and note that x/t > 1 whenever x > t.

6.

Let Z ∼ N(0, 1). Find ℙ(|Z| > t) and plot this as a function of t. From Markov’s inequality, we have the bound for any k > 0. Plot these bounds for k = 1, 2, 3, 4, 5 and compare them to the true value of ℙ(|Z| > t). Also, plot the bound from Mill’s inequality.

7.

Let X₁,..., Xn ∼ N(0, 1). Bound using Mill’s inequality, where . Compare to the Chebyshev bound.

5
Convergence of Random Variables

Larry Wasserman1

(1)

Department of Statistics, Carnegie Mellon University, Baker Hall 228A, 15213-3890, Pittsburgh, PA, USA

Larry Wasserman

Email: larry@stat.cmu.edu

5.1 Introduction

The most important aspect of probability theory concerns the behavior of sequences of random variables. This part of probability is called large sample theory, or limit theory, or asymptotic theory. The basic question is this: what can we say about the limiting behavior of a sequence of random variables X₁, X₂, X₃,...? Since statistics and data mining are all about gathering data, we will naturally be interested in what happens as we gather more and more data.

In calculus we say that a sequence of real numbers xn converges to a limit x if, for every ϵ > 0, |xn − x| < ϵ for all large n. In probability, convergence is more subtle. Going back to calculus for a moment, suppose that xn = x for all n. Then, trivially, limn→∞ xn = x. Consider a probabilistic version of this example. Suppose that X₁, X₂,... is a sequence of random variables which are independent and suppose each has a N(0, 1) distribution. Since these all have the same distribution, we are tempted to say that Xn “converges” to X ∼ N(0, 1). But this can’t quite be right since ℙ(Xn = X) = 0 for all n. (Two continuous random variables are equal with probability zero.)

Here is another example. Consider X₁, X₂,... where Xi ∼ N(0, 1/n). Intuitively, Xn is very concentrated around 0 for large n so we would like to say that Xn converges to 0. But ℙ(Xn = 0) = 0 for all n. Clearly, we need to develop some tools for discussing convergence in a rigorous way. This chapter develops the appropriate methods.

There are two main ideas in this chapter which we state informally here:

1.

The law of large numbers says that the sample average converges in probability to the expectation . This means that is close to μ with high probability.

2.

The central limit theorem says that converges in distribution to a Normal distribution. This means that the sample average has approximately a Normal distribution for large n.

5.2 Types of Convergence

The two main types of convergence are defined as follows.

5.1 Definition. Let X₁, X₂,... be a sequence of random variables and let X be another random variable. Let Fn denote the cdf of Xn and let F denote the cdf of X.

1.

Xn converges to X in probability, written , if, for every ϵ > 0,

(5.1)

as n → ∞.

2.

Xn converges to X in distribution, written , if

(5.2)

at all t for which F is continuous.

When the limiting random variable is a point mass, we change the notation slightly. If ℙ(X = c) = 1 and then we write . Similarly, if we write .

There is another type of convergence which we introduce mainly because it is useful for proving convergence in probability.

5.2 Definition. Xn converges to X in quadratic mean (also called convergence in L₂), written , if

(5.3)

as n → ∞.

Again, if X is a point mass at c we write instead of .

5.3 Example. Let Xn ∼ N(0, 1/n). Intuitively, Xn is concentrating at 0 so we would like to say that Xn converges to 0. Let’s see if this is true. Let F be the distribution function for a point mass at 0. Note that . Let Z denote a standard normal random variable. For t < 0, Fn (t) = ℙ(Xn < since . For t > 0, since . Hence, Fn (t) → F(t) for all t ≠ 0 and so . Notice that Fn (0) = 1/2 ≠ F(1/2) = 1 so convergence fails at t = 0. That doesn’t matter because t = 0 is not a continuity point of F and the definition of convergence in distribution only requires convergence at continuity points. See Figure 5.1. Now consider convergence in probability. For any ϵ > 0, using Markov’s inequality,

as n → ∞. Hence, . ■

FIGURE 5.1.

Example 5.3. Xn converges in distribution to X because Fn(t) converges to F(t) at all points except t = 0. Convergence is not required at t = 0 because t = 0 is not a point of continuity for F.

The next theorem gives the relationship between the types of convergence. The results are summarized in Figure 5.2.

FIGURE 5.2.

Relationship between types of convergence.

5.4 Theorem. The following relationships hold:

(a)

implies that .

(b)

implies that .

(c)

If and if ℙ(X = c) = 1 for some real number c, then .

In general, none of the reverse implications hold except the special case in (c).

Proof. We start by proving (a). Suppose that . Fix ϵ > 0. Then, using Markov’s inequality,

Proof of (b). This proof is a little more complicated. You may skip it if you wish. Fix ϵ > 0 and let x be a continuity point of F. Then

Also,

Hence,

Take the limit as n → ∞ to conclude that

This holds for all ϵ > 0. Take the limit as ϵ → 0 and use the fact that F is continuous at x and conclude that limn Fn(x) = F(x).

Proof of (c). Fix ϵ > 0. Then,

Let us now show that the reverse implications do not hold.

Convergence in probability does not imply convergence in quadratic mean. Let U ∼ Unif(0, 1) and let . Then ℙ(|Xn| > ϵ) = . Hence, . But for all n so Xn does not converge in quadratic mean.

Convergence in distribution does not imply convergence in probability. Let X ∼ N(0, 1). Let Xn = −X for n = 1, 2, 3,...; hence Xn ∼ N(0, 1). Xn has the same distribution function as X for all n so, trivially, limn Fn(x) = F(x) for all x. Therefore, . But ℙ(|Xn − X| > ϵ) = ℙ(|2X| > ϵ) = ℙ(|X| > ϵ/2) ≠ 0. So Xn does not converge to X in probability. ■

Warning! One might conjecture that if , then . This is not¹ true. Let Xn be a random variable defined by ℙ(Xn = n²) = 1/n and ℙ(Xn = 0) = 1 − (1/n). Now, ℙ(|Xn| < ϵ) = ℙ(Xn = 0) = 1 − (1/n) → 1. Hence, . However, . Thus, .

Summary. Stare at Figure 5.2.

Some convergence properties are preserved under transformations.

5.5 Theorem. Let Xn, X, Yn, Y be random variables. Let ɡ be a continuous function.

(a) If and , then .

(b) If and , then .

(c) If and , then .

(d) If and , then .

(e) If and , then .

(f) If , then .

(g) If , then .

Parts (c) and (e) are know as Slutzky’s theorem. It is worth noting that and does not in general imply that .

5.3 The Law of Large Numbers

Now we come to a crowning achievement in probability, the law of large numbers. This theorem says that the mean of a large sample is close to the mean of the distribution. For example, the proportion of heads of a large number of tosses is expected to be close to 1/2. We now make this more precise.

Let X₁, X₂,... be an iid sample, let and ² . Recall that the sample mean is defined as and that and .

5.6 Theorem (The Weak Law of Large Numbers (WLLN)).³ If X₁,..., Xn are iid, then .

Interpretation of the WLLN: The distribution of becomes more concentrated around μ as n gets large.

Proof. Assume that σ < ∞. This is not necessary but it simplifies the proof. Using Chebyshev’s inequality,

which tends to 0 as n → ∞. ■

5.7 Example. Consider flipping a coin for which the probability of heads is p. Let Xi denote the outcome of a single toss (0 or 1). Hence, p = P(Xi = 1) = E(Xi). The fraction of heads after n tosses is . According to the law of large numbers, converges to p in probability. This does not mean that will numerically equal p. It means that, when n is large, the distribution of is tightly concentrated around p. Suppose that p = 1/2. How large should n be so that ? First, and . From Chebyshev’s inequality,

The last expression will be larger than .7 if n = 84. ■

5.4 The Central Limit Theorem

The law of large numbers says that the distribution of piles up near μ. This isn’t enough to help us approximate probability statements about . For this we need the central limit theorem.

Suppose that X₁,..., Xn are iid with mean μ and variance σ². The central limit theorem (CLT) says that has a distribution which is approximately Normal with mean μ and variance σ²/n. This is remarkable since nothing is assumed about the distribution of Xi, except the existence of the mean and variance.

5.8 Theorem (The Central Limit Theorem (CLT)). Let X₁,..., Xn be iid with mean μ and variance σ². Let . Then

where Z ∼ N(0, 1). In other words,

Interpretation: Probability statements about can be approximated using a Normal distribution. It’s the probability statements that we are approximating, not the random variable itself.

In addition to , there are several forms of notation to denote the fact that the distribution of Zn is converging to a Normal. They all mean the same thing. Here they are:

5.9 Example. Suppose that the number of errors per computer program has a Poisson distribution with mean 5. We get 125 programs. Let X₁,..., X₁₂₅ be the number of errors in the programs. We want to approximate . Let and . Then,

The central limit theorem tells us that is approximately N(0,1). However, we rarely know σ. Later, we will see that we can estimate σ² from X₁,..., Xn by

This raises the following question: if we replace σ with Sn, is the central limit theorem still true? The answer is yes.

5.10 Theorem. Assume the same conditions as the CLT. Then,

You might wonder, how accurate the normal approximation is. The answer is given in the Berry-Essèen theorem.

5.11 Theorem (The Berry-Essèen Inequality). Suppose that . Then

(5.4)

There is also a multivariate version of the central limit theorem.

5.12 Theorem (Multivariate central limit theorem). Let X₁,..., Xn be iid random vectors where

with mean

and variance matrix Σ. Let

where . Then,

5.5 The Delta Method

If Yn has a limiting Normal distribution then the delta method allows us to find the limiting distribution of ɡ(Yn) where ɡ is any smooth function.

5.13 Theorem (The Delta Method). Suppose that

and that ɡ is a differentiable function such that ɡ′ (μ) ≠ 0. Then

In other words,

5.14 Example. Let X₁,..., Xn be iid with finite mean μ and finite variance σ². By the central limit theorem, . Let . Thus, where ɡ(s) = es. Since ɡ′(s) = es, the delta method implies that Wn ≈ N(eμ, e2μσ²/n). ■

There is also a multivariate version of the delta method.

5.15 Theorem (The Multivariate Delta Method). Suppose that Yn = (Yn1,..., Ynk) is a sequence of random vectors such that

Let ɡ : ℝk → ℝ and let

Let ∇μ denote ∇ɡ(y) evaluated at y = μ and assume that the elements of ∇μ are nonzero. Then

5.16 Example. Let

be iid random vectors with mean μ = (μ₁, μ₂)T and variance Σ. Let

and define . Thus, where ɡ(s₁, s₂) = s₁ s₂. By the central limit theorem,

Now

and so

Therefore,

5.6 Bibliographic Remarks

Convergence plays a central role in modern probability theory. For more details, see Grimmett and Stirzaker (1982), Karr (1993), and Billingsley (1979). Advanced convergence theory is explained in great detail in van der Vaart and Wellner (1996) and and van der Vaart (1998).

5.7 Appendix

5.7.1 Almost Sure and L₁ Convergence

We say that Xn converges almost surely to X, written , if

We say that Xn converges in L₁ to X, written , if

as n → ∞.

5.17 Theorem. Let Xn and X be random variables. Then:

(a) implies that .

(b) implies that .

(c) implies that .

The weak law of large numbers says that converges to in probability. The strong law asserts that this is also true almost surely.

5.18 Theorem (The Strong Law of Large Numbers). Let X₁, X₂,... be iid. If then .

A sequence Xn is asymptotically uniformly integrable if

5.19 Theorem. If and Xn is asymptotically uniformly integrable, then .

5.7.2 Proof of the Central Limit Theorem

Recall that if X is a random variable, its moment generating function (mgf) is . Assume in what follows that the mgf is finite in a neighborhood around t = 0.

5.20 Lemma. Let Z₁, Z₂,... be a sequence of random variables. Let ψn be the mgf of Zn. Let Z be another random variable and denote its mgf by ψ. If ψn(t) → ψ(t) for all t in some open interval around 0, then .

proof of the central limit theorem. Let Yi = (Xi − μ)/σ. Then, Zn = n−1/2 ∑iYi. Let ψ(t) be the mgf of Yi. The mgf of ∑iYi is (ψ(t))n and mgf of Zn is . Now , ψ″(0) = . So,

Now,

which is the mgf of a N(0,1). The result follows from the previous Theorem. In the last step we used the fact that if an → a then

■

5.8 Exercises

1.

Let X₁,..., Xn be iid with finite mean and finite variance . Let be the sample mean and let be the sample variance.

(a)

Show that .

(b)

Show that . Hint: Show that where cn → 1 and dn → 1. Apply the law of large numbers to and to . Then use part (e) of Theorem 5.5.

2.

Let X₁, X₂,... be a sequence of random variables. Show that if and only if

3.

Let X₁,..., Xn be iid and let . Suppose that the variance is finite. Show that .

4.

Let X₁, X₂,... be a sequence of random variables such that

Does Xn converge in probability? Does Xn converge in quadratic mean?

5.

Let X₁,..., Xn ∼ Bernoulli(p). Prove that

6.

Suppose that the height of men has mean 68 inches and standard deviation 2.6 inches. We draw 100 men at random. Find (approximately) the probability that the average height of men in our sample will be at least 68 inches.

7.

Let λn = 1/n for n = 1, 2,.... Let Xn ∼ Poisson(λn).

(a)

Show that .

(b)

Let Yn = nXn. Show that .

8.

Suppose we have a computer program consisting of n = 100 pages of code. Let Xi be the number of errors on the ith page of code. Suppose that the are Poisson with mean 1 and that they are independent. Let be the total number of errors. Use the central limit theorem to approximate ℙ(Y < 90).

9.

Suppose that ℙ(X = 1) = ℙ(X = −1) = 1/2. Define

Does Xn converge to X in probability? Does Xn converge to X in distribution? Does converge to 0?

10.

Let Z ∼ N(0, 1). Let t > 0. Show that, for any k > 0,

Compare this to Mill’s inequality in Chapter 4.

11.

Suppose that Xn ∼ N(0, 1/n) and let X be a random variable with distribution F(x) = 0 if x < 0 and F(x) = 1 if x ≥ 0. Does Xn converge to X in probability? (Prove or disprove). Does Xn converge to X in distribution? (Prove or disprove).

12.

Let X, X₁, X₂, X₃,... be random variables that are positive and integer valued. Show that if and only if

for every integer k.

13.

Let Z₁, Z₂,... be iid random variables with density f. Suppose that ℙ(Zi > 0) = 1 and that λ = limx↓0 f(x) > 0. Let

Show that where Z has an exponential distribution with mean 1/λ.

14.

Let X₁,..., Xn ∼ Uniform(0, 1). Let . Find the limiting distribution of Yn.

15.

Let

be iid random vectors with mean μ = (μ₁, μ₂) and variance Σ. Let

and define . Find the limiting distribution of Yn.

16.

Construct an example where and but Xn + Yn does not converge in distribution to X + Y.

¹

We can conclude that if Xn is uniformly integrable. See the appendix.

²

Note that is the same for all i so we can define for any i. By convention, we often write .

³

There is a stronger theorem in the appendix called the strong law of large numbers.

Part II
Statistical Inference

6
Models, Statistical Inference and Learning

Larry Wasserman1

(1)

Department of Statistics, Carnegie Mellon University, Baker Hall 228A, 15213-3890, Pittsburgh, PA, USA

Larry Wasserman

Email: larry@stat.cmu.edu

6.1 Introduction

Statistical inference, or “learning” as it is called in computer science, is the process of using data to infer the distribution that generated the data. A typical statistical inference question is:

In some cases, we may want to infer only some feature of F such as its mean.

6.2 Parametric and Nonparametric Models

A statistical model is a set of distributions (or densities or regression functions). A parametric model is a set that can be parameterized by a finite number of parameters. For example, if we assume that the data come from a Normal distribution, then the model is

(6.1)

This is a two-parameter model. We have written the density as f(x; μ, σ) to show that x is a value of the random variable whereas μ and σ are parameters. In general, a parametric model takes the form

(6.2)

where θ is an unknown parameter (or vector of parameters) that can take values in the parameter space Θ. If θ is a vector but we are only interested in one component of θ, we call the remaining parameters nuisance parameters. A nonparametric model is a set that cannot be parameterized by a finite number of parameters. For example, is nonparametric.¹

6.1 Example (One-dimensional Parametric Estimation). Let X₁,..., Xn be independent Bernoulli(p) observations. The problem is to estimate the parameter p. ■

6.2 Example (Two-dimensional Parametric Estimation). Suppose that X₁,..., Xn ∼ F and we assume that the pdf where is given in (6.1). In this case there are two parameters, μ and σ. The goal is to estimate the parameters from the data. If we are only interested in estimating μ, then μ is the parameter of interest and σ is a nuisance parameter. ■

6.3 Example (Nonparametric estimation of the cdf). Let X₁,..., Xn be independent observations from a cdf F. The problem is to estimate F assuming only that = {all cdf’s}. ■

6.4 Example (Nonparametric density estimation). Let X₁,..., Xn be independent observations from a cdf F and let f = F′ be the pdf. Suppose we want to estimate the pdf f. It is not possible to estimate f assuming only that . We need to assume some smoothness on f. For example, we might assume that where is the set of all probability density functions and

The class is called a Sobolev space; it is the set of functions that are not “too wiggly.” ■

6.5 Example (Nonparametric estimation of functionals). Let X₁,..., Xn ∼ F. Suppose we want to estimate μ = (X₁) = ∫ x dF(x) assuming only that μ exists. The mean μ may be thought of as a function of F: we can write μ = T(F) = ∫ x dF(x). In general, any function of F is called a statistical functional. Other examples of functionals are the variance T(F) = ∫ x²dF(x) − (∫ xdF(x))² and the median T(F) = F⁻¹(1/2). ■

6.6 Example (Regression, prediction, and classification). Suppose we observe pairs of data (X₁, Y₁),... (Xn, Yn). Perhaps Xi is the blood pressure of subject i and Yi is how long they live. X is called a predictor or regressor or feature or independent variable. Y is called the outcome or the response variable or the dependent variable. We call r(x) = (Y|X = x) the regression function. If we assume that where is finite dimensional — the set of straight lines for example — then we have a parametric regression model. If we assume that where is not finite dimensional then we have a nonparametric regression model. The goal of predicting Y for a new patient based on their X value is called prediction. If Y is discrete (for example, live or die) then prediction is instead called classification. If our goal is to estimate the function r, then we call this regression or curve estimation. Regression models are sometimes written as

(6.3)

where (ϵ) = 0. We can always rewrite a regression model this way. To see this, define ϵ = Y − r(X) and hence Y = Y + r(X) − r(X) = r(X) + ϵ. Moreover, (ϵ) = (ϵ|X) = ((Y − r(X))|X) = ((Y|X) − r(X)) = (r(X) − r(X)) = 0. ■

What’s Next? It is traditional in most introductory courses to start with parametric inference. Instead, we will start with nonparametric inference and then we will cover parametric inference. In some respects, nonparametric inference is easier to understand and is more useful than parametric inference.

Frequentists and Bayesians. There are many approaches to statistical inference. The two dominant approaches are called frequentist inference and Bayesian inference. We’ll cover both but we will start with frequentist inference. We’ll postpone a discussion of the pros and cons of these two until later.

Some Notation. If is a parametric model, we write ℙθ(X ∈ A) = ∫A f(x; θ)dx and θ(r(X)) = ∫ r(x)f(x; θ)dx. The subscript θ indicates that the probability or expectation is with respect to f(x; θ); it does not mean we are averaging over θ. Similarly, we write for the variance.

6.3 Fundamental Concepts in Inference

Many inferential problems can be identified as being one of three types: estimation, confidence sets, or hypothesis testing. We will treat all of these problems in detail in the rest of the book. Here, we give a brief introduction to the ideas.

6.3.1 Point Estimation

Point estimation refers to providing a single “best guess” of some quantity of interest. The quantity of interest could be a parameter in a parametric model, a cdf F, a probability density function f, a regression function r, or a prediction for a future value Y of some random variable.

By convention, we denote a point estimate of θ by or . Remember that θ is a fixed, unknown quantity. The estimate depends on the data so is a random variable.

More formally, let X₁,..., Xn be n iid data points from some distribution F. A point estimator of a parameter θ is some function of X₁,..., Xn:

The bias of an estimator is defined by

(6.4)

We say that is unbiased if . Unbiasedness used to receive much attention but these days is considered less important; many of the estimators we will use are biased. A reasonable requirement for an estimator is that it should converge to the true parameter value as we collect more and more data. This requirement is quantified by the following definition:

6.7 Definition. A point estimator of a parameter θ is consistent if .

The distribution of is called the sampling distribution. The standard deviation of is called the standard error, denoted by se:

(6.5)

Often, the standard error depends on the unknown F. In those cases, se is an unknown quantity but we usually can estimate it. The estimated standard error is denoted by .

6.8 Example. Let X₁,..., Xn ∼ Bernoulli(p) and let . Then so is unbiased. The standard error is se = . The estimated standard error is . ■

The quality of a point estimate is sometimes assessed by the mean squared error, or mse defined by

(6.6)

Keep in mind that θ(·) refers to expectation with respect to the distribution

that generated the data. It does not mean we are averaging over a distribution for θ.

6.9 Theorem. The mse can be written as

(6.7)

Proof. Let . Then

where we have used the fact that . ■

6.10 Theorem. If bias → 0 and se → 0 as n → ∞ then is consistent, that is, .

Proof. If bias → 0 and se → 0 then, by Theorem 6.9, MSE → 0. It follows that . (Recall Definition 5.2.) The result follows from part (b) of Theorem 5.4. ■

6.11 Example. Returning to the coin flipping example, we have that = p so the bias = p − p = 0 and . Hence, , that is, is a consistent estimator. ■

Many of the estimators we will encounter will turn out to have, approximately, a Normal distribution.

6.12 Definition. An estimator is asymptotically Normal if

(6.8)

6.3.2 Confidence Sets

A 1 − α confidence interval for a parameter θ is an interval Cn = (a, b) where a = a(X₁,..., Xn) and b = b(X₁,..., Xn) are functions of the data such that

(6.9)

In words, (a, b) traps θ with probability 1 − α. We call 1 − α the coverage of the confidence interval.

Warning! Cn is random and θ is fixed.

Commonly, people use 95 percent confidence intervals, which corresponds to choosing α = 0.05. If θ is a vector then we use a confidence set (such as a sphere or an ellipse) instead of an interval.

Warning! There is much confusion about how to interpret a confidence interval. A confidence interval is not a probability statement about θ since θ is a fixed quantity, not a random variable. Some texts interpret confidence intervals as follows: if I repeat the experiment over and over, the interval will contain the parameter 95 percent of the time. This is correct but useless since we rarely repeat the same experiment over and over. A better interpretation is this:

On day 1, you collect data and construct a 95 percent confidence interval for a parameter θ₁. On day 2, you collect new data and construct a 95 percent confidence interval for an unrelated parameter θ₂. On day 3, you collect new data and construct a 95 percent confidence interval for an unrelated parameter θ₃. You continue this way constructing confidence intervals for a sequence of unrelated parameters θ₁, θ₂,... Then 95 percent of your intervals will trap the true parameter value. There is no need to introduce the idea of repeating the same experiment over and over.

6.13 Example. Every day, newspapers report opinion polls. For example, they might say that “83 percent of the population favor arming pilots with guns.” Usually, you will see a statement like “this poll is accurate to within 4 points 95 percent of the time.” They are saying that 83±4 is a 95 percent confidence interval for the true but unknown proportion p of people who favor arming pilots with guns. If you form a confidence interval this way every day for the rest of your life, 95 percent of your intervals will contain the true parameter. This is true even though you are estimating a different quantity (a different poll question) every day. ■

6.14 Example. The fact that a confidence interval is not a probability statement about θ is confusing. Consider this example from Berger and Wolpert (1984). Let θ be a fixed, known real number and let X₁, X₂ be independent random variables such that ℙ(Xi = 1) = ℙ(Xi = −1) = 1/2. Now define Yi = θ + Xi and suppose that you only observe Y₁ and Y₂. Define the following “confidence interval” which actually only contains one point:

You can check that, no matter what θ is, we have ℙθ(θ ∈ C) = 3/4 so this is a 75 percent confidence interval. Suppose we now do the experiment and we get Y₁ = 15 and Y₂ = 17. Then our 75 percent confidence interval is {16}. However, we are certain that θ = 16. If you wanted to make a probability statement about θ you would probably say that . There is nothing wrong with saying that {16} is a 75 percent confidence interval. But is it not a probability statement about θ. ■

In Chapter 11 we will discuss Bayesian methods in which we treat θ as if it were a random variable and we do make probability statements about θ. In particular, we will make statements like “the probability that θ is in Cn, given the data, is 95 percent.” However, these Bayesian intervals refer to degree-of-belief probabilities. These Bayesian intervals will not, in general, trap the parameter 95 percent of the time.

6.15 Example. In the coin flipping setting, let where . From Hoeffding’s inequality (4.4) it follows that

for every p. Hence, Cn is a 1 − α confidence interval. ■

As mentioned earlier, point estimators often have a limiting Normal distribution, meaning that equation (6.8) holds, that is, . In this case we can construct (approximate) confidence intervals as follows.

6.16 Theorem (Normal-based Confidence Interval). Suppose that . Let Φ be the cdf of a standard Normal and let zα/2 = Φ⁻¹(1 − (α/2)), that is, ℙ(Z > zα/2) = α/2 and ℙ(−zα/2 < Z < zα/2) = 1 − α where Z ∼ N(0, 1). Let

(6.10)

Then

(6.11)

Proof. Let . By assumption where Z ∼ N(0, 1). Hence,

■

For 95 percent confidence intervals, α = 0.05 and zα/2 = 1.96 ≈ 2 leading to the approximate 95 percent confidence interval

6.17 Example. Let X₁,..., Xn ∼ Bernoulli(p) and let Then . Hence, se and . By the Central Limit Theorem, . Therefore, an approximate 1 − α confidence interval is

Compare this with the confidence interval in example 6.15. The Normal-based interval is shorter but it only has approximately (large sample) correct coverage. ■

6.3.3 Hypothesis Testing

In hypothesis testing, we start with some default theory called a null hypothesis — and we ask if the data provide sufficient evidence to reject the theory. If not we retain the null hypothesis.²

6.18 Example (Test if a Coin is Fair). Let

be n independent coin flips. Suppose we want to test if the coin is fair. Let H₀ denote the hypothesis that the coin is fair and let H₁ denote the hypothesis that the coin is not fair. H₀ is called the null hypothesis and H₁ is called the alternative hypothesis. We can write the hypotheses as

It seems reasonable to reject H₀ if is large. When we discuss hypothesis testing in detail, we will be more precise about how large T should be to reject H₀. ■

6.4 Bibliographic Remarks

Statistical inference is covered in many texts. Elementary texts include DeG-root and Schervish (2002) and Larsen and Marx (1986). At the intermediate level I recommend Casella and Berger (2002), Bickel and Doksum (2000), and Rice (1995). At the advanced level, Cox and Hinkley (2000), Lehmann and Casella (1998), Lehmann (1986), and van der Vaart (1998).

6.5 Appendix

Our definition of confidence interval requires that ℙθ(θ ∈ Cn) ≥ 1 − α for all θ ∈ Θ. A pointwise asymptotic confidence interval requires that lim infn→∞ ℙθ(θ ∈ Cn) ≥ 1 − α for all θ ∈ Θ. A uniform asymptotic confidence interval requires that lim infn→∞ infθ∈Θ ℙθ(θ ∈ Cn) ≥ 1 − α. The approximate Normal-based interval is a pointwise asymptotic confidence interval.

6.6 Exercises

1.

Let X₁,..., Xn ∼ Poisson(λ) and let . Find the bias, se, and mse of this estimator.

2.

Let X₁,..., Xn Uniform(0, θ) and let . Find the bias, se, and mse of this estimator.

3.

Let X₁,..., Xn ∼ Uniform(0, θ) and let . Find the bias, se, and mse of this estimator.

¹

The distinction between parametric and nonparametric is more subtle than this but we don’t need a rigorous definition for our purposes.

²

The term “retaining the null hypothesis” is due to Chris Genovese. Other terminology is “accepting the null” or “failing to reject the null.”

7
Estimating the CDF and Statistical Functionals

Larry Wasserman1

(1)

Department of Statistics, Carnegie Mellon University, Baker Hall 228A, 15213-3890, Pittsburgh, PA, USA

Larry Wasserman

Email: larry@stat.cmu.edu

The first inference problem we will consider is nonparametric estimation of the cdf F. Then we will estimate statistical functionals, which are functions of cdf, such as the mean, the variance, and the correlation. The nonparametric method for estimating functionals is called the plug-in method.

7.1 The Empirical Distribution Function

Let X₁,..., Xn ∼ F be an iid sample where F is a distribution function on the real line. We will estimate F with the empirical distribution function, which is defined as follows.

7.1 Definition. The empirical distribution function is the cdf that puts mass 1/n at each data point Xi. Formally,

(7.1)

where

7.2 Example (Nerve Data). Cox and Lewis (1966) reported 799 waiting times between successive pulses along a nerve fiber. Figure 7.1 shows the empirical cdf . The data points are shown as small vertical lines at the bottom of the plot. Suppose we want to estimate the fraction of waiting times between .4 and .6 seconds. The estimate is ■

FIGURE 7.1.

Nerve data. Each vertical line represents one data point. The solid line is the empirical distribution function. The lines above and below the middle line are a 95 percent confidence band.

7.3 Theorem. At any fixed value of x,

7.4 Theorem (The Gilvenko-Cantelli Theorem). Let X₁,..., Xn ∼ F. Then¹

Now we give an inequality that will be used to construct a confidence band.

7.5 Theorem (The Dvoretzky-Kiefer-Wolfowitz (DKW) Inequality). Let X₁,..., Xn ∼ F. Then, for any ϵ > 0,

(7.2)

From the DKW inequality, we can construct a confidence set as follows:

A Nonparametric 1 − α Confidence Band for F

Define,

It follows from (7.2) that for any F,

(7.3)

7.6 Example. The dashed lines in Figure 7.1 give a 95 percent confidence band using ■

7.2 Statistical Functionals

A statistical functional T(F) is any function of F. Examples are the mean μ = ∫ x dF(x), the variance σ² = ∫(x − μ)² dF(x) and the median m = F⁻¹(1/2).

7.7 Definition. The plug-in estimator of θ = T(F) is defined by

In other words, just plug in for the unknown F.

7.8 Definition. If T(F) = ∫ r(x)dF(x) for some function r(x) then T is called a linear functional.

The reason T(F) = ∫ r(x)dF(x) is called a linear functional is because T satisfies

hence T is linear in its arguments. Recall that ∫ r(x)dF(x) is defined to be ∫ r(x)f(x)dx in the continuous case and ∑j r(xj)f(xj) in the discrete. The empirical cdf ) is discrete, putting mass 1/n at each Xi. Hence, if T(F) = ∫ r(x)dF(x) is a linear functional then we have:

7.9 Theorem. The plug-in estimator for linear functional T(F) = ∫ r(x)dF(x) is:

(7.4)

Sometimes we can find the estimated standard error se of by doing some calculations. However, in other cases it is not obvious how to estimate the standard error. In the next chapter, we will discuss a general method for finding . For now, let us just assume that somehow we can find .

In many cases, it turns out that

(7.5)

By equation (6.11), an approximate 1 − α confidence interval for T(F) is then

(7.6)

We will call this the Normal-based interval. For a 95 percent confidence interval, zα/2 = z.05/2 = 1.96 ≈ 2 so the interval is

7.10 Example (The mean). Let μ = T(F) = ∫ x dF(x). The plug-in estimator is . The standard error is . If denotes an estimate of σ, then the estimated standard error is . (In the next example, we shall see how to estimate σ.) A Normal-based confidence interval for μ is . ■

7.11 Example (The Variance). Let . The plug-in estimator is

Another reasonable estimator of σ² is the sample variance

In practice, there is little difference between and and you can use either one. Returning to the last example, we now see that the estimated standard error of the estimate of the mean is . ■

7.12 Example (The Skewness). Let μ and σ² denote the mean and variance of a random variable X. The skewness is defined to be

The skewness measures the lack of symmetry of a distribution. To find the plug-in estimate, first recall that and . The plug-in estimate of κ is

7.13 Example (Correlation). Let Z = (X, Y) and let ρ = T(F) = (X − μX)(Y − μY)/(σxσy) denote the correlation between X and Y, where F(x, y) is bivariate. We can write

where

and

Replace F with in T₁(F),..., T₅(F), and take

We get

which is called the sample correlation. ■

7.14 Example (Quantiles). Let F be strictly increasing with density f. For 0 < p < 1, the pth quantile is defined by T(F) = F⁻¹ (p). The estimate if T(F) is . We have to be a bit careful since is not invertible. To avoid ambiguity we define

We call the pth sample quantile. ■

Only in the first example did we compute a standard error or a confidence interval. How shall we handle the other examples? When we discuss parametric methods, we will develop formulas for standard errors and confidence intervals. But in our nonparametric setting we need something else. In the next chapter, we will introduce the bootstrap for getting standard errors and confidence intervals.

7.15 Example (Plasma Cholesterol). Figure 7.2 shows histograms for plasma cholesterol (in mg/dl) for 371 patients with chest pain (Scott et al. (1978)). The histograms show the percentage of patients in 10 bins. The first histogram is for 51 patients who had no evidence of heart disease while the second histogram is for 320 patients who had narrowing of the arteries. Is the mean cholesterol different in the two groups? Let us regard these data as samples from two distributions F₁ and F₂. Let μ₁ = ∫ xdF₁(x) and μ₂ = ∫ xdF₂(x) denote the means of the two populations. The plug-in estimates are and . Recall that the standard error of the sample mean is

which we estimate by

where

FIGURE 7.2.

Plasma cholesterol for 51 patients with no heart disease and 320 patients with narrowing of the arteries.

For the two groups this yields and . Approximate 95 percent confidence intervals for μ₁ and μ₂ are and .

Now, consider the functional θ = T(F₂ ) − T(F₁) whose plug-in estimate is . The standard error of is

and we estimate this by

An approximate 95 percent confidence interval for θ is . This suggests that cholesterol is higher among those with narrowed arteries. We should not jump to the conclusion (from these data) that cholesterol causes heart disease. The leap from statistical evidence to causation is very subtle and is discussed in Chapter 16. ■

7.3 Bibliographic Remarks

The Glivenko-Cantelli theorem is the tip of the iceberg. The theory of distribution functions is a special case of what are called empirical processes which underlie much of modern statistical theory. Some references on empirical processes are Shorack and Wellner (1986) and van der Vaart and Wellner (1996).

7.4 Exercises

1.

Prove Theorem 7.3.

2.

Let X₁,..., Xn ∼ Bernoulli(p) and let Y₁,..., Ym ∼ Bernoulli(q). Find the plug-in estimator and estimated standard error for p. Find an approximate 90 percent confidence interval for p. Find the plug-in estimator and estimated standard error for p − q. Find an approximate 90 percent confidence interval for p − q.

3.

(Computer Experiment.) Generate 100 observations from a N(0,1) distribution. Compute a 95 percent confidence band for the cdf F (as described in the appendix). Repeat this 1000 times and see how often the confidence band contains the true distribution function. Repeat using data from a Cauchy distribution.

4.

Let X₁,..., Xn ∼ F and let be the empirical distribution function. For a fixed x, use the central limit theorem to find the limiting distribution of .

5.

Let x and y be two distinct points. Find Cov.

6.

Let X₁,..., Xn ∼ F and let be the empirical distribution function. Let a < b be fixed numbers and define θ = T(F) = F(b) − F(a). Let . Find the estimated standard error of . Find an expression for an approximate 1 − α confidence interval for θ.

7.

Data on the magnitudes of earthquakes near Fiji are available on the website for this book. Estimate the cdf F(x). Compute and plot a 95 percent confidence envelope for F (as described in the appendix). Find an approximate 95 percent confidence interval for F(4.9) − F(4.3).

8.

Get the data on eruption times and waiting times between eruptions of the Old Faithful geyser from the website. Estimate the mean waiting time and give a standard error for the estimate. Also, give a 90 percent confidence interval for the mean waiting time. Now estimate the median waiting time. In the next chapter we will see how to get the standard error for the median.

9.

100 people are given a standard antibiotic to treat an infection and another 100 are given a new antibiotic. In the first group, 90 people recover; in the second group, 85 people recover. Let p₁ be the probability of recovery under the standard treatment and let p₂ be the probability of recovery under the new treatment. We are interested in estimating θ = p₁ − p₂. Provide an estimate, standard error, an 80 percent confidence interval, and a 95 percent confidence interval for θ.

10.

In 1975, an experiment was conducted to see if cloud seeding produced rainfall. 26 clouds were seeded with silver nitrate and 26 were not. The decision to seed or not was made at random. Get the data from
http://lib.stat.cmu.edu/DASL/Stories/CloudSeeding.html
Let θ be the difference in the mean precipitation from the two groups. Estimate θ. Estimate the standard error of the estimate and produce a 95 percent confidence interval.

¹

More precisely, converges to 0 almost surely.

8
The Bootstrap

Larry Wasserman1

(1)

Department of Statistics, Carnegie Mellon University, Baker Hall 228A, 15213-3890, Pittsburgh, PA, USA

Larry Wasserman

Email: larry@stat.cmu.edu

The bootstrap is a method for estimating standard errors and computing confidence intervals. Let Tn = g(X₁,..., Xn) be a statistic, that is, Tn is any function of the data. Suppose we want to know , the variance of Tn. We have written to emphasize that the variance usually depends on the unknown distribution function F. For example, if then = σ²/n where σ² = ∫(x − μ)²dF(x) and μ = ∫ xdF(x). Thus the variance of Tn is a function of F. The bootstrap idea has two steps:

Step 1: Estimate with .

Step 2: Approximate using simulation.

For , we have for Step 1 that where . In this case, Step 1 is enough. However, in more complicated cases we cannot write down a simple formula for which is why we need Step 2. Before proceeding, let us discuss the idea of simulation.

8.1 Simulation

Suppose we draw an iid sample Y₁,..., YB from a distribution G. By the law of large numbers,

as B → ∞. So if we draw a large sample from G, we can use the sample mean to approximate . In a simulation, we can make B as large as we like, in which case, the difference between and is negligible. More generally, if h is any function with finite mean then

as B → ∞. In particular,

Hence, we can use the sample variance of the simulated values to approximate .

8.2 Bootstrap Variance Estimation

According to what we just learned, we can approximate by simulation. Now means “the variance of Tn if the distribution of the data is .” How can we simulate from the distribution of Tn when the data are assumed to have distribution ? The answer is to simulate ,..., from and then compute . This constitutes one draw from the distribution of Tn. The idea is illustrated in the following diagram:

How do we simulate ,..., from ? Notice that puts mass 1/n at each data point X₁,..., Xn. Therefore,

drawing an observation from is equivalent to drawing one point at random from the original data set.

Thus, to simulate ,..., it suffices to draw n observations with replacement from X₁,..., Xn. Here is a summary:

Bootstrap Variance Estimation

1.

Draw ,..., .

2.

Compute .

3.

Repeat steps 1 and 2, B times, to get .

4.

Let

(8.1)

8.1 Example. The following pseudocode shows how to use the bootstrap to estimate the standard error of the median.

The following schematic diagram will remind you that we are using two approximations:

8.2 Example. Consider the nerve data. Let θ = T(F) = ∫(x − μ)³dF(x)/σ³ be the skewness. The skewness is a measure of asymmetry. A Normal distribution, for example, has skewness 0. The plug-in estimate of the skewness is

To estimate the standard error with the bootstrap we follow the same steps as with the median example except we compute the skewness from each bootstrap sample. When applied to the nerve data, the bootstrap, based on B = 1,000 replications, yields a standard error for the estimated skewness of .16. ■

8.3 Bootstrap Confidence Intervals

There are several ways to construct bootstrap confidence intervals. Here we discuss three methods.

Method 1: The Normal Interval. The simplest method is the Normal interval

(8.2)

where is the bootstrap estimate of the standard error. This interval is not accurate unless the distribution of Tn is close to Normal.

Method 2: Pivotal Intervals. Let θ = T(F) and and define the pivot . Let denote bootstrap replications of . Let H(r) denote the cdf of the pivot:

(8.3)

Define where

(8.4)

It follows that

Hence, is an exact 1 − α confidence interval for θ. Unfortunately, a and b depend on the unknown distribution H but we can form a bootstrap estimate of H:

(8.5)

where . Let denote the β sample quantile of and let denote the β sample quantile of . Note that . It follows that an approximate 1 − α confidence interval is where

In summary, the 1 − α bootstrap pivotal confidence interval is

(8.6)

8.3 Theorem. Under weak conditions on T(F),

as n → ∞, where Cn is given in (8.6).

Method 3: Percentile Intervals. The bootstrap percentile interval is defined by

The justification for this interval is given in the appendix.

8.4 Example. For estimating the skewness of the nerve data, here are the various confidence intervals.

Method

95 % Interval

Normal

(1.44, 2.09)

Pivotal

(1.48, 2.11)

Percentile

(1.42, 2.03)

All these confidence intervals are approximate. The probability that T(F) is in the interval is not exactly 1 − α. All three intervals have the same level of accuracy. There are more accurate bootstrap confidence intervals but they are more complicated and we will not discuss them here.

8.5 Example (The Plasma Cholesterol Data). Let us return to the cholesterol data. Suppose we are interested in the difference of the medians. Pseudocode for the bootstrap analysis is as follows:

The point estimate is 18.5, the bootstrap standard error is 7.42 and the resulting approximate 95 percent confidence intervals are as follows:

Method

95 % Interval

Normal

(3.7, 33.3)

Pivotal

(5.0, 34.0)

Percentile

(5.0, 33.3)

Since these intervals exclude 0, it appears that the second group has higher cholesterol although there is considerable uncertainty about how much higher as reflected in the width of the intervals. ■

The next two examples are based on small sample sizes. In practice, statistical methods based on very small sample sizes might not be reliable. We include the examples for their pedagogical value but we do want to sound a note of caution about interpreting the results with some skepticism.

8.6 Example. Here is an example that was one of the first used to illustrate the bootstrap by Bradley Efron, the inventor of the bootstrap. The data are LSAT scores (for entrance to law school) and GPA.

Each data point is of the form Xi = (Yi, Zi) where Yi = LSATi and Zi = GPAi. The law school is interested in the correlation

The plug-in estimate is the sample correlation

The estimated correlation is . The bootstrap based on B = 1000 gives . Figure 8.1 shows the data and a histogram of the bootstrap replications ,..., . This histogram is an approximation to the sampling distribution of . The Normal-based 95 percent confidence interval is .78 ± while the percentile interval is (.46,.96). In large samples, the two methods will show closer agreement. ■

FIGURE 8.1.

Law school data. The top panel shows the raw data. The bottom panel is a histogram of the correlations computed from each bootstrap sample.

8.7 Example. This example is from Efron and Tibshirani (1993). When drug companies introduce new medications, they are sometimes required to show bioequivalence. This means that the new drug is not substantially different than the current treatment. Here are data on eight subjects who used medical patches to infuse a hormone into the blood. Each subject received three treatments: placebo, old-patch, new-patch.

Let Z = old − placebo and Y = new − old. The Food and Drug Administration (FDA) requirement for bioequivalence is that |θ| ≤ .20 where

The plug-in estimate of θ is

The bootstrap standard error is . To answer the bioequivalence question, we compute a confidence interval. From B = 1000 bootstrap replications we get the 95 percent interval (-0.24,0.15). This is not quite contained in (-0.20,0.20) so at the 95 percent level we have not demonstrated bioequivalence. Figure 8.2 shows the histogram of the bootstrap values.

FIGURE 8.2.

Patch data.

8.4 Bibliographic Remarks

The bootstrap was invented by Efron (1979). There are several books on these topics including Efron and Tibshirani (1993), Davison and Hinkley (1997), Hall (1992) and Shao and Tu (1995). Also, see section 3.6 of van der Vaart and Wellner (1996).

8.5 Appendix

8.5.1 The Jackknife

There is another method for computing standard errors called the jackknife, due to Quenouille (1949). It is less computationally expensive than the bootstrap but is less general. Let Tn = T(X₁,..., Xn) be a statistic and T(−i) denote the statistic with the ith observation removed. Let . The jackknife estimate of var(Tn) is

and the jackknife estimate of the standard error is . Under suitable conditions on T, it can be shown that vjack consistently estimates var(Tn) in the sense that . However, unlike the bootstrap, the jackknife does not produce consistent estimates of the standard error of sample quantiles.

8.5.2 Justification For The Percentile Interval

Suppose there exists a monotone transformation U = m(T) such that U ∼ N(ϕ, c²) where ϕ = m(θ). We do not suppose we know the transformation, only that one exists. Let . Let be the β sample quantile of the . Since a monotone transformation preserves quantiles, we have that . Also, since U ∼ N(ϕ, c²), the α/2 quantile of U is ϕ − zα/2c. Hence . Similarly, . Therefore,

An exact normalizing transformation will rarely exist but there may exist approximate normalizing transformations.

8.6 Exercises

1.

Consider the data in Example 8.6. Find the plug-in estimate of the correlation coefficient. Estimate the standard error using the bootstrap. Find a 95 percent confidence interval using the Normal, pivotal, and percentile methods.

2.

(Computer Experiment.) Conduct a simulation to compare the various bootstrap confidence interval methods. Let n = 50 and let T(F) = ∫(x − μ)³dF(x)/σ³ be the skewness. Draw Y₁,..., Yn ∼ N(0, 1) and set Xi = eYi, i = 1,..., n. Construct the three types of bootstrap 95 percent intervals for T(F) from the data X₁,..., Xn. Repeat this whole thing many times and estimate the true coverage of the three intervals.

3.

Let

where n = 25. Let θ = T(F) = (q.75 − q.25)/1.34 where qp denotes the pth quantile. Do a simulation to compare the coverage and length of the following confidence intervals for θ: (i) Normal interval with standard error from the bootstrap, (ii) bootstrap percentile interval, and (iii) pivotal bootstrap interval.

4.

Let X₁,..., Xn be distinct observations (no ties). Show that there are

distinct bootstrap samples.
Hint: Imagine putting n balls into n buckets.

5.

Let X₁,..., Xn be distinct observations (no ties). Let ,..., denote a bootstrap sample and let . Find: , and .

6.

(Computer Experiment.) Let X₁,..., Xn Normal (μ, 1). Let θ = eμ and let . Create a data set (using μ = 5) consisting of n=100 observations.

(a)

Use the bootstrap to get the se and 95 percent confidence interval for θ.

(b)

Plot a histogram of the bootstrap replications. This is an estimate of the distribution of Compare this to the true sampling distribution of

7.

Let X₁,..., Xn ∼ Uniform (0, θ). Let . Generate a data set of size 50 with θ = 1.

(a)

Find the distribution of . Compare the true distribution of to the histograms from the bootstrap.

(b)

This is a case where the bootstrap does very poorly. In fact, we can prove that this is the case. Show that and yet . Hint: show that, then take the limit as n gets large.

8.

Let , αk = ∫ |x − μ|kdF(x) and . Show that

9
Parametric Inference

Larry Wasserman1

(1)

Department of Statistics, Carnegie Mellon University, Baker Hall 228A, 15213-3890, Pittsburgh, PA, USA

Larry Wasserman

Email: larry@stat.cmu.edu

We now turn our attention to parametric models, that is, models of the form

(9.1)

where the Θ ⊂ ℝk is the parameter space and θ = (θ₁,..., θk) is the parameter. The problem of inference then reduces to the problem of estimating the parameter θ.

Students learning statistics often ask: how would we ever know that the distribution that generated the data is in some parametric model? This is an excellent question. Indeed, we would rarely have such knowledge which is why nonparametric methods are preferable. Still, studying methods for parametric models is useful for two reasons. First, there are some cases where background knowledge suggests that a parametric model provides a reasonable approximation. For example, counts of traffic accidents are known from prior experience to follow approximately a Poisson model. Second, the inferential concepts for parametric models provide background for understanding certain nonparametric methods.

We begin with a brief discussion about parameters of interest and nuisance parameters in the next section, then we will discuss two methods for estimating θ, the method of moments and the method of maximum likelihood.

9.1 Parameter of Interest

Often, we are only interested in some function T(θ). For example, if X ∼ N(μ, σ²) then the parameter is θ = (μ, σ). If our goal is to estimate μ then μ = T(θ) is called the parameter of interest and σ is called a nuisance parameter. The parameter of interest might be a complicated function of θ as in the following example.

9.1 Example. Let X₁,..., Xn ∼ Normal(μ, σ²). The parameter is θ = (μ, σ) and the parameter space is Θ = {(μ, σ) : μ ∈ ℝ, σ > 0}. Suppose that Xi is the outcome of a blood test and suppose we are interested in τ, the fraction of the population whose test score is larger than 1. Let Z denote a standard Normal random variable. Then

The parameter of interest is τ = T(μ, σ) = 1 − Φ((1 − μ)/σ). ■

9.2 Example. Recall that X has a Gamma(α, β) distribution if

where α, β > 0 and

is the Gamma function. The parameter is θ = (α, β). The Gamma distribution is sometimes used to model lifetimes of people, animals, and electronic equipment. Suppose we want to estimate the mean lifetime. Then . ■

9.2 The Method of Moments

The first method for generating parametric estimators that we will study is called the method of moments. We will see that these estimators are not optimal but they are often easy to compute. They are are also useful as starting values for other methods that require iterative numerical routines.

Suppose that the parameter θ = (θ₁,..., θk) has k components. For 1 ≤ j ≤ k, define the jth moment

(9.2)

and the jth sample moment

(9.3)

9.3 Definition. The method of moments estimator is defined to be the value of θ such that

(9.4)

Formula (9.4) defines a system of k equations with k unknowns.

9.4 Example. Let X₁,..., Xn ∼ Bernoulli(p). Then and . By equating these we get the estimator

9.5 Example. Let X₁,..., Xn ∼ Normal(μ, σ²). Then, and . We need to solve the equations¹

This is a system of 2 equations with 2 unknowns. The solution is

9.6 Theorem. Let denote the method of moments estimator. Under appropriate conditions on the model, the following statements hold:

1.

The estimate exists with probability tending to 1.

2.

The estimate is consistent: .

3.

The estimate is asymptotically Normal:

where

The last statement in the theorem above can be used to find standard errors and confidence intervals. However, there is an easier way: the bootstrap. We defer discussion of this until the end of the chapter.

9.3 Maximum Likelihood

The most common method for estimating parameters in a parametric model is the maximum likelihood method. Let X₁,..., Xn be iid with pdf f(x; θ).

9.7 Definition. The likelihood function is defined by

(9.5)

The log-likelihood function is defined by .

The likelihood function is just the joint density of the data, except that we treat it is a function of the parameter θ. Thus, . The likelihood function is not a density function: in general, it is not true that integrates to 1 (with respect to θ).

9.8 Definition. The maximum likelihood estimator mle, denoted by , is the value of θ that maximizes .

The maximum of ℓn(θ) occurs at the same place as the maximum of , so maximizing the log-likelihood leads to the same answer as maximizing the likelihood. Often, it is easier to work with the log-likelihood.

9.9 Remark. If we multiply by any positive constant c (not depending on θ) then this will not change the mle. Hence, we shall often drop constants in the likelihood function.

9.10 Example. Suppose that X₁,..., Xn ∼ Bernoulli(p). The probability function is f(x; p) = px (1 − p)1−x for x = 0, 1. The unknown parameter is p. Then,

where S = ∑i Xi. Hence,

Take the derivative of ℓn(p), set it equal to 0 to find that the mle is . See Figure 9.1. ■

FIGURE 9.1.

Likelihood function for Bernoulli with n = 20 and . The mle is .

9.11 Example. Let X₁,..., Xn ∼ N(μ, σ²). The parameter is θ = (μ, σ) and the likelihood function (ignoring some constants) is:

where is the sample mean and . The last equality above follows from the fact that which can be verified by writing and then expanding the square. The log-likelihood is

Solving the equations

we conclude that and . It can be verified that these are indeed global maxima of the likelihood. ■

9.12 Example (A Hard Example). Here is an example that many people find confusing. Let X₁,..., Xn ∼ Uni f(0, θ). Recall that

Consider a fixed value of θ. Suppose θ < Xi for some i. Then, f(Xi; θ) = 0 and hence . It follows that if any Xi > θ. Therefore, if θ < X(n) where X(n) = max{X₁,..., Xn}. Now consider any θ ≥ X(n). For every Xi we then have that f(Xi; θ) = 1/θ so that . In conclusion,

See Figure 9.2. Now is strictly decreasing over the interval [X(n), ∞). Hence, . ■

FIGURE 9.2.

Likelihood function for Uniform (0, θ). The vertical lines show the observed data. The first three plots show f(x; θ) for three different values of θ. When θ < X(n) = max{X₁,..., Xn}, as in the first plot, f(X(n); θ) = 0 and hence . Otherwise f(Xi; θ) = 1/θ for each i and hence . The last plot shows the likelihood function.

The maximum likelihood estimators for the multivariate Normal and the multinomial can be found in Theorems 14.5 and 14.3.

9.4 Properties of Maximum Likelihood Estimators

Under certain conditions on the model, the maximum likelihood estimator possesses many properties that make it an appealing choice of estimator. The main properties of the mle are:

1.

The mle is consistent: where θ★ denotes the true value of the parameter θ;

2.

The mle is equivariant: if is the mle of θ then is the mle of g(θ);

3.

The mle is asymptotically Normal: ; also, the estimated standard error can often be computed analytically;

4.

The mle is asymptotically optimal or efficient: roughly, this means that among all well-behaved estimators, the mle has the smallest variance, at least for large samples;

5.

The mle is approximately the Bayes estimator. (This point will be explained later.)

We will spend some time explaining what these properties mean and why they are good things. In sufficiently complicated problems, these properties will no longer hold and the mle will no longer be a good estimator. For now we focus on the simpler situations where the mle works well. The properties we discuss only hold if the model satisfies certain regularity conditions. These are essentially smoothness conditions on f(x; θ). Unless otherwise stated, we shall tacitly assume that these conditions hold.

9.5 Consistency of Maximum Likelihood Estimators

Consistency means that the mle converges in probability to the true value. To proceed, we need a definition. If f and g are pdf’s, define the Kullback-Leibler distance ² between f and g to be

(9.6)

It can be shown that D(f, g) ≥ 0 and D(f, f) = 0. For any θ, ψ ∈ Θ write D(θ, ψ) to mean D(f(x; θ), f(x; ψ)).

We will say that the model is identifiable if θ ≠ ψ implies that D(θ, ψ) > 0. This means that different values of the parameter correspond to different distributions. We will assume from now on the the model is identifiable.

Let θ★ denote the true value of θ. Maximizing ℓn(θ) is equivalent to maximizing

This follows since Mn(θ) = n⁻¹(ℓn(θ) − ℓn(θ★)) and ℓn(θ★) is a constant (with respect to θ). By the law of large numbers, Mn(θ) converges to

Hence, Mn(θ) ≈ −D(θ★, θ) which is maximized at θ★ since −D(θ★, θ★) = 0 and −D(θ★, θ) < 0 for θ ≠ θ★. Therefore, we expect that the maximizer will tend to θ★. To prove this formally, we need more than . We need this convergence to be uniform over θ. We also have to make sure that the function D(θ★, θ) is well behaved. Here are the formal details.

9.13 Theorem. Let θ★ denote the true value of θ. Define

and M(θ) = −D(θ★,θ). Suppose that

(9.7)

and that, for every ϵ > 0,

(9.8)

Let denote the mle. Then .

The proof is in the appendix.

9.6 Equivariance of the mle

9.14 Theorem. Let τ = g(θ) be a function of θ. Let be the mle of θ. Then is the mle of τ.

Proof. Let h = g⁻¹ denote the inverse of g. Then . For any τ, where θ = h(τ). Hence, for any τ, . ■

9.15 Example. Let X₁,..., Xn ∼ N(θ, 1). The mle for θ is . Let τ = eθ. Then, the mle for τ is . ■

9.7 Asymptotic Normality

It turns out that the distribution of is approximately Normal and we can compute its approximate variance analytically. To explore this, we first need a few definitions.

9.16 Definition. The score function is defined to be

(9.9)

The Fisher information is defined to be

(9.10)

For n = 1 we will sometimes write I(θ) instead of I₁(θ). It can be shown that . It then follows that . In fact, a further simplification of In(θ) is given in the next result.

9.17 Theorem. In(θ) = nI(θ). Also,

(9.11)

9.18 Theorem (Asymptotic Normality of the mle). Let . Under appropriate regularity conditions, the following hold:

1.

and

(9.12)

2.

Let . Then,

(9.13)

The proof is in the appendix. The first statement says that where the approximate standard error of is . The second statement says that this is still true even if we replace the standard error by its estimated standard error .

Informally, the theorem says that the distribution of the mle can be approximated with . From this fact we can construct an (asymptotic) confidence interval.

9.19 Theorem. Let

Then, ℙθ(θ ∈ Cn) → 1 − α as n → ∞.

Proof. Let Z denote a standard normal random variable. Then,

For α = .05, zα/2 = 1.96 ≈ 2, so:

(9.14)

is an approximate 95 percent confidence interval.

When you read an opinion poll in the newspaper, you often see a statement like: the poll is accurate to within one point, 95 percent of the time. They are simply giving a 95 percent confidence interval of the form .

9.20 Example. Let X₁,..., Xn ∼ Bernoulli(p). The mle is and f(x; p) = px (1 − p)1−x, log f(x; p) = x log p + (1 − x)log(1 − p),

and

Thus,

Hence,

An approximate 95 percent confidence interval is

9.21 Example. Let X₁,..., Xn ∼ N(θ, σ²) where σ² is known. The score function is s(X; θ) = (X − θ)/σ² and s′(X; θ) = −1/σ² so that I₁(θ) = 1/σ². The mle is . According to Theorem 9.18, . In this case, the Normal approximation is actually exact. ■

9.22 Example. Let X₁,..., Xn ∼ Poisson( λ). Then and some calculations show that I₁( λ) = 1/ λ, so

Therefore, an approximate 1 − α confidence interval for λ is . ■

9.8 Optimality

Suppose that X₁,..., Xn ∼ N(θ, σ²). The mle is . Another reasonable estimator of θ is the sample median . The mle satisfies

It can be proved that the median satisfies

This means that the median converges to the right value but has a larger variance than the mle.

More generally, consider two estimators Tn and Un and suppose that

and that

We define the asymptotic relative efficiency of U to T by are(U, T) = t²/u². In the Normal example, . The interpretation is that if you use the median, you are effectively using only a fraction of the data.

9.23 Theorem. If is the mle and is any other estimator then ³

Thus, the mle has the smallest (asymptotic) variance and we say that the mle is efficient or asymptotically optimal.

This result is predicated upon the assumed model being correct. If the model is wrong, the mle may no longer be optimal. We will discuss optimality in more generality when we discuss decision theory in Chapter 12.

9.9 The Delta Method

Let τ = g(θ) where g is a smooth function. The maximum likelihood estimator of τ is . Now we address the following question: what is the distribution of ?

9.24 Theorem (The Delta Method). If τ = g(θ) where g is differentiable and g′(θ) ≠ 0 then

(9.15)

where and

(9.16)

Hence, if

(9.17)

then ℙθ(τ ∈ Cn) → 1 − α as n → ∞.

9.25 Example. Let X₁,..., Xn ∼ Bernoulli(p) and let ψ = g(p) = log(p/(1 − p)). The Fisher information function is I(p) = 1/(p(1 − p)) so the estimated standard error of the mle is

The mle of ψ is . Since, g′(p) = 1/(p(1 − p)), according to the delta method

An approximate 95 percent confidence interval is

9.26 Example. Let X₁,..., Xn ∼ N(μ, σ²). Suppose that μ is known, σ is unknown and that we want to estimate ψ = log σ. The log-likelihood is ℓ(σ) = . Differentiate and set equal to 0 and conclude that

To get the standard error we need the Fisher information. First,

with second derivative

and hence

Therefore, . Let ψ = g(σ) = log σ. Then, . Since g′ = 1/σ,

and an approximate 95 percent confidence interval is . ■

9.10 Multiparameter Models

These ideas can directly be extended to models with several parameters. Let θ = (θ₁,..., θk) and let be the mle. Let ,

Define the Fisher Information Matrix by

(9.18)

Let be the inverse of In.

9.27 Theorem. Under appropriate regularity conditions,

Also, if is the jth component of then

(9.19)

where is the jth diagonal element of Jn. The approximate covariance of and is .

There is also a multiparameter delta method. Let τ = g(θ₁,..., θk) be a function and let

be the gradient of g.

9.28 Theorem (Multiparameter delta method). Suppose that ∇g evaluated at is not 0. Let . Then

where

(9.20)

and is ∇g evaluated at .

9.29 Example. Let X₁,..., Xn ∼ N(μ, σ²). Let τ = g(μ, σ) = σ/μ. In Excercise 8 you will show that

Hence,

The gradient of g is

Thus,

9.11 The Parametric Bootstrap

For parametric models, standard errors and confidence intervals may also be estimated using the bootstrap. There is only one change. In the nonparametric bootstrap, we sampled from the empirical distribution . In the parametric bootstrap we sample instead from . Here, could be the mle or the method of moments estimator.

9.30 Example. Consider example 9.29. To get the bootstrap standard error, simulate , compute and . Then compute . Repeating this B times yields bootstrap replications

and the estimated standard error is

The bootstrap is much easier than the delta method. On the other hand, the delta method has the advantage that it gives a closed form expression for the standard error.

9.12 Checking Assumptions

If we assume the data come from a parametric model, then it is a good idea to check that assumption. One possibility is to check the assumptions informally by inspecting plots of the data. For example, if a histogram of the data looks very bimodal, then the assumption of Normality might be questionable. A formal way to test a parametric model is to use a goodness-of-fit test. See Section 10.8.

9.13 Appendix

9.13.1 Proofs

Proof of Theorem 9.13. Since maximizes Mn (θ), we have . Hence,

where the last line follows from (9.7). It follows that, for any δ > 0,

Pick any ϵ > 0. By (9.8), there exists δ > 0 such that |θ − θ★| ≥ ϵ implies that M(θ) < M(θ★) − δ. Hence,

Next we want to prove Theorem 9.18. First we need a lemma.

9.31 Lemma. The score function satisfies

Proof. Note that 1 = ∫ f(x; θ)dx. Differentiate both sides of this equation to conclude that

Proof of Theorem 9.18. Let ℓ(θ) = log (θ). Then,

Rearrange the above equation to get or, in other words,

Let Yi = ∂ log f(Xi; θ)/∂θ. Recall that from the previous lemma and also . Hence,

by the central limit theorem. Let Ai = −∂² log f(Xi; θ)/∂θ². Then I(θ) and

by the law of large numbers. Apply Theorem 5.5 part (e), to conclude that

Assuming that I(θ) is a continuous function of θ, it follows that . Now

The first term tends in distribution to N(0,1). The second term tends in probability to 1. The result follows from Theorem 5.5 part (e). ■

Outline of Proof of Theorem 9.24. Write

Thus,

and hence

Theorem 9.18 tells us that the right-hand side tends in distribution to a N(0,1). Hence,

or, in other words,

where

The result remains true if we substitute for θ by Theorem 5.5 part (e). ■

9.13.2 Sufficiency

A statistic is a function T(Xn) of the data. A sufficient statistic is a statistic that contains all the information in the data. To make this more formal, we need some definitions.

9.32 Definition. Write xn ↔ yn if f(xn; θ) = c f(yn; θ) for some constant c that might depend on xn and yn but not θ. A statistic T(xn) is sufficient if T(xn) ↔ T(yn) implies that xn ↔ yn.

Notice that if xn ↔ yn, then the likelihood function based on xn has the same shape as the likelihood function based on yn. Roughly speaking, a statistic is sufficient if we can calculate the likelihood function knowing only T(Xn).

9.33 Example. Let X₁,..., Xn ∼ Bernoulli(p). Then (p) = pS (1 − p)n−S where S = ∑i Xi, so S is sufficient. ■

9.34 Example. Let X₁,..., Xn ∼ N(μ, σ) and let . Then

where S² is the sample variance. The last expression depends on the data only through T and therefore, is a sufficient statistic. Note that is also a sufficient statistic. If I tell you the value of U then you can easily figure out T and then compute the likelihood. Sufficient statistics are far from unique. Consider the following statistics for the N(μ, σ²) model:

The first statistic is just the whole data set. This is sufficient. The second is also sufficient as we proved above. The third is not sufficient: you can’t compute (μ, σ) if I only tell you . The fourth statistic T₄ is sufficient. The statistics T₁ and T₄ are sufficient but they contain redundant information. Intuitively, there is a sense in which T₂ is a “more concise” sufficient statistic than either T₁ or T₄. We can express this formally by noting that T₂ is a function of T₁ and similarly, T₂ is a function of T₄. For example, T₂ = g(T₄) where g(a₁, a₂, a₃) = (a₁, a₂). ■

9.35 Definition. A statistic T is minimal sufficient if (i) it is sufficient; and (ii) it is a function of every other sufficient statistic.

9.36 Theorem. T is minimal sufficient if the following is true:

A statistic induces a partition on the set of outcomes. We can think of sufficiency in terms of these partitions.

9.37 Example. Let X₁, X₂ ∼ Bernoulli(θ). Let V = X₁, T = ∑i Xi and U = (T, X₁). Here is the set of outcomes and the statistics:

The partitions induced by these statistics are:

Then V is not sufficient but T and U are sufficient. T is minimal sufficient; U is not minimal since if xn = (1, 0) and yn = (0, 1), then xn ↔ yn yet U(xn) ≠ U(yn). The statistic W = 17T generates the same partition as T. It is also minimal sufficient. ■

9.38 Example. For a N(μ, σ²) model, is a minimal sufficient statistic. For the Bernoulli model, T =∑i Xi is a minimal sufficient statistic. For the Poisson model, T = ∑i Xi is a minimal sufficient statistic. Check that T = (∑i Xi, X₁) is sufficient but not minimal sufficient. Check that T = X₁ is not sufficient. ■

I did not give the usual definition of sufficiency. The usual definition is this: T is sufficient if the distribution of Xn given T(xn) = t does not depend on θ. In other words, T is sufficient if f(x₁,..., xn | t; θ) = h(x₁,..., xn, t) where h is some function that does not depend on θ.

9.39 Example. Two coin flips. Let X = (X₁, X₂) ∼ Bernoulli(p). Then T = X₁ + X₂ is sufficient. To see this, we need the distribution of (X₁, X₂) given T = t. Since T can take 3 possible values, there are 3 conditional distributions to check. They are: (i) the distribution of (X₁, X₂) given T = 0:

(ii) the distribution of (X₁, X₂) given T = 1:

(iii) the distribution of (X₁, X₂) given T = 2:

None of these depend on the parameter p. Thus, the distribution of X₁, X₂|T does not depend on θ, so T is sufficient. ■

9.40 Theorem (Factorization Theorem). T is sufficient if and only if there are functions g(t, θ) and h(x) such that f(xn; θ) = g(t(xn), θ)h(xn).

9.41 Example. Return to the two coin flips. Let t = x₁ + x₂. Then

where g(t, θ) = θt (1 − θ)2−t and h(x₁, x₂) = 1. Therefore, T = X₁ + X₂ is sufficient. ■

Now we discuss an implication of sufficiency in point estimation. Let be an estimator of θ. The Rao-Blackwell theorem says that an estimator should only depend on the sufficient statistic, otherwise it can be improved. Let denote the mse of the estimator.

9.42 Theorem (Rao-Blackwell). Let be an estimator and let T be a sufficient statistic. Define a new estimator by

Then, for every θ, .

9.43 Example. Consider flipping a coin twice. Let . This is a well-defined (and unbiased) estimator. But it is not a function of the sufficient statistic T = X₁ + X₂. However, note that . By the Rao-Blackwell Theorem, has mse at least as small as . The same applies with n coin flips. Again define and T = ∑i Xi. Then has improved mse. ■

9.13.3 Exponential Families

Most of the parametric models we have studied so far are special cases of a general class of models called exponential families. We say that {f(x; θ): θ ∈ Θ} is a one-parameter exponential family if there are functions η(θ), B(θ), T(x) and h(x) such that

It is easy to see that T(X) is sufficient. We call T the natural sufficient statistic.

9.44 Example. Let X ∼ Poisson(θ). Then

and hence, this is an exponential family with η(θ) = log θ, B(θ) = θ, T(x) = x, h(x) = 1/x!. ■

9.45 Example. Let X ∼ Binomial(n, θ). Then

In this case,

and

■

We can rewrite an exponential family as

where η = η(θ) is called the natural parameter and

For example a Poisson can be written as where the natural parameter is η = log θ.

Let X₁,..., Xn be iid from an exponential family. Then f(xn; θ) is an exponential family:

where hn (xn) = ∏i h(xi), Tn (xn) = ∑i T(xi) and Bn (θ) = nB(θ). This implies that ∑i T(Xi) is sufficient.

9.46 Example. Let X₁,..., Xn ∼ Uniform(0, θ). Then

where I is 1 if the term inside the brackets is true and 0 otherwise, and x(n) = max{x₁,..., xn}. Thus T(Xn) = max{X₁,..., Xn} is sufficient. But since T(Xn) ≠ ∑i T(Xi), this cannot be an exponential family. ■

9.47 Theorem. Let X have density in an exponential family. Then,

If θ = (θ₁,..., θk) is a vector, then we say that f(x; θ) has exponential family form if

Again, T = (T₁,..., Tk) is sufficient. An iid sample of size n also has exponential form with sufficient statistic (∑i T₁ (Xi),..., ∑i Tk (Xi)).

9.48 Example. Consider the normal family with θ = (μ, σ). Now,

This is exponential with

Hence, with n iid samples, is sufficient. ■

As before we can write an exponential family as

where . It can be shown that

where the first expression is the vector of partial derivatives and the second is the matrix of second derivatives.

9.13.4 Computing Maximum Likelihood Estimates

In some cases we can find the mle analytically. More often, we need to find the mle by numerical methods. We will briefly discuss two commonly used methods: (i) Newton-Raphson, and (ii) the EM algorithm. Both are iterative methods that produce a sequence of values θ⁰, θ¹,... that, under ideal conditions, converge to the mle . In each case, it is helpful to use a good starting value θ⁰. Often, the method of moments estimator is a good starting value.

Newton-Raphson. To motivate Newton-Raphson, let’s expand the derivative of the log-likelihood around θj:

Solving for gives

This suggests the following iterative scheme:

In the multiparameter case, the mle is a vector and the method becomes

where ℓ′ (θj) is the vector of first derivatives and H is the matrix of second derivatives of the log-likelihood.

The EM Algorithm. The letters EM stand for Expectation-Maximization. The idea is to iterate between taking an expectation then maximizing. Suppose we have data Y whose density f(y; θ) leads to a log-likelihood that is hard to maximize. But suppose we can find another random variable Z such that f(y; θ) = ∫ f(y, z; θ) dz and such that the likelihood based on f(y, z; θ) is easy to maximize. In other words, the model of interest is the marginal of a model with a simpler likelihood. In this case, we call Y the observed data and Z the hidden (or latent or missing) data. If we could just “fill in” the missing data, we would have an easy problem. Conceptually, the EM algorithm works by filling in the missing data, maximizing the log-likelihood, and iterating.

9.49 Example (Mixture of Normals). Sometimes it is reasonable to assume that the distribution of the data is a mixture of two normals. Think of heights of people being a mixture of men and women’s heights. Let ϕ(y; μ, σ) denote a normal density with mean μ and standard deviation σ. The density of a mixture of two Normals is

The idea is that an observation is drawn from the first normal with probability p and the second with probability 1−p. However, we don’t know which Normal it was drawn from. The parameters are θ = (μ₀, σ₀, μ₁, σ₁, p). The likelihood function is

Maximizing this function over the five parameters is hard. Imaging that we were given extra information telling us which of the two normals every observation came from. These “complete” data are of the form (Y₁, Z₁),..., (Yn, Zn), where Zi = 0 represents the first normal and Zi = 1 represents the second. Note that ℙ(Zi = 1) = p. We shall soon see that the likelihood for the complete data (Y₁, Z₁),..., (Yn, Zn) is much simpler than the likelihood for the observed data Y₁,..., Yn. ■

Now we describe the EM algorithm.

The EM Algorithm

(0) Pick a starting value θ⁰. Now for j = 1, 2,..., repeat steps 1 and 2 below:

(1) (The E-step): Calculate

The expectation is over the missing data Zn treating θi and the observed data Yn as fixed.

(2) Find θJ+1 to maximize J(θ|θj).

We now show that the EM algorithm always increases the likelihood, that is, (θJ+1) ≥ (θj). Note that

and hence

where fj = f(yn; θj) and fj+1 = f(yn; θJ+1) and K(f, g) = ∫ f(x) log(f(x)/g(x)) dx is the Kullback-Leibler distance. Now, θJ+1 was chosen to maximize J(θ|θj). Hence, J(θJ+1|θj) ≥ J(θj|θj) = 0. Also, by the properties of Kullback-Leibler divergence, K(fj, fj+1) ≥ 0. Hence, (θJ+1) ≥ (θj) as claimed.

9.50 Example (Continuation of Example 9.49). Consider again the mixture of two normals but, for simplicity assume that p = 1/2, σ₁ = σ₂ = 1. The density is

Directly maximizing the likelihood is hard. Introduce latent variables Zi,..., Zn where Zi = 0 if Yi is from ϕ(y; μ₀, 1), and Zi = 1 if Yi is from ϕ(y; μ₁, 1), ℙ(Zi = 1) = P(Zi = 0) = 1/2, f(yi|Zi = 0) = ϕ(y; μ₀, 1) and f(yi|Zi = 1) ϕ(y; μ₁, 1). So where we have dropped the parameters from the density to avoid notational overload. We can write

Hence, the complete likelihood is

The complete log-likelihood is then

And so

Since Zi is binary, and, by Bayes’ theorem,

Take the derivative of J(θ|θj) with respect to μ₁ and μ₂, set them equal to 0 to get

and

We then recompute τi using and and iterate. ■

9.14 Exercises

1.

Let X₁,..., Xn ∼ Gamma(α, β). Find the method of moments estimator for α and β.

2.

Let X₁,..., Xn Uniform(a, b) where a and b are unknown parameters and a < b.

(a)

Find the method of moments estimators for a and b.

(b)

Find the mle and .

(c)

Let τ = ∫ x dF(x). Find the mle of τ.

(d)

Let be the mle of τ. Let be the nonparametric plug-in estimator of τ = ∫ x dF(x). Suppose that a = 1, b = 3, and n = 10. Find the mse of by simulation. Find the mse of analytically. Compare.

3.

Let X₁,..., Xn ∼ N(μ, σ²). Let τ be the .95 percentile, i.e. ℙ(X < τ) = .95.

(a)

Find the mle of τ.

(b)

Find an expression for an approximate 1 − α confidence interval for τ.

(c)

Suppose the data are:

Find the mle . Find the standard error using the delta method. Find the standard error using the parametric bootstrap.

4.

Let X₁,..., Xn ~ Uniform(0, θ). Show that the mle is consistent. Hint: Let Y = max{X₁,..., Xn}. For any c, ℙ(Y < c) = ℙ(X₁ < c, X₂ < C,..., Xn < c) = ℙ(X₁ < c)ℙ(X₂ < c)...ℙ(Xn < c).

5.

Let X₁,..., Xn ∼ Poisson( λ). Find the method of moments estimator, the maximum likelihood estimator and the Fisher information I( λ).

6.

Let X₁,..., Xn ∼ N(θ, 1). Define

Let ψ = ℙ(Y₁ = 1).

(a)

Find the maximum likelihood estimator of ψ.

(b)

Find an approximate 95 percent confidence interval for ψ.

(c)

Define . Show that is a consistent estimator of ψ.

(d)

Compute the asymptotic relative efficiency of to . Hint: Use the delta method to get the standard error of the mle. Then compute the standard error (i.e. the standard deviation) of .

(e)

Suppose that the data are not really normal. Show that is not consistent. What, if anything, does converge to?

7.

(Comparing two treatments.) n₁ people are given treatment 1 and n₂ people are given treatment 2. Let X₁ be the number of people on treatment 1 who respond favorably to the treatment and let X₂ be the number of people on treatment 2 who respond favorably. Assume that X₁ ∼ Binomial(n₁, p₁) X₂ ∼ Binomial(n₂, p₂). Let ψ = p₁ − p₂.

(a)

Find the mle for ψ.

(b)

Find the Fisher information matrix I(p₁, p₂).

(c)

Use the multiparameter delta method to find the asymptotic standard error of .

(d)

Suppose that n₁ = n₂ = 200, X₁ = 160 and X₂ = 148. Find . Find an approximate 90 percent confidence interval for ψ using (i) the delta method and (ii) the parametric bootstrap.

8.

Find the Fisher information matrix for Example 9.29.

9.

Let X₁,..., Xn ∼ Normal(μ, 1). Let θ = eμ and let be the mle. Create a data set (using μ = 5) consisting of n=100 observations.

(a)

Use the delta method to get and a 95 percent confidence interval for θ. Use the parametric bootstrap to get and 95 percent confidence interval for θ. Use the nonparametric bootstrap to get and 95 percent confidence interval for θ. Compare your answers.

(b)

Plot a histogram of the bootstrap replications for the parametric and nonparametric bootstraps. These are estimates of the distribution of . The delta method also gives an approximation to this distribution namely, Normal. Compare these to the true sampling distribution of (which you can get by simulation). Which approximation — parametric bootstrap, bootstrap, or delta method — is closer to the true distribution?

10.

Let X₁,..., Xn Uniform(0, θ). The mle is . Generate a dataset of size 50 with θ = 1.

(a)

Find the distribution of analytically. Compare the true distribution of to the histograms from the parametric and nonparametric bootstraps.

(b)

This is a case where the nonparametric bootstrap does very poorly. Show that for the parametric bootstrap , but for the nonparametric bootstrap . Hint: show that, then take the limit as n gets large. What is the implication of this?

¹

Recall that . Hence, .

²

This is not a distance in the formal sense because D(f, g) is not symmetric.

³

The result is actually more subtle than this but the details are too complicated to consider here.

10
Hypothesis Testing and p-values

Larry Wasserman1

(1)

Department of Statistics, Carnegie Mellon University, Baker Hall 228A, 15213-3890, Pittsburgh, PA, USA

Larry Wasserman

Email: larry@stat.cmu.edu

Suppose we want to know if exposure to asbestos is associated with lung disease. We take some rats and randomly divide them into two groups. We expose one group to asbestos and leave the second group unexposed. Then we compare the disease rate in the two groups. Consider the following two hypotheses:

The Null Hypothesis: The disease rate is the same in the two groups.

The Alternative Hypothesis: The disease rate is not the same in the two groups.

If the exposed group has a much higher rate of disease than the unexposed group then we will reject the null hypothesis and conclude that the evidence favors the alternative hypothesis. This is an example of hypothesis testing.

More formally, suppose that we partition the parameter space Θ into two disjoint sets Θ₀ and Θ₁ and that we wish to test

(10.1)

We call H₀ the null hypothesis and H₁ the alternative hypothesis.

Let X be a random variable and let be the range of X. We test a hypothesis by finding an appropriate subset of outcomes R ⊂ called the rejection region. If X ∈ R we reject the null hypothesis, otherwise, we do not reject the null hypothesis:

Usually, the rejection region R is of the form

(10.2)

where T is a test statistic and c is a critical value. The problem in hypothesis testing is to find an appropriate test statistic T and an appropriate critical value c.

Warning! There is a tendency to use hypothesis testing methods even when they are not appropriate. Often, estimation and confidence intervals are better tools. Use hypothesis testing only when you want to test a well-defined hypothesis.

Hypothesis testing is like a legal trial. We assume someone is innocent unless the evidence strongly suggests that he is guilty. Similarly, we retain H₀ unless there is strong evidence to reject H₀. There are two types of errors we can make. Rejecting H₀ when H₀ is true is called a type I error. Retaining H₀ when H₁ is true is called a type II error. The possible outcomes for hypothesis testing are summarized in Tab. 10.1.

TABLE 10.1.

Summary of outcomes of hypothesis testing.

Retain Null

Reject Null

H₀ true

√

type I error

H₁ true

type II error

√

10.1 Definition. The power function of a test with rejection region R is defined by

(10.3)

The size of a test is defined to be

(10.4)

A test is said to have level α if its size is less than or equal to α.

A hypothesis of the form θ = θ₀ is called a simple hypothesis. A hypothesis of the form θ > θ₀ or θ < θ₀ is called a composite hypothesis. A test of the form

is called a two-sided test. A test of the form

or

is called a one-sided test. The most common tests are two-sided.

10.2 Example. Let X₁,..., Xn ∼ N(μ, σ) where σ is known. We want to test H₀ : μ ≤ 0 versus H₁ : μ > 0. Hence, Θ₀ = (−∞, 0] and Θ₁ = (0, ∞). Consider the test:

where . The rejection region is

Let Z denote a standard Normal random variable. The power function is

This function is increasing in μ. See Figure 10.1. Hence

For a size α test, we set this equal to α and solve for c to get

We reject when . Equivalently, we reject when

where zα = Φ⁻¹ (1 − α). ■

FIGURE 10.1.

The power function for Example 10.2. The size of the test is the largest probability of rejecting H₀ when H₀ is true. This occurs at μ = 0 hence the size is β(0). We choose the critical value c so that β(0) = α.

It would be desirable to find the test with highest power under H₁, among all size α tests. Such a test, if it exists, is called most powerful. Finding most powerful tests is hard and, in many cases, most powerful tests don’t even exist. Instead of going into detail about when most powerful tests exist, we, 11 just consider four widely used tests: the Wald test,¹ the χ² test, the permutation test, and the likelihood ratio test.

10.1 The Wald Test

Let θ be a scalar parameter, let be an estimate of θ and let be the estimated standard error of .

10.3 Definition. The Wald Test

Consider testing

Assume that is asymptotically Normal:

The size α Wald test is: reject H₀ when |W| > zα/2 where

(10.5)

10.4 Theorem. Asymptotically, the Wald test has size α, that is,

as n → ∞.

Proof. Under . Hence, the probability of rejecting when the null θ = θ₀ is true is

where Z ∼ N(0, 1). ■

10.5 Remark. An alternative version of the Wald test statistic is W = ( − θ₀)/se₀ where se₀ is the standard error computed at θ = θ₀. Both versions of the test are valid.

Let us consider the power of the Wald test when the null hypothesis is false.

10.6 Theorem. Suppose the true value of θ is θ★ ≠ θ₀. The power β(θ★) — the probability of correctly rejecting the null hypothesis — is given (approximately) by

(10.6)

Recall that tends to 0 as the sample size increases. Inspecting (10.6) closely we note that: (i) the power is large if θ★ is far from θ₀, and (ii) the power is large if the sample size is large.

10.7 Example (Comparing Two Prediction Algorithms). We test a prediction algorithm on a test set of size m and we test a second prediction algorithm on a second test set of size n. Let X be the number of incorrect predictions for algorithm 1 and let Y be the number of incorrect predictions for algorithm 2. Then X ∼ Binomial(m, p₁) and Y ∼ Binomial(n, p₂). To test the null hypothesis that p₁ = p₂ write

where δ = p₁ − p₂. The mle is with estimated standard error

The size α Wald test is to reject H₀ when |W| > zα/2 where

The power of this test will be largest when p₁ is far from p₂ and when the sample sizes are large.

What if we used the same test set to test both algorithms? The two samples are no longer independent. Instead we use the following strategy. Let Xi = 1 if algorithm 1 is correct on test case i and Xi = 0 otherwise. Let Yi = 1 if algorithm 2 is correct on test case i, and Yi = 0 otherwise. Define Di = Xi − Yi A typical dataset will look something like this:

Let

The nonparametric plug-in estimate of δ is and = , where . To test H₀ : δ = 0 versus H₁ : δ ≠ 0 we use and reject H₀ if |W| > zα/2. This is called a paired comparison. ■

10.8 Example (Comparing Two Means). Let X₁,..., Xm and Y₁,..., Yn be two independent samples from populations with means μ₁ and μ₂, respectively. Let’s test the null hypothesis that μ₁ = μ₂. Write this as H₀ : δ = 0 versus H₁ : δ ≠ 0 where δ = μ₁ − μ₂. Recall that the nonparametric plug-in estimate of δ is with estimated standard error

where and are the sample variances. The size α Wald test rejects H₀ when |W| > zα/2 where

10.9 Example (Comparing Two Medians). Consider the previous example again but let us test whether the medians of the two distributions are the same. Thus, H₀ : δ = 0 versus H₁ : δ ≠ 0 where δ = ν₁ − ν₂ where ν₁ and ν₂ are the medians. The nonparametric plug-in estimate of δ is where and are the sample medians. The estimated standard error of can be obtained from the bootstrap. The Wald test statistic is . ■

There is a relationship between the Wald test and the 1 − α asymptotic confidence interval .

10.10 Theorem. The size α Wald test rejects H₀ : θ = θ₀ versus H₁ : θ ≠ θ₀ if and only if θ₀ ∉ C where

Thus, testing the hypothesis is equivalent to checking whether the null value is in the confidence interval.

Warning! When we reject H₀ we often say that the result is statistically significant. A result might be statistically significant and yet the size of the effect might be small. In such a case we have a result that is statistically significant but not scientifically or practically significant. The difference between statistical significance and scientific significance is easy to understand in light of Theorem 10.10. Any confidence interval that excludes θ₀ corresponds to rejecting H₀. But the values in the interval could be close to θ₀ (not scientifically significant) or far from θ₀ (scientifically significant). See Figure 10.2.

FIGURE 10.2.

Scientific significance versus statistical significance. A level α test rejects H₀ : θ = θ₀ if and only if the 1 − α confidence interval does not include θ₀. Here are two different confidence intervals. Both exclude θ₀ so in both cases the test would reject H₀. But in the first case, the estimated value of θ is close to θ₀ so the finding is probably of little scientific or practical value. In the second case, the estimated value of θ is far from θ₀ so the finding is of scientific value. This shows two things. First, statistical significance does not imply that a finding is of scientific importance. Second, confidence intervals are often more informative than tests.

10.2 p-values

Reporting “reject H₀” or “retain H₀” is not very informative. Instead, we could ask, for every α, whether the test rejects at that level. Generally, if the test rejects at level α it will also reject at level α′ > α. Hence, there is a smallest α at which the test rejects and we call this number the p-value. See Figure 10.3.

FIGURE 10.3.

p-values explained. For each α we can ask: does our test reject H₀ at level α? The p-value is the smallest α at which we do reject H₀. If the evidence against H₀ is strong, the p-value will be small.

10.11 Definition. Suppose that for every α ∈ (0, 1) we have a size α test with rejection region Rα. Then,

That is, the p-value is the smallest level at which we can reject H₀.

Informally, the p-value is a measure of the evidence against H₀ : the smaller the p-value, the stronger the evidence against H₀. Typically, researchers use the following evidence scale:

p-value

evidence

< .01

very strong evidence against H₀

.01 – .05

strong evidence against H₀

.05 – .10

weak evidence against H₀

> .1

little or no evidence against H₀

Warning! A large p-value is not strong evidence in favor of H₀. A large p-value can occur for two reasons: (i) H₀ is true or (ii) H₀ is false but the test has low power.

Warning! Do not confuse the p-value with ℙ(H₀|Data). ² The p-value is not the probability that the null hypothesis is true.

The following result explains how to compute the p-value.

10.12 Theorem. Suppose that the size α test is of the form

Then,

where xn is the observed value of Xn. If Θ₀ = {θ₀} then

We can express Theorem 10.12 as follows:

The p-value is the probability (under H₀) of observing a value of the test statistic the same as or more extreme than what was actually observed.

10.13 Theorem. Let denote the observed value of the Wald statistic W. The p-value is given by

(10.7)

where Z ∼ N (0, 1).

To understand this last theorem, look at Figure 10.4.

FIGURE 10.4.

The p-value is the smallest α at which you would reject H₀. To find the p-value for the Wald test, we find α such that |w| and − |w| are just at the boundary of the rejection region. Here, w is the observed value of the Wald statistic: . This implies that the p-value is the tail area ℙ(| Z| > |w|) where Z ∼ N (0, 1).

Here is an important property of p-values.

10.14 Theorem. If the test statistic has a continuous distribution, then under H₀ : θ = θ₀, the p-value has a Uniform (0, 1) distribution. Therefore, if we reject H₀ when the p-value is less than α, the probability of a type I error is α.

In other words, if H₀ is true, the p-value is like a random draw from a Unif(0, 1) distribution. If H₁ is true, the distribution of the p-value will tend to concentrate closer to 0.

10.15 Example. Recall the cholesterol data from Example 7.15. To test if the means are different we compute

To compute the p-value, let Z ∼ N(0, 1) denote a standard Normal random variable. Then,

which is very strong evidence against the null hypothesis. To test if the medians are different, let and denote the sample medians. Then,

where the standard error 7.7 was found using the bootstrap. The p-value is

which is strong evidence against the null hypothesis. ■

10.3 The χ² Distribution

Before proceeding we need to discuss the χ² distribution. Let Z₁,..., Zk be independent, standard Normals. Let . Then we say that V has a χ² distribution with k degrees of freedom, written . The probability density of V is

for υ > 0. It can be shown that and . We define the upper α quantile where F is the cdf. That is, .

10.4 Pearson’s χ² Test For Multinomial Data

Pearson’s χ² test is used for multinomial data. Recall that if X = (X₁,..., Xk) has a multinomial (n, p) distribution, then the mle of p is = (X₁/n,..., X)k/n).

Let p₀ = (p₀₁,..., p0k) be some fixed vector and suppose we want to test

10.16 Definition. Pearson’s χ² statistic is

where is the expected value of Xj under H₀.

10.17 Theorem. Under . Hence the test: reject H₀, if T > has asymptotic level α. The p-value is where t is the observed value of the test statistic.

Theorem 10.17 is illustrated in Figure 10.5.

FIGURE 10.5.

The p-value is the smallest α at which we would reject H₀. To find the p-value for the test, we find α such that the observed value t of the test statistic is just at the boundary of the rejection region. This implies that the p-value is the tail area .

10.18 Example (Mendel’s peas). Mendel bred peas with round yellow seeds and wrinkled green seeds. There are four types of progeny: round yellow, wrinkled yellow, round green, and wrinkled green. The number of each type is multinomial with probability p = (p₁, p₂, p₃, p₄). His theory of inheritance predicts that p is equal to

In n = 556 trials he observed X = (315, 101, 108, 32). We will test H₀ : p = p₀ versus H₁ : p ≠ p₀. Since, np₀₁ = 312.75, np₀₂ = np₀₃ = 104.25, and np₀₄ = 34.75, the test statistic is

The α = .05 value for a is 7.815. Since 0.47 is not larger than 7.815 we do not reject the null. The p-value is

which is not evidence against H₀. Hence, the data do not contradict Mendel’s theory.³■

In the previous example, one could argue that hypothesis testing is not the right tool. Hypothesis testing is useful to see if there is evidence to reject H₀. This is appropriate when H₀ corresponds to the status quo. It is not useful for proving that H₀ is true. Failure to reject H₀ might occur because H₀ is true, but it might occur just because the test has low power. Perhaps a confidence set for the distance between p and p₀ might be more useful in this example.

10.5 The Permutation Test

The permutation test is a nonparametric method for testing whether two distributions are the same. This test is “exact,” meaning that it is not based on large sample theory approximations. Suppose that X₁,..., Xm ∼ FX and Y₁,..., Yn ∼ FY are two independent samples and H₀ is the hypothesis that the two samples are identically distributed. This is the type of hypothesis we would consider when testing whether a treatment differs from a placebo. More precisely we are testing

Let T(x₁,..., xm, y₁,..., yn) be some test statistic, for example,

Let N = m + n and consider forming all N! permutations of the data X₁,..., Xm, Y₁,..., Yn. For each permutation, compute the test statistic T. Denote these values by T₁,..., TN!. Under the null hypothesis, each of these values is equally likely. ⁴ The distribution ℙ₀ that puts mass 1/N! on each Tj is called the permutation distribution of T. Let tobs be the observed value of the test statistic. Assuming we reject when T is large, the p-value is

10.19 Example. Here is a toy example to make the idea clear. Suppose the data are: (X₁, X₂, Y₁) = (1, 9, 3). Let . The permutations are:

permutation

value of T

probability

(1,9,3)

2

1/6

(9,1,3)

2

1/6

(1,3,9)

7

1/6

(3,1,9)

7

1/6

(3,9,1)

5

1/6

(9,3,1)

5

1/6

The p-value is ℙ(T > 2) = 4/6. ■

Usually, it is not practical to evaluate all N! permutations. We can approximate the p-value by sampling randomly from the set of permutations. The fraction of times Tj > tobs among these samples approximates the p-value.

Algorithm for Permutation Test

1.

Compute the observed value of the test statistic

2.

Randomly permute the data. Compute the statistic again using the permuted data.

3.

Repeat the previous step B times and let T₁,..., TB denote the resulting values.

4.

The approximate p-value is

10.20 Example. DNA microarrays allow researchers to measure the expression levels of thousands of genes. The data are the levels of messenger RNA (mRNA) of each gene, which is thought to provide a measure of how much protein that gene produces. Roughly, the larger the number, the more active the gene. The table below, reproduced from Efron et al. (2001) shows the expression levels for genes from ten patients with two types of liver cancer cells. There are 2,638 genes in this experiment but here we show just the first two. The data are log-ratios of the intensity levels of two different color dyes used on the arrays.

Let’s test whether the median level of gene 1 is different between the two groups. Let ν₁ denote the median level of gene 1 of Type I and let ν₂ denote the median level of gene 1 of Type II. The absolute difference of sample medians is . Now we estimate the permutation distribution by simulation and we find that the estimated p-value is .045. Thus, if we use a α = .05 level of significance, we would say that there is evidence to reject the null hypothesis of no difference. ■

In large samples, the permutation test usually gives similar results to a test that is based on large sample theory. The permutation test is thus most useful for small samples.

10.6 The Likelihood Ratio Test

The Wald test is useful for testing a scalar parameter. The likelihood ratio test is more general and can be used for testing a vector-valued parameter.

10.21 Definition. Consider testing

The likelihood ratio statistic is

where is the mle and is the mle when θ is restricted to lie in Θ₀.

You might have expected to see the maximum of the likelihood over instead of Θ in the numerator. In practice, replacing with Θ has little effect on the test statistic. Moreover, the theoretical properties of λ are much simpler if the test statistic is defined this way.

The likelihood ratio test is most useful when Θ₀ consists of all parameter values θ such that some coordinates of θ are fixed at particular values.

10.22 Theorem. Suppose that θ = (θ₁,..., θq, θq+1,..., θr). Let

Let λ be the likelihood ratio test statistic. Under H₀ : θ ∈ Θ₀,

where r − q is the dimension of Θ minus the dimension of Θ₀. The p-value for the test is .

For example, if θ = (θ₁, θ₂, θ₃, θ₄, θ₅) and we want to test the null hypothesis that θ₄ = θ₅ = 0 then the limiting distribution has 5 − 3 = 2 degrees of freedom.

10.23 Example (Mendel’s Peas Revisited). Consider example 10.18 again. The likelihood ratio test statistic for H₀ : p = p₀ versus H₁ : p ≠ p₀ is

Under H₁ there are four parameters. However, the parameters must sum to one so the dimension of the parameter space is three. Under H₀ there are no free parameters so the dimension of the restricted parameter space is zero. The difference of these two dimensions is three. Therefore, the limiting distribution of λ under H₀ is and the p-value is

The conclusion is the same as with the χ² test. ■

When the likelihood ratio test and the χ² test are both applicable, as in the last example, they usually lead to similar results as long as the sample size is large.

10.7 Multiple Testing

In some situations we may conduct many hypothesis tests. In Example 10.20, there were actually 2,638 genes. If we tested for a difference for each gene, we would be conducting 2,638 separate hypothesis tests. Suppose each test is conducted at level α. For any one test, the chance of a false rejection of the null is α. But the chance of at least one false rejection is much higher. This is the multiple testing problem. The problem comes up in many data mining situations where one may end up testing thousands or even millions of hypotheses. There are many ways to deal with this problem. Here we discuss two methods.

Consider m hypothesis tests:

and let P₁,..., Pm denote the m p-values for these tests.

The Bonferroni Method

Given p-values P₁,..., Pm, reject null hypothesis H0i if

10.24 Theorem. Using the Bonferroni method, the probability of falsely rejecting any null hypotheses is less than or equal to α.

Proof. Let R be the event that at least one null hypothesis is falsely rejected. Let Ri be the event that the ith null hypothesis is falsely rejected. Recall that if A₁,..., Ak are events then . Hence,

from Theorem 10.14. ■

10.25 Example. In the gene example, using α = .05, we have that .05/2, 638 = .00001895375. Hence, for any gene with p-value less than .00001895375, we declare that there is a significant difference. ■

The Bonferroni method is very conservative because it is trying to make it unlikely that you would make even one false rejection. Sometimes, a more reasonable idea is to control the false discovery rate (FDR) which is defined as the mean of the number of false rejections divided by the number of rejections.

Suppose we reject all null hypotheses whose p-values fall below some threshold. Let m₀ be the number of null hypotheses that are true and let m₁ = m − m₀. The tests can be categorized in a 2 × 2 as in Table 10.2.

TABLE 10.2.

Types of outcomes in multiple testing.

Define the False Discovery Proportion (FDP)

The FDP is the proportion of rejections that are incorrect. Next define FDR = (FDP).

The Benjamini-Hochberg (BH) Method

1.

Let P₍₁₎ < ⋯ < P(m) denote the ordered p-values.

2.

Define

(10.8)

where Cm is defined to be 1 if the p-values are independent and otherwise.

3.

Let T = P(R); we call T the BH rejection threshold.

4.

Reject all null hypotheses H0i for which Pi ≤ T.

10.26 Theorem (Benjamini and Hochberg). If the procedure above is applied, then regardless of how many nulls are true and regardless of the distribution of the p-values when the null hypothesis is false,

10.27 Example. Figure 10.6 shows six ordered p-values plotted as vertical lines. If we tested at level α without doing any correction for multiple testing, we would reject all hypotheses whose p-values are less than α. In this case, the four hypotheses corresponding to the four smallest p-values are rejected. The Bonferroni method rejects all hypotheses whose p-values are less than α/m. In this case, this leads to no rejections. The BH threshold corresponds to the last p-value that falls under the line with slope α. This leads to two hypotheses being rejected in this case. ■

FIGURE 10.6.

The Benjamini-Hochberg (BH) procedure. For uncorrected testing we reject when Pi < α. For Bonferroni testing we reject when Pi < α/m. The BH procedure rejects when Pi ≤ T. The BH threshold T corresponds to the rightmost undercrossing of the upward sloping line.

10.28 Example. Suppose that 10 independent hypothesis tests are carried leading to the following ordered p-values:

With α = 0.05, the Bonferroni test rejects any hypothesis whose p-value is less than α/10 = 0 .005. Thus, only the first two hypotheses are rejected. For the BH test, we find the largest i such that P(i) < iα/m, which in this case is i = 5. Thus we reject the first five hypotheses. ■

10.8 Goodness-of-fit Tests

There is another situation where testing arises, namely, when we want to check whether the data come from an assumed parametric model. There are many such tests; here is one.

Let be a parametric model. Suppose the data take values on the real line. Divide the line into k disjoint intervals I₁,..., Ik. For j = 1,..., k, let

be the probability that an observation falls into interval Ij under the assumed model. Here, θ = (θ₁,..., θs) are the parameters in the assumed model. Let Nj be the number of observations that fall into Ij. The likelihood for θ based on the counts N₁,..., Nk is the multinomial likelihood

Maximizing Q(θ) yields estimates of θ. Now define the test statistic

(10.9)

10.29 Theorem. Let H₀ be the null hypothesis that the data are IID draws from the model . Under H − 0, the statistic Q defined in equation (10.9) converges in distribution to a random variable. Thus, the (approximate) p-value for the test is ) where q denotes the observed value of Q.

It is tempting to replace in (10.9) with the mle . However, this will not result in a statistic whose limiting distribution is a . However, it can be shown — due to a theorem of Herman Chernoff and Erich Lehmann from 1954 — that the p-value is bounded approximately by the p-values obtained using a and a .

Goodness-of-fit testing has some serious limitations. If reject H₀ then we conclude we should not use the model. But if we do not reject H₀ we cannot conclude that the model is correct. We may have failed to reject simply because the test did not have enough power. This is why it is better to use nonparametric methods whenever possible rather than relying on parametric assumptions.

10.9 Bibliographic Remarks

The most complete book on testing is Lehmann (1986). See also Chapter 8 of Casella and Berger (2002) and Chapter 9 of Rice (1995). The FDR method is due to Benjamini and Hochberg (1995). Some of the exercises are from Rice (1995).

10.10 Appendix

10.10.1 The Neyman-Pearson Lemma

In the special case of a simple null H₀ : θ = θ₀ and a simple alternative H₁ : θ = θ₁ we can say precisely what the most powerful test is.

10.30 Theorem (Neyman-Pearson). Suppose we test H₀ : θ = θ₀ versus H₁ : θ = θ₁. Let

Suppose we reject H₀ when T > k. If we choose k so that ℙθ₀ (T > k) = α then this test is the most powerful, size α test. That is, among all tests with size α, this test maximizes the power β(θ₁).

10.10.2 The t-test

To test H₀ : μ = μ₀ where is the mean, we can use the Wald test. When the data are assumed to be Normal and the sample size is small, it is common instead to use the t-test. A random variable T has a t-distribution with k degrees of freedom if it has density

When the degrees of freedom k → ∞, this tends to a Normal distribution. When k = 1 it reduces to a Cauchy.

Let X₁,..., Xn ∼ N(μ, σ²) where θ = (μ, σ²) are both unknown. Suppose we want to test μ = μ₀ versus μ ≠ μ₀. Let

where is the sample variance. For large samples T ≈ N(0, 1) under H₀. The exact distribution of T under H₀ is tn−1. Hence if we reject when |T| > tn−1, α/2 then we get a size α test. However, when n is moderately large, the t-test is essentially identical to the Wald test.

10.11 Exercises

1.

Prove Theorem 10.6.

2.

Prove Theorem 10.14.

3.

Prove Theorem 10.10.

4.

Prove Theorem 10.12.

5.

Let X1, ..., Xn ∼ Uniform(0, θ) and let Y = max{X₁,..., Xn}. We want to test

H₀ : θ = 1/2 versus H₁ : θ > 1/2.
The Wald test is not appropriate since Y does not converge to a Normal. Suppose we decide to test this hypothesis by rejecting H₀ when Y > c.

(a)

Find the power function.

(b)

What choice of c will make the size of the test .05?

(c)

In a sample of size n = 20 with Y=0.48 what is the p-value? What conclusion about H₀ would you make?

(d)

In a sample of size n = 20 with Y=0.52 what is the p-value? What conclusion about H₀ would you make?

6.

There is a theory that people can postpone their death until after an important event. To test the theory, Phillips and King (1988) collected data on deaths around the Jewish holiday Passover. Of 1919 deaths, 922 died the week before the holiday and 997 died the week after. Think of this as a binomial and test the null hypothesis that θ = 1/2. Report and interpret the p-value. Also construct a confidence interval for θ.

7.

In 1861, 10 essays appeared in the New Orleans Daily Crescent. They were signed “Quintus Curtius Snodgrass” and some people suspected they were actually written by Mark Twain. To investigate this, we will consider the proportion of three letter words found in an author’s work. From eight Twain essays we have:
.225 .262 .217 .240 .230 .229 .235 .217
From 10 Snodgrass essays we have:
.209 .205 .196 .210 .202 .207 .224 .223 .220 .201

(a)

Perform a Wald test for equality of the means. Use the nonparametric plug-in estimator. Report the p-value and a 95 per cent confidence interval for the difference of means. What do you conclude?

(b)

Now use a permutation test to avoid the use of large sample methods. What is your conclusion? (Brinegar (1963)).

8.

Let X₁,..., Xn ∼ N(θ, 1). Consider testing

Let the rejection region be R = {xn : T(xn) > c} where T(xn) = .

(a)

Find c so that the test has size α.

(b)

Find the power under H₁, that is, find β(1).

(c)

Show that β(1) → 1 as n →∞.

9.

Let be the mle of a parameter θ and let where I(θ) is the Fisher information. Consider testing

Consider the Wald test with rejection region R = {xn : |Z| > zα/2} where. Let θ₁ > θ₀ be some alternative. Show that β(θ₁) → 1.

10.

Here are the number of elderly Jewish and Chinese women who died just before and after the Chinese Harvest Moon Festival.

Week

Chinese

Jewish

−2

55

141

−1

33

145

1

70

139

2

49

161

Compare the two mortality patterns. (Phillips and Smith (1990)).

11.

A randomized, double-blind experiment was conducted to assess the effectiveness of several drugs for reducing postoperative nausea. The data are as follows.

Number of Patients

Incidence of Nausea

Placebo

80

45

Chlorpromazine

75

26

Dimenhydrinate

85

52

Pentobarbital (100 mg)

67

35

Pentobarbital (150 mg)

85

37

(a)

Test each drug versus the placebo at the 5 per cent level. Also, report the estimated odds-ratios. Summarize your findings.

(b)

Use the Bonferroni and the FDR method to adjust for multiple testing. (Beecher (1959)).

12.

Let X₁,..., Xn ∼ Poisson(λ).

(a)

Let λ₀ > 0. Find the size α Wald test for

(b)

(Computer Experiment.) Let λ₀ = 1, n = 20 and α = .05. Simulate X₁,..., Xn ∼ Poisson(λ₀) and perform the Wald test. Repeat many times and count how often you reject the null. How close is the type I error rate to .05?

13.

Let X₁,..., Xn ∼N(μ, σ²). Construct the likelihood ratio test for

Compare to the Wald test.

14.

Let X₁,..., Xn ∼ N(μ,σ²). Construct the likelihood ratio test for

Compare to the Wald test.

15.

Let X₁ ∼ Binomial(n, p). Construct the likelihood ratio test for

Compare to the Wald test.

16.

Let θ be a scalar parameter and suppose we test

Let W be the Wald test statistic and let λ be the likelihood ratio test statistic. Show that these tests are equivalent in the sense that

as n → ∞. Hint: Use a Taylor expansion of the log-likelihood ℓ(θ) to show that

¹

The test is named after Abraham Wald (1902–1950), who was a very influential mathematical statistician. Wald died in a plane crash in India in 1950.

²

We discuss quantities like ℙ(H₀|Data) in the chapter on Bayesian inference.

³

There is some controversy about whether Mendel’s results are “too good.”

⁴

More precisely, under the null hypothesis, given the ordered data values, X₁,..., Xm, Y₁,..., Yn is uniformly distributed over the N! permutations of the data.

11
Bayesian Inference

Larry Wasserman1

(1)

Department of Statistics, Carnegie Mellon University, Baker Hall 228A, 15213-3890, Pittsburgh, PA, USA

Larry Wasserman

Email: larry@stat.cmu.edu

11.1 The Bayesian Philosophy

The statistical methods that we have discussed so far are known as frequentist (or classical) methods. The frequentist point of view is based on the following postulates:

F1

Probability refers to limiting relative frequencies. Probabilities are objective properties of the real world.

F2

Parameters are fixed, unknown constants. Because they are not fluctuating, no useful probability statements can be made about parameters.

F3

Statistical procedures should be designed to have well-defined long run frequency properties. For example, a 95 percent confidence interval should trap the true value of the parameter with limiting frequency at least 95 percent.

There is another approach to inference called Bayesian inference. The Bayesian approach is based on the following postulates:

B1

Probability describes degree of belief, not limiting frequency. As such, we can make probability statements about lots of things, not just data which are subject to random variation. For example, I might say that “the probability that Albert Einstein drank a cup of tea on August 1, 1948” is .35. This does not refer to any limiting frequency. It reflects my strength of belief that the proposition is true.

B2

We can make probability statements about parameters, even though they are fixed constants.

B3

We make inferences about a parameter θ by producing a probability distribution for θ. Inferences, such as point estimates and interval estimates, may then be extracted from this distribution.

Bayesian inference is a controversial approach because it inherently embraces a subjective notion of probability. In general, Bayesian methods provide no guarantees on long run performance. The field of statistics puts more emphasis on frequentist methods although Bayesian methods certainly have a presence. Certain data mining and machine learning communities seem to embrace Bayesian methods very strongly. Let’s put aside philosophical arguments for now and see how Bayesian inference is done. We’ll conclude this chapter with some discussion on the strengths and weaknesses of the Bayesian approach.

11.2 The Bayesian Method

Bayesian inference is usually carried out in the following way.

1.

We choose a probability density f(θ) — called the prior distribution — that expresses our beliefs about a parameter θ before we see any data.

2.

We choose a statistical model f(x|θ) that reflects our beliefs about x given θ. Notice that we now write this as f(x|θ) instead of f(x; θ).

3.

After observing data X₁,..., Xn, we update our beliefs and calculate the posterior distribution f(θ|X₁,..., Xn).

To see how the third step is carried out, first suppose that θ is discrete and that there is a single, discrete observation X. We should use a capital letter now to denote the parameter since we are treating it like a random variable, so let Θ denote the parameter. Now, in this discrete setting,

which you may recognize from Chapter 1 as Bayes’ theorem. The version for continuous variables is obtained by using density functions:

(11.1)

If we have n iid observations X₁,..., Xn, we replace f(x|θ) with

Notation. We will write Xn to mean (X₁,..., Xn) and xn to mean (x₁,..., xn).

Now,

(11.2)

where

(11.3)

is called the normalizing constant. Note that cn does not depend on θ. We can summarize by writing:

Posterior is proportional to Likelihood times Prior

or, in symbols,

You might wonder, doesn’t it cause a problem to throw away the constant cn? The answer is that we can always recover the constant later if we need to.

What do we do with the posterior distribution? First, we can get a point estimate by summarizing the center of the posterior. Typically, we use the mean or mode of the posterior. The posterior mean is

(11.4)

We can also obtain a Bayesian interval estimate. We find a and b such that Let C = (a, b). Then

so C is a 1 − α posterior interval.

11.1 Example. Let X₁,..., Xn ∼ Bernoulli(p). Suppose we take the uniform distribution f(p) = 1 as a prior. By Bayes’ theorem, the posterior has the form

where is the number of successes. Recall that a random variable has a Beta distribution with parameters α and β if its density is

We see that the posterior for p is a Beta distribution with parameters s + 1 and n − s + 1. That is,

We write this as

Notice that we have figured out the normalizing constant without actually doing the integral ∫n (p)f(p)dp. The mean of a Beta(α, β) distribution is α/(α + β) so the Bayes estimator is

(11.5)

It is instructive to rewrite the estimator as

(11.6)

where is the mle, is the prior mean and λn = n/(n + 2) ≈ 1. A 95 percent posterior interval can be obtained by numerically finding a and b such that

Suppose that instead of a uniform prior, we use the prior p ∼ Beta(α, β). If you repeat the calculations above, you will see that p|xn ∼ Beta(α + s, β + n − s). The flat prior is just the special case with α = β = 1. The posterior mean is

where p₀ = α/(α + β) is the prior mean. ■

In the previous example, the prior was a Beta distribution and the posterior was a Beta distribution. When the prior and the posterior are in the same family, we say that the prior is conjugate with respect to the model.

11.2 Example. Let X₁,..., Xn ∼ N(θ, σ²). For simplicity, let us assume that σ is known. Suppose we take as a prior θ ∼ N(a, b²). In problem 1 in the exercises it is shown that the posterior for θ is

(11.7)

where

and is the standard error of the mle . This is another example of a conjugate prior. Note that w → 1 and τ/se → 1 as n → ∞. So, for large n, the posterior is approximately . The same is true if n is fixed but b → ∞, which corresponds to letting the prior become very flat.

Continuing with this example, let us find C = (c, d) such that ℙ(θ ∈ C|Xn) = .95. We can do this by choosing c and d such that ℙ(θ < c|Xn) = .025 and ℙ(θ > d|Xn) = .025. So, we want to find c such that

We know that ℙ(Z < −1.96) = .025. So,

implying that . By similar arguments, . So a 95 percent Bayesian interval is . Since and τ ≈ se, the 95 percent Bayesian interval is approximated by which is the frequentist confidence interval. ■

11.3 Functions of Parameters

How do we make inferences about a function τ = g(θ)? Remember in Chapter 3 we solved the following problem: given the density fX for X, find the density for Y = g(X). We now simply apply the same reasoning. The posterior cdf for τ is

where A = {θ : g(θ) ≤ τ}. The posterior density is h(τ|xn) = H′(τ|xn).

11.3 Example. Let X₁,..., Xn ∼ Bernoulli(p) and f(p) = 1 so that p|Xn ∼ Beta(s + 1, n − s + 1) with . Then

and

for ψ ∈ ℝ. ■

11.4 Simulation

The posterior can often be approximated by simulation. Suppose we draw θ₁,..., θB ∼ p(θ|xn). Then a histogram of θ₁,..., θB approximates the posterior density p(θ|xn). An approximation to the posterior mean is . The posterior 1 − α interval can be approximated by (θα/2, θ1 − α/2) where θα/2 is the α/2 sample quantile of θ₁,..., θB.

Once we have a sample θ₁,..., θB from f(θ|xn), let τi = g(θi). Then τ₁,..., τB is a sample from f(τ|xn). This avoids the need to do any analytical calculations. Simulation is discussed in more detail in Chapter 24.

11.4 Example. Consider again Example 11.3. We can approximate the posterior for ψ without doing any calculus. Here are the steps:

1.

Draw P₁,..., PB ∼ Beta(s + 1, n − s + 1).

2.

Let ψi = log(Pi/(1 − Pi)) for i = 1,..., B.

Now ψ₁,..., ψB are iid draws from h(ψ|xn). A histogram of these values provides an estimate of h(ψ|xn). ■

11.5 Large Sample Properties of Bayes’ Procedures

In the Bernoulli and Normal examples we saw that the posterior mean was close to the mle. This is true in greater generality.

11.5 Theorem. Let be the mle and let Under appropriate regularity conditions, the posterior is approximately Normal with mean and standard deviation Hence, . Also, if is the asymptotic frequentist 1 − α confidence interval, then Cn is also an approximate 1 − α Bayesian posterior interval:

There is also a Bayesian delta method. Let τ = g(θ). Then

where and

11.6 Flat Priors, Improper Priors, and “Noninformative” Priors

An important question in Bayesian inference is: where does one get the prior f(θ)? One school of thought, called subjectivism says that the prior should reflect our subjective opinion about θ (before the data are collected). This may be possible in some cases but is impractical in complicated problems especially if there are many parameters. Moreover, injecting subjective opinion into the analysis is contrary to the goal of making scientific inference as objective as possible. An alternative is to try to define some sort of “noninformative prior.” An obvious candidate for a noninformative prior is to use a flat prior f(θ) ∝ constant.

In the Bernoulli example, taking f(p) = 1 leads to p|Xn ∼ Beta(s + 1, n − s + 1) as we saw earlier, which seemed very reasonable. But unfettered use of flat priors raises some questions.

Improper Priors. Let X ∼ N(θ, σ²) with σ known. Suppose we adopt a flat prior f(θ) ∝ c where c > 0 is a constant. Note that ∫ f(θ)dθ = ∞ so this is not a probability density in the usual sense. We call such a prior an improper prior. Nonetheless, we can still formally carry out Bayes’ theorem and compute the posterior density by multiplying the prior and the likelihood: f(θ) ∝ n(θ)f(θ) ∝ n(θ). This gives and the resulting point and interval estimators agree exactly with their frequentist counterparts. In general, improper priors are not a problem as long as the resulting posterior is a well-defined probability distribution.

Flat Priors are Not Invariant. Let X ∼ Bernoulli(p) and suppose we use the flat prior f(p) = 1. This flat prior presumably represents our lack of information about p before the experiment. Now let ψ = log(p/(1 − p)). This is a transformation of p and we can compute the resulting distribution for ψ, namely,

which is not flat. But if we are ignorant about p then we are also ignorant about ψ so we should use a flat prior for ψ. This is a contradiction. In short, the notion of a flat prior is not well defined because a flat prior on a parameter does not imply a flat prior on a transformed version of the parameter. Flat priors are not transformation invariant.

Jeffreys’ Prior. Jeffreys came up with a rule for creating priors. The rule is: take

where I(θ) is the Fisher information function. This rule turns out to be transformation invariant. There are various reasons for thinking that this prior might be a useful prior but we will not go into details here.

11.6 Example. Consider the Bernoulli (p) model. Recall that

Jeffreys’ rule says to use the prior

This is a Beta (1/2,1/2) density. This is very close to a uniform density. ■

In a multiparameter problem, the Jeffreys’ prior is defined to be f(θ) ∝ where |A| denotes the determinant of a matrix A and I(θ) is the Fisher information matrix.

11.7 Multiparameter Problems

Suppose that θ = (θ₁,..., θp). The posterior density is still given by

(11.8)

The question now arises of how to extract inferences about one parameter. The key is to find the marginal posterior density for the parameter of interest. Suppose we want to make inferences about θ₁. The marginal posterior for θ₁ is

(11.9)

In practice, it might not be feasible to do this integral. Simulation can help. Draw randomly from the posterior:

where the superscripts index the different draws. Each θj is a vector θj = . Now collect together the first component of each draw:

These are a sample from f(θ₁|xn) and we have avoided doing any integrals.

11.7 Example (Comparing Two Binomials). Suppose we have n₁ control patients and n₂ treatment patients and that X₁ control patients survive while X₂ treatment patients survive. We want to estimate τ = g(p₁, p₂). Then,

If f(p₁, p₂) = 1, the posterior is

Notice that (p₁, p₂) live on a rectangle (a square, actually) and that

where

which implies that p₁ and p₂ are independent under the posterior. Also, p₁|x₁ ∼ Beta(x₁ + 1, n₁ − x₁ + 1) and p₂|x₂ ∼ Beta(x₂ + 1, n₂ − x₂ + 1). If we simulate P1,1,..., P1,B ∼ Beta(x₁ + 1, n₁ − x₁ + 1) and P2,1,..., P2, B ∼ Beta(x₂ + 1, n₂ − x₂ + 1), then τb = P2, b − P1,b, b = 1,..., B, is a sample from f(τ|x₁, x₂). ■

11.8 Bayesian Testing

Hypothesis testing from a Bayesian point of view is a complex topic. We will only give a brief sketch of the main idea here. The Bayesian approach to testing involves putting a prior on H₀ and on the parameter θ and then computing ℙ(H₀ |Xn). Consider the case where θ is scalar and we are testing

It is usually reasonable to use the prior ℙ(H₀) = ℙ(H₁) = 1/2 (although this is not essential in what follows). Under H₁ we need a prior for θ. Denote this prior density by f(θ). From Bayes’ theorem

We saw that, in estimation problems, the prior was not very influential and that the frequentist and Bayesian methods gave similar answers. This is not the case in hypothesis testing. Also, one can’t use improper priors in testing because this leads to an undefined constant in the denominator of the expression above. Thus, if you use Bayesian testing you must choose the prior f(θ) very carefully. It is possible to get a prior-free bound on ℙ(H₀|Xn = xn). Notice that . Hence,

The upper bound is not very interesting, but the lower bound is non-trivial.

11.9 Strengths and Weaknesses of Bayesian Inference

Bayesian inference is appealing when prior information is available since Bayes’ theorem is a natural way to combine prior information with data. Some people find Bayesian inference psychologically appealing because it allows us to make probability statements about parameters. In contrast, frequentist inference provides confidence sets Cn which trap the parameter 95 percent of the time, but we cannot say that ℙ(θ ∈ Cn|Xn) is .95. In the frequentist approach we can make probability statements about Cn, not θ. However, psychological appeal is not a compelling scientific argument for using one type of inference over another.

In parametric models, with large samples, Bayesian and frequentist methods give approximately the same inferences. In general, they need not agree.

Here are three examples that illustrate the strengths and weakness of Bayesian inference. The first example is Example 6.14 revisited. This example shows the psychological appeal of Bayesian inference. The second and third show that Bayesian methods can fail.

11.8 Example (Example 6.14 revisited). We begin by reviewing the example. Let θ be a fixed, known real number and let X₁, X₂ be independent random variables such that ℙ(Xi = 1) = ℙ(Xi = −1) = 1/2. Now define Yi = θ + Xi and suppose that you only observe Y₁ and Y₂. Let

This is a 75 percent confidence set since, no matter what θ is, ℙθ(θ ∈ C) = 3/4.

Suppose we observe Y₁ = 15 and Y₂ = 17. Then our 75 percent confidence interval is {16}. However, we are certain, in this case, that θ = 16. So calling this a 75 percent confidence set, bothers many people. Nonetheless, C is a valid 75 percent confidence set. It will trap the true value 75 percent of the time.

The Bayesian solution is more satisfying to many. For simplicity, assume that θ is an integer. Let f(θ) be a prior mass function such that f(θ) > 0 for every integer θ. When Y = (Y₁, Y₂) = (15, 17), the likelihood function is

Applying Bayes’ theorem we see that

Hence, ℙ(θ ∈ C|Y = (15, 17)) = 1. There is nothing wrong with saying that {16} is a 75 percent confidence interval. But is it not a probability statement about θ. ■

11.9 Example. This is a simplified version of the example in Robins and Ritov (1997). The data consist of n iid triples

Let B be a finite but very large number, like B = 100¹⁰⁰. Any realistic sample size n will be small compared to B. Let

be a vector of unknown parameters such that 0 ≤ θj ≤ 1 for 1 ≤ j ≤ B. Let

be a vector of known numbers such that

where δ is some, small, positive number. Each data point (Xi, Ri, Yi) is drawn in the following way:

1.

Draw Xi uniformly from {1,..., B}.

2.

Draw Ri ∼ Bernoulli(ξXi).

3.

If Ri = 1, then draw Yi ~ Bernoulli(θXi). If Ri = 0, do not draw Yi.

The model may seem a little artificial but, in fact, it is caricature of some real missing data problems in which some data points are not observed. In this example, Ri = 0 can be thought of as meaning “missing.” Our goal is to estimate

Note that

so ψ = g(θ) is a function of θ.

Let us consider a Bayesian analysis first. The likelihood of a single observation is

The last term is raised to the power Ri since, if Ri = 0, then Yi is not observed and hence that term drops out of the likelihood. Since f(Xi) = 1/B and that Yi and Ri are Bernoulli,

Thus, the likelihood function is

We have dropped all the terms involving B and the ξj’s since these are known constants, not parameters. The log-likelihood is

where

Now, nj = mj = 0 for most j since B is so much larger than n. This has several implications. First, the mle for most θj is not defined. Second, for most θj, the posterior distribution is equal to the prior distribution, since those θj do not appear in the likelihood. Hence, f(θ|Data) ≈ f(θ). It follows that f(ψ|Data) ≈ f(ψ). In other words, the data provide little information about ψ in a Bayesian analysis.

Now we consider a frequentist solution. Define

(11.10)

We will now show that this estimator is unbiased and has small mean-squared error. It can be shown (see Exercise 7) that

(11.11)

Therefore, the mse is of order 1/n which goes to 0 fairly quickly as we collect more data, no matter how large B is. The estimator defined in (11.10) is called the Horwitz-Thompson estimator. It cannot be derived from a Bayesian or likelihood point of view since it involves the terms ξXi. These terms drop out of the log-likelihood and hence will not show up in any likelihood-based method including Bayesian estimators.

The moral of the story is this. Bayesian methods are tied to the likelihood function. But in high dimensional (and nonparametric) problems, the likelihood may not yield accurate inferences. ■

11.10 Example. Suppose that f is a probability density function and that

where g(x) > 0 is a known function and c is unknown. In principle we can compute c since ∫ f(x) dx = 1 implies that c = 1/∫ g(x) dx. But in many cases we can’t do the integral ∫ g(x) dx since g might be a complicated function and x could be high dimensional. Despite the fact that c is not known, it is often possible to draw a sample X₁,..., Xn from f; see Chapter 24. Can we use the sample to estimate the normalizing constant c? Here is a frequentist solution: Let be a consistent estimate of the density f. Chapter 20 explains how to construct such an estimate. Choose any point x and note that c = f(x)/g(x). Hence, is a consistent estimate of c. Now let us try to solve this problem from a Bayesian approach. Let π(c) be a prior such that π(c) > 0 for all c > 0. The likelihood function is

Hence the posterior is proportional to cnπ(c). The posterior does not depend on X₁,..., Xn, so we come to the startling conclusion that, from the Bayesian point of view, there is no information in the data about c. Moreover, the posterior mean is

which tends to infinity as n increases. ■

These last two examples illustrate an important point. Bayesians are slaves to the likelihood function. When the likelihood goes awry, so will Bayesian inference.

What should we conclude from all this? The important thing is to understand that frequentist and Bayesian methods are answering different questions. To combine prior beliefs with data in a principled way, use Bayesian inference. To construct procedures with guaranteed long run performance, such as confidence intervals, use frequentist methods. Generally, Bayesian methods run into problems when the parameter space is high dimensional. In particular, 95 percent posterior intervals need not contain the true value 95 percent of the time (in the frequency sense).

11.10 Bibliographic Remarks

Some references on Bayesian inference include Carlin and Louis (1996), Gelman et al. (1995), Lee (1997), Robert (1994), and Schervish (1995). See Cox (1993), Diaconis and Freedman (1986), Freedman (1999), Barron et al. (1999), Ghosal et al. (2000), Shen and Wasserman (2001), and Zhao (2000) for discussions of some of the technicalities of nonparametric Bayesian inference. The Robins-Ritov example is discussed in detail in Robins and Ritov (1997) where it is cast more properly as a nonparametric problem. Example 11.10 is due to Edward George (personal communication). See Berger and Delampady (1987) and Kass and Raftery (1995) for a discussion of Bayesian testing. See Kass and Wasserman (1996) for a discussion of noninformative priors.

11.11 Appendix

Proof of Theorem 11.5.

It can be shown that the effect of the prior diminishes as n increases so that f(θ|Xn) ∝ n(θ)f(θ) ≈ n(θ). Hence, log f(θ|Xn) ≈ ℓ(θ). Now, ℓ(θ) ≈ . Exponentiating, we get approximately that

where . So the posterior of θ is approximately Normal with mean and variance . Let ℓi = log f(Xi| θ), then

and hence . ■

11.12 Exercises

1.

Verify (11.7).

2.

Let X₁,..., Xn ∼ Normal (μ, 1).

(a)

Simulate a data set (using μ = 5) consisting of n=100 observations.

(b)

Take f(μ) = 1 and find the posterior density. Plot the density.

(c)

Simulate 1,000 draws from the posterior. Plot a histogram of the simulated values and compare the histogram to the answer in (b).

(d)

Let θ = eμ. Find the posterior density for θ analytically and by simulation.

(e)

Find a 95 percent posterior interval for μ.

(f)

Find a 95 percent confidence interval for θ.

3.

Let X₁,..., Xn ∼ Uniform(0, θ). Let f(θ) ∝ 1/θ. Find the posterior density.

4.

Suppose that 50 people are given a placebo and 50 are given a new treatment. 30 placebo patients show improvement while 40 treated patients show improvement. Let τ = p₂ − p₁ where p₂ is the probability of improving under treatment and p₁ is the probability of improving under placebo.

(a)

Find the mle of τ. Find the standard error and 90 percent confidence interval using the delta method.

(b)

Find the standard error and 90 percent confidence interval using the parametric bootstrap.

(c)

Use the prior f(p₁, p₂) = 1. Use simulation to find the posterior mean and posterior 90 percent interval for τ.

(d)

Let

be the log-odds ratio. Note that ψ = 0 if p₁ = p₂. Find the mle of ψ. Use the delta method to find a 90 percent confidence interval for ψ.

(e)

Use simulation to find the posterior mean and posterior 90 percent interval for ψ.

5.

Consider the Bernoulli(p) observations

0 1 0 1 0 0 0 0 0 0

Plot the posterior for p using these priors: Beta(1/2,1/2), Beta(1,1), Beta(10,10), Beta(100,100).

6.

Let X₁,..., Xn ∼ Poisson(λ).

(a)

Let λ ∼ Gamma(α, β) be the prior. Show that the posterior is also a Gamma. Find the posterior mean.

(b)

Find the Jeffreys’ prior. Find the posterior.

7.

In Example 11.9, verify (11.11).

8.

Let X ∼ N(μ, 1). Consider testing

Take ℙ(H₀) = ℙ(H₁) = 1/2. Let the prior for μ under H₁ be μ ∼ N(0, b²). Find an expression for ℙ(H₀|X = x). Compare ℙ(H₀|X = x) to the p-value of the Wald test. Do the comparison numerically for a variety of values of x and b. Now repeat the problem using a sample of size n. You will see that the posterior probability of H₀ can be large even when the p-value is small, especially when n is large. This disagreement between Bayesian and frequentist testing is called the Jeffreys-Lindley paradox.

12
Statistical Decision Theory

Larry Wasserman1

(1)

Department of Statistics, Carnegie Mellon University, Baker Hall 228A, 15213-3890, Pittsburgh, PA, USA

Larry Wasserman

Email: larry@stat.cmu.edu

12.1 Preliminaries

We have considered several point estimators such as the maximum likelihood estimator, the method of moments estimator, and the posterior mean. In fact, there are many other ways to generate estimators. How do we choose among them? The answer is found in decision theory which is a formal theory for comparing statistical procedures.

Consider a parameter θ which lives in a parameter space Θ. Let be an estimator of θ. In the language of decision theory, an estimator is sometimes called a decision rule and the possible values of the decision rule are called actions.

We shall measure the discrepancy between θ and using a loss function . Formally, L maps Θ × Θ into ℝ. Here are some examples of loss functions:

Bear in mind in what follows that an estimator is a function of the data. To emphasize this point, sometimes we will write as . To assess an estimator, we evaluate the average loss or risk.

12.1 Definition. The risk of an estimator is

When the loss function is squared error, the risk is just the mse (mean squared error):

In the rest of the chapter, if we do not state what loss function we are using, assume the loss function is squared error.

12.2 Comparing Risk Functions

To compare two estimators we can compare their risk functions. However, this does not provide a clear answer as to which estimator is better. Consider the following examples.

12.2 Example. Let X ∼ N(θ, 1) and assume we are using squared error loss. Consider two estimators: and . The risk functions are and . If 2 < θ < 4 then , otherwise, . Neither estimator uniformly dominates the other; see Figure 12.1. ■

FIGURE 12.1.

Comparing two risk functions. Neither risk function dominates the other at all values of θ.

12.3 Example. Let X₁,..., Xn ∼ Bernoulli(p). Consider squared error loss and let . Since this has 0 bias, we have that

Another estimator is

where and α and β are positive constants. This is the posterior mean using a Beta (α, β) prior. Now,

Let . (In Example 12.12 we will explain this choice.) The resulting estimator is

and the risk function is

The risk functions are plotted in figure 12.2. As we can see, neither estimator uniformly dominates the other.

FIGURE 12.2.

Risk functions for and in Example 12.3. The solid curve is . The dotted line is .

These examples highlight the need to be able to compare risk functions. To do so, we need a one-number summary of the risk function. Two such summaries are the maximum risk and the Bayes risk.

12.4 Definition. The maximum risk is

(12.1)

and the Bayes risk is

(12.2)

where f(θ) is a prior for θ.

12.5 Example. Consider again the two estimators in Example 12.3. We have

and

Based on maximum risk, is a better estimator since . However, when n is large, has smaller risk except for a small region in the parameter space near p = 1/2. Thus, many people prefer to . This illustrates that one-number summaries like maximum risk are imperfect. Now consider the Bayes risk. For illustration, let us take f(p) = 1. Then

and

For which suggests that is a better estimator. This might seem intuitively reasonable but this answer depends on the choice of prior. The advantage of using maximum risk, despite its problems, is that it does not require one to choose a prior. ■

These two summaries of the risk function suggest two different methods for devising estimators: choosing to minimize the maximum risk leads to minimax estimators; choosing to minimize the Bayes risk leads to Bayes estimators.

12.6 Definition. A decision rule that minimizes the Bayes risk is called a Bayes rule. Formally, is a Bayes rule with respect to the prior f if

(12.3)

where the infimum is over all estimators . An estimator that minimizes the maximum risk is called a minimax rule. Formally, is minimax if

(12.4)

where the infimum is over all estimators

12.3 Bayes Estimators

Let f be a prior. From Bayes’ theorem, the posterior density is

(12.5)

where m(x) = ∫ f(x, θ)dθ = ∫ f(x|θ)f(θ)dθ is the marginal distribution of X. Define the posterior risk of an estimator by

(12.6)

12.7 Theorem. The Bayes risk satisfies

Let be the value of θ that minimizes . Then is the Bayes estimator.

Proof. We can rewrite the Bayes risk as follows:

If we choose to be the value of θ that minimizes then we will minimize the integrand at every x and thus minimize the integral . ■

Now we can find an explicit formula for the Bayes estimator for some specific loss functions.

12.8 Theorem. If then the Bayes estimator is

(12.7)

If then the Bayes estimator is the median of the posterior is zero-one loss, then the Bayes estimator is the mode of the posterior f(θ|x).

Proof. We will prove the theorem for squared error loss. The Bayes rule minimizes . Taking the derivative of with respect to and setting it equal to 0 yields the equation Solving for we get 12.7. ■

12.9 Example. Let X₁,..., Xn ∼ N(μ,σ²) where σ² is known. Suppose we use a N(a, b²) prior for μ. The Bayes estimator with respect to squared error loss is the posterior mean, which is

12.4 Minimax Rules

Finding minimax rules is complicated and we cannot attempt a complete coverage of that theory here but we will mention a few key results. The main message to take away from this section is: Bayes estimators with a constant risk function are minimax.

12.10 Theorem. Let be the Bayes rule for some prior f:

(12.8)

Suppose that

(12.9)

Then is minimax and f is called a least favorable prior.

Proof. Suppose that is not minimax. Then there is another rule such that . Since the average of a function is always less than or equal to its maximum, we have that . Hence,

which contradicts (12.8). ■

12.11 Theorem. Suppose that is the Bayes rule with respect to some prior f. Suppose further that has constant risk: for some c. Then is minimax.

Proof. The Bayes risk is and hence for all θ. Now apply the previous theorem. ■

12.12 Example. Consider the Bernoulli model with squared error loss. In example 12.3 we showed that the estimator

has a constant risk function. This estimator is the posterior mean, and hence the Bayes rule, for the prior Beta(α, β) with . Hence, by the previous theorem, this estimator is minimax.

12.13 Example. Consider again the Bernoulli but with loss function

Let

The risk is

which, as a function of p, is constant. It can be shown that, for this loss function, is the Bayes estimator under the prior f(p) = 1. Hence, is minimax. ■

A natural question to ask is: what is the minimax estimator for a Normal model?

12.14 Theorem. Let X₁,..., Xn ∼N(θ, 1) and let . Then is minimax with respect to any well-behaved loss function.¹ It is the only estimator with this property.

If the parameter space is restricted, then the theorem above does not apply as the next example shows.

12.15 Example. Suppose that X ∼ N(θ, 1) and that θ is known to lie in the interval [−m, m] where 0 < m < 1. The unique, minimax estimator under squared error loss is

where tanh(z) = (ez − e−z)/(ez + e−z). It can be shown that this is the Bayes rule with respect to the prior that puts mass 1/2 at m and mass 1/2 at −m. Moreover, it can be shown that the risk is not constant but it does satisfy for all θ; see Figure 12.3. Hence, Theorem 12.10 implies that is minimax. ■

FIGURE 12.3.

Risk function for constrained Normal with m=.5. The two short dashed lines show the least favorable prior which puts its mass at two points.

12.5 Maximum Likelihood, Minimax, and Bayes

For parametric models that satisfy weak regularity conditions, the maximum likelihood estimator is approximately minimax. Consider squared error loss which is squared bias plus variance. In parametric models with large samples, it can be shown that the variance term dominates the bias so the risk of the mle roughly equals the variance:²

As we saw in Chapter 9, the variance of the mle is approximately

where I(θ) is the Fisher information. Hence,

(12.10)

For any other estimator θ′, it can be shown that for large n, . More precisely,

(12.11)

This says that, in a local, large sample sense, the mle is minimax. It can also be shown that the mle is approximately the Bayes rule.

In summary:

In most parametric models, with large samples, the mle is approximately minimax and Bayes.

There is a caveat: these results break down when the number of parameters is large as the next example shows.

12.16 Example (Many Normal means). Let Yi ∼ N(θi, σ²/n), i = 1,..., n. Let Y = (Y₁,..., Yn) denote the data and let θ = (θ₁,..., θn) denote the unknown parameters. Assume that

for some c > 0. In this model, there are as many parameters as observations.³ The mle is . Under the loss function θi)², the risk of the mle is . It can be shown that the minimax risk is approximately σ²/(σ² + c²) and one can find an estimator that achieves this risk. Since σ²/ (σ² +c²) < σ², we see that has smaller risk than the mle. In practice, the difference between the risks can be substantial. This shows that maximum likelihood is not an optimal estimator in high dimensional problems. ■

12.6 Admissibility

Minimax estimators and Bayes estimators are “good estimators” in the sense that they have small risk. It is also useful to characterize bad estimators.

12.17 Definition. An estimator is inadmissible if there exists another rule such that

Otherwise, is admissible.

12.18 Example. Let X ∼ N(θ, 1) and consider estimating θ with squared error loss. Let . We will show that is admissible. Suppose not. Then there exists a different rule with smaller risk. In particular, . Hence, . Thus, . So there is no rule that beats . Even though is admissible it is clearly a bad decision rule. ■

12.19 Theorem (Bayes Rules Are Admissible). Suppose that Θ ⊂ ℝ and that is a continuous function of θ for every Let f be a prior density with full support, meaning that, for every θ and every . Let be the Bayes’ rule. If the Bayes risk is finite then is admissible.

Proof. Suppose is inadmissible. Then there exists a better rule such that for all θ and for some θ₀. Let . Since R is continuous, there is an ϵ > 0 such that for all θ ∈ (θ₀ − ϵ, θ₀ + ϵ). Now,

Hence, . This implies that does not minimize which contradicts the fact that is the Bayes rule. ■

12.20 Theorem. Let X₁,..., Xn ∼N(μ, σ²). Under squared error loss, is admissible.

The proof of the last theorem is quite technical and is omitted but the idea is as follows: The posterior mean is admissible for any strictly positive prior. Take the prior to be N(a, b²). When b² is very large, the posterior mean is approximately equal to .

How are minimaxity and admissibility linked? In general, a rule may be one, both, or neither. But here are some facts linking admissibility and minimaxity.

12.21 Theorem. Suppose that has constant risk and is admissible. Then it is minimax.

Proof. The risk is for some c. If were not minimax then there exists a rule such that

This would imply that is inadmissible. ■

Now we can prove a restricted version of Theorem 12.14 for squared error loss.

12.22 Theorem. Let X₁,..., Xn ∼ N(θ, 1). Then, under squared error loss, is minimax.

Proof. According to Theorem 12.20, is admissible. The risk of is 1/n which is constant. The result follows from Theorem 12.21. ■

Although minimax rules are not guaranteed to be admissible they are “close to admissible.” Say that is strongly inadmissible if there exists a rule and an ϵ > 0 such that for all θ.

12.23 Theorem. If is minimax, then it is not strongly inadmissible.

12.7 Stein’s Paradox

Suppose that X ∼N(θ, 1) and consider estimating θ with squared error loss. From the previous section we know that is admissible. Now consider estimating two, unrelated quantities θ = (θ₁, θ₂) and suppose that X₁ ∼N(θ₁, 1) and X₂ ∼N(θ₂, 1) independently, with loss . Not surprisingly, is again admissible where X = (X₁, X₂). Now consider the generalization to k normal means. Let θ = (θ₁,..., θk), X = (X₁,..., Xk) with Xi ∼ N(θi, 1) (independent) and loss . Stein astounded everyone when he proved that, if k ≥ 3, then is inadmissible. It can be shown that the James-Stein estimator has smaller risk, where ,

(12.12)

and (z)⁺ = max{z, 0}. This estimator shrinks the Xi’s towards 0. The message is that, when estimating many parameters, there is great value in shrinking the estimates. This observation plays an important role in modern nonparametric function estimation.

12.8 Bibliographic Remarks

Aspects of decision theory can be found in Casella and Berger (2002), Berger (1985), Ferguson (1967), and Lehmann and Casella (1998).

12.9 Exercises

1.

In each of the following models, find the Bayes risk and the Bayes estimator, using squared error loss.

(a)

X ∼ Binomial(n, p), p ∼ Beta(α, β).

(b)

X ∼ Poisson(λ), λ ∼ Gamma(α, β).

(c)

X ∼N(θ, σ²) where σ² is known and θ ∼N(a, b²).

2.

Let X₁,..., Xn ∼ N(θ, σ²) and suppose we estimate θ with loss function . Show that is admissible and minimax.

3.

Let Θ = {θ₁,..., θk} be a finite parameter space. Prove that the posterior mode is the Bayes estimator under zero-one loss.

4.

(Casella and Berger (2002).) Let X₁,..., Xn, be a sample from a distribution with variance σ². Consider estimators of the form bS² where S² is the sample variance. Let the loss function for estimating σ² be

Find the optimal value of b that minimizes the risk for all σ².

5.

(Berliner (1983).) Let X ∼ Binomial(n, p) and suppose the loss function is

where 0 < p < 1. Consider the estimator . This estimator falls outside the parameter space (0,1) but we will allow this. Show that is the unique, minimax rule.

6.

(Computer Experiment.) Compare the risk of the mle and the James-Stein estimator (12.12) by simulation. Try various values of n and various vectors θ. Summarize your results.

¹

“Well-behaved” means that the level sets must be convex and symmetric about the origin. The result holds up to sets of measure 0.

²

Typically, the squared bias is order O(n⁻²) while the variance is of order O(n− 1).

³

The many Normal means problem is more general than it looks. Many nonparametric estimation problems are mathematically equivalent to this model.

Part III
Statistical Models and Methods

13
Linear and Logistic Regression

Larry Wasserman1

(1)

Department of Statistics, Carnegie Mellon University, Baker Hall 228A, 15213-3890, Pittsburgh, PA, USA

Larry Wasserman

Email: larry@stat.cmu.edu

Regression is a method for studying the relationship between a response variable Y and a covariate X. The covariate is also called a predictor variable or a feature.¹ One way to summarize the relationship between X and Y is through the regression function

(13.1)

Our goal is to estimate the regression function r(x) from data of the form

In this Chapter, we take a parametric approach and assume that r is linear. In Chapters 20 and 21 we discuss nonparametric regression.

13.1 Simple Linear Regression

The simplest version of regression is when Xi is simple (one-dimensional) and r(x) is assumed to be linear:

This model is called the the simple linear regression model. We will make the further simplifying assumption that does not depend on x. We can thus write the linear regression model as follows.

13.1 Definition. The Simple Linear Regression Model

(13.2)

where and .

13.2 Example. Figure 13.1 shows a plot of log surface temperature (Y) versus log light intensity (X) for some nearby stars. Also on the plot is an estimated linear regression line which will be explained shortly. ■

Figure 13.1.

Data on nearby stars. The solid line is the least squares line.

The unknown parameters in the model are the intercept β₀ and the slope β₁ and the variance σ². Let and denote estimates of β₀ and β₁. The fitted line is

(13.3)

The predicted values or fitted values are and the residuals are defined to be

. (13.4)

The residual sums of squares or rss, which measures how well the line fits the data, is defined by .

13.3 Definition. The least squares estimates are the values and that minimize

13.4 Theorem. The least squares estimates are given by

(13.5)

(13.6)

An unbiased estimate of σ² is

(13.7)

13.5 Example. Consider the star data from Example 13.2. The least squares estimates are The fitted line is shown in Figure 13.1. ■

13.6 Example (The 2001 Presidential Election). Figure 13.2 shows the plot of votes for Buchanan (Y) versus votes for Bush (X) in Florida. The least squares estimates (omitting Palm Beach County) and the standard errors are

The fitted line is

(We will see later how the standard errors were computed.) Figure 13.2 also shows the residuals. The inferences from linear regression are most accurate when the residuals behave like random normal numbers. Based on the residual plot, this is not the case in this example. If we repeat the analysis replacing votes with log(votes) we get

This gives the fit

The residuals look much healthier. Later, we shall address the following question: how do we see if Palm Beach County has a statistically plausible outcome? ■

Figure 13.2.

Voting Data for Election 2000. See example 13.6.

13.2 Least Squares and Maximum Likelihood

Suppose we add the assumption that ϵi|Xi ∼ N(0, σ²), that is,

where μi = β₀ + β₁Xi. The likelihood function is

where and

(13.8)

The term does not involve the parameters β₀ and β₁. We shall focus on the second term which is called the conditional likelihood, given by

The conditional log-likelihood is

(13.9)

To find the MLE of (β₀, β₁) we maximize ℓ(β₀, β₁, σ). From (13.9) we see that maximizing the likelihood is the same as minimizing the rss Therefore, we have shown the following:

13.7 Theorem. Under the assumption of Normality, the least squares estimator is also the maximum likelihood estimator.

We can also maximize ℓ(β₀, β₁, σ) over σ, yielding the MLE

(13.10)

This estimator is similar to, but not identical to, the unbiased estimator. Common practice is to use the unbiased estimator (13.7).

13.3 Properties of the Least Squares Estimators

We now record the standard errors and limiting distribution of the least squares estimator. In regression problems, we usually focus on the properties of the estimators conditional on Xn = (X₁,..., Xn). Thus, we state the means and variances as conditional means and variances.

13.8 Theorem. denote the least squares estimators. Then,

(13.11)

where

The estimated standard errors of and are obtained by taking the square roots of the corresponding diagonal terms of and inserting the estimate for σ. Thus,

(13.12)

(13.13)

We should really write these as and but we will use the shorter notation and .

13.9 Theorem. Under appropriate conditions we have:

1.

(Consistency):

2.

(Asymptotic Normality):

3.

Approximate 1 − α confidence intervals for β₀ and β₁ are

(13.14)

4.

The Wald test² for testing H₀ : β₁ = 0 versus H₁ : β₁ ≠ 0 is: reject H₀ if |W| > zα/2 where .

13.10 Example. For the election data, on the log scale, a 95 percent confidence interval is .7303 ± 2(.0358) = (.66, .80). The Wald statistics for testing H₀ : β₁ = 0 versus H₀ : β₁ ≠ 0 is |W| = |.7303 − 0|/.0358 with a p-value of ℙ(|Z| > 20.40) ≈ 0. This is strong evidence that that the true slope is not 0. ■

13.4 Prediction

Suppose we have estimated a regression model from data (X₁, Y₁), ..., (Xn, Yn). We observe the value X = x* of the covariate for a new subject and we want to predict their outcome Y*. An estimate of Y* is

(13.15)

Using the formula for the variance of the sum of two random variables,

Theorem 13.8 gives the formulas for all the terms in this equation. The estimated standard error is the square root of this variance, with in place of σ². However, the confidence interval for Y* is not of the usual form . The reason for this is explained in Exercise 10. The correct form of the confidence interval is given in the following theorem.

13.11 Theorem (Prediction Interval). Let

(13.16)

An approximate 1 − α prediction interval for Y* is

(13.17)

13.12 Example (Election Data Revisited). On the log scale, our linear regression gives the following prediction equation:

In Palm Beach, Bush had 152,954 votes and Buchanan had 3,467 votes. On the log scale this is 11.93789 and 8.151045. How likely is this outcome, assuming our regression model is appropriate? Our prediction for log Buchanan votes . Now, 8.151045 is bigger than 6.388441 but is it “significantly” bigger? Let us compute a confidence interval. We find that and the approximate 95 percent confidence interval is (6.200,6.578) which clearly excludes 8.151. Indeed, 8.151 is nearly 20 standard errors from . Going back to the vote scale by exponentiating, the confidence interval is (493,717) compared to the actual number of votes which is 3,467. ■

13.5 Multiple Regression

Now suppose that the covariate is a vector of length k. The data are of the form

where

Here, Xi is the vector of k covariate values for the ith observation. The linear regression model is

(13.18)

for i = 1,..., n, where Usually we want to include an intercept in the model which we can do by setting Xi₁ = 1 for i = 1,..., n. At this point it will be more convenient to express the model in matrix notation. The outcomes will be denoted by

and the covariates will be denoted by

Each row is one observation; the columns correspond to the k covariates. Thus, X is a (n × k) matrix. Let

Then we can write (13.18) as

(13.19)

The form of the least squares estimate is given in the following theorem.

13.13 Theorem. Assuming that the (k × k) matrix XT X is invertible,

(13.20)

(13.21)

(13.22)

The estimate regression function is . An unbiased estimate of σ² is

where is the vector of residuals. An approximate 1 − α confidence interval for βj is

(13.23)

where is the jth diagonal element of the matrix .

13.14 Example. Crime data on 47 states in 1960 can be obtained from http://lib.stat.cmu.edu/DASL/Stories/USCrime.html.
If we fit a linear regression of crime rate on 10 variables we get the following: This table is typical of the output of a multiple regression program. The “tvalue” is the Wald test statistic for testing H₀: βj = 0 versus H₁: βj ≠ 0. The asterisks denote “degree of significance” and more asterisks denote smaller p-values. The example raises several important questions: (1) should we eliminate some variables from this model? (2) should we interpret these relationships as causal? For example, should we conclude that low crime prevention expenditures cause high crime rates? We will address question (1) in the next section. We will not address question (2) until Chapter 16. ■

13.6 Model Selection

Example 13.14 illustrates a problem that often arises in multiple regression. We may have data on many covariates but we may not want to include all of them in the model. A smaller model with fewer covariates has two advantages: it might give better predictions than a big model and it is more parsimonious (simpler). Generally, as you add more variables to a regression, the bias of the predictions decreases and the variance increases. Too few covariates yields high bias; this called underfitting. Too many covariates yields high variance; this called overfitting. Good predictions result from achieving a good balance between bias and variance.

In model selection there are two problems: (i) assigning a “score” to each model which measures, in some sense, how good the model is, and (ii) searching through all the models to find the model with the best score.

Let us first discuss the problem of scoring models. Let S ⊂ {1, ..., k} and let denote a subset of the covariates. Let βS denote the coefficients of the corresponding set of covariates and let denote the least squares estimate of βS. Also, let Xs denote the X matrix for this subset of covariates and define to be the estimated regression function. The predicted values from model S are denoted by . The prediction risk is defined to be

(13.24)

where denotes the value of a future observation of Yi at covariate value X. Our goal is to choose S to make R(S) small.

The training error is defined to be

This estimate is very biased as an estimate of R(S).

13.15 Theorem. The training error is a downward-biased estimate of the prediction risk:

In fact,

(13.25)

The reason for the bias is that the data are being used twice: to estimate the parameters and to estimate the risk. When we fit a complex model with many parameters, the covariance will be large and the bias of the training error gets worse. Here are some better estimates of risk.

Mallow’s Cp statistic is defined by

(13.26)

where |S| denotes the number of terms in S and ( is the estimate of σ² obtained from the full model (with all covariates in the model). This is simply the training error plus a bias correction. This estimate is named in honor of Colin Mallows who invented it. The first term in (13.26) measures the fit of the model while the second measure the complexity of the model. Think of the Cp statistic as:

Thus, finding a good model involves trading off fit and complexity.

A related method for estimating risk is AIC (Akaike Information Criterion). The idea is to choose S to maximize

(13.27)

where ℓS is the log-likelihood of the model evaluated at the mle. ³ This can be thought of “goodness of fit” minus “complexity.” In linear regression with Normal errors (and taking σ equal to its estimate from the largest model), maximizing AIC is equivalent to minimizing Mallow’s Cp; see Exercise 8. The appendix contains more explanation about AIC.

Yet another method for estimating risk is leave-one-out cross-validation. In this case, the risk estimator is

(13.28)

where is the prediction for Yi obtained by fitting the model with Yi omitted. It can be shown that

(13.29)

where Uii (S) is the ith diagonal element of the matrix

(13.30)

Thus, one need not actually drop each observation and re-fit the model. A generalization is k-fold cross-validation. Here we divide the data into k groups; often people take k = 10. We omit one group of data and fit the models to the remaining data. We use the fitted model to predict the data in the group that was omitted. We then estimate the risk by where the sum is over the the data points in the omitted group. This process is repeated for each of the k groups and the resulting risk estimates are averaged.

For linear regression, Mallows Cp and cross-validation often yield essentially the same results so one might as well use Mallows’ method. In some of the more complex problems we will discuss later, cross-validation will be more useful.

Another scoring method is BIC (Bayesian information criterion). Here we choose a model to maximize

(13.31)

The BIC score has a Bayesian interpretation. Let S = {S₁,..., Sm} denote a set of models. Suppose we assign the prior ℙ(Sj ) = 1/m over the models. Also, assume we put a smooth prior on the parameters within each model. It can be shown that the posterior probability for a model is approximately,

Hence, choosing the model with highest BIC is like choosing the model with highest posterior probability. The BIC score also has an information-theoretic interpretation in terms of something called minimum description length. The BIC score is identical to Mallows Cp except that it puts a more severe penalty for complexity. It thus leads one to choose a smaller model than the other methods.

Now let us turn to the problem of model search. If there are k covariates then there are 2k possible models. We need to search through all these models, assign a score to each one, and choose the model with the best score. If k is not too large we can do a complete search over all the models. When k is large, this is infeasible. In that case we need to search over a subset of all the models. Two common methods are forward and backward stepwise regression. In forward stepwise regression, we start with no covariates in the model. We then add the one variable that leads to the best score. We continue adding variables one at a time until the score does not improve. Backwards stepwise regression is the same except that we start with the biggest model and drop one variable at a time. Both are greedy searches; nether is guaranteed to find the model with the best score. Another popular method is to do random searching through the set of all models. However, there is no reason to expect this to be superior to a deterministic search.

13.16 Example. We applied backwards stepwise regression to the crime data using AIC. The following was obtained from the program R. This program uses a slightly different definition of AIC. With their definition, we seek the smallest (not largest) possible AIC. This is the same is minimizing Mallows Cp.

The full model (which includes all covariates) has AIC = 310.37. In ascending order, the AIC scores for deleting one variable are as follows:

For example, if we dropped Pop from the model and kept the other terms, then the AIC score would be 308. Based on this information we drop “population” from the model and the current AIC score is 308. Now we consider dropping a variable from the current model. The AIC scores are:

We then drop “Southern” from the model. This process is continued until there is no gain in AIC by dropping any variables. In the end, we are left with the following model:

Warning! This does not yet address the question of which variables are causes of crime. ■

There is another method for model selection that avoids having to search through all possible models. This method, which is due to Zheng and Loh (1995), does not seek to minimize prediction errors. Rather, it assumes some subset of the βj’s are exactly equal to 0 and tries to find the true model, that is, the smallest sub-model consisting of nonzero βj terms. The method is carried out as follows.

Zheng-Loh Model Selection Method ⁴

1.

Fit the full model with all k covariates and let denote the Wald test statistic for H₀ : βj = 0 versus H₁ : βj ≠ 0.

2.

Order the test statistics from largest to smallest in absolute value:

3.

Let be the value of j that minimizes

where rss(j) is the residual sums of squares from the model with the j largest Wald statistics.

4.

Choose, as the final model, the regression with the terms with the largest absolute Wald statistics.

Zheng and Loh showed that, under appropriate conditions, this method chooses the true model with probability tending to one as the sample size increases.

13.7 Logistic Regression

So far we have assumed that Yi is real valued. Logistic regression is a parametric method for regression when Yi ∈ {0, 1} is binary. For a k-dimensional covariate X, the model is

(13.32)

or, equivalently,

(13.33)

where

(13.34)

The name “logistic regression” comes from the fact that is called the logistic function. A plot of the logistic for a one-dimensional covariate is shown in Figure 13.3.

Figure 13.3.

The logistic function p = ex/(1 + ex).

Because the Yi’s are binary, the data are Bernoulli:

Hence the (conditional) likelihood function is

(13.35)

The MLE has to be obtained by maximizing numerically. There is a fast numerical algorithm called reweighted least squares. The steps are as follows:

Reweighted Least Squares Algorithm

Choose starting values and compute using equation (13.32), for i = 1,..., n. Set s = 0 and iterate the following steps until convergence.

1.

Set

2.

Let W be a diagonal matrix with (i, i) element equal to

3.

Set

This corresponds to doing a (weighted) linear regression of Z on Y.

4.

Set s = s + 1 and go back to the first step.

The Fisher information matrix I can also be obtained numerically. The estimate standard error of is the (j, j) element of J = I⁻¹. Model selection is usually done using the AIC score .

13.17 Example. The Coronary Risk-Factor Study (CORIS) data involve 462 males between the ages of 15 and 64 from three rural areas in South Africa, (Rousseauw et al. (1983)). The outcome Y is the presence (Y = 1) or absence (Y = 0) of coronary heart disease. There are 9 covariates: systolic blood pressure, cumulative tobacco (kg), ldl (low density lipoprotein cholesterol), adiposity, famhist (family history of heart disease), typea (type-A behavior), obesity, alcohol (current alcohol consumption), and age. A logistic regression yields the following estimates and Wald statistics Wj for the coefficients:

Are you surprised by the fact that systolic blood pressure is not significant or by the minus sign for the obesity coefficient? If yes, then you are confusing association and causation. This issue is discussed in Chapter 16. The fact that blood pressure is not significant does not mean that blood pressure is not an important cause of heart disease. It means that it is not an important predictor of heart disease relative to the other variables in the model. ■

13.8 Bibliographic Remarks

A succinct book on linear regression is Weisberg (1985). A data-mining view of regression is given in Hastie et al. (2001). The Akaike Information Criterion (AIC) is due to Akaike (1973). The Bayesian Information Criterion (BIC) is due to Schwarz (1978). References on logistic regression include Agresti (1990) and Dobson (2001).

13.9 Appendix

The Akaike Information Criterion (AIC). Consider a set of models {M₁, M₂, ...}. Let denote the estimated probability function obtained by using the maximum likelihood estimator of model Mj . Thus, where is the mle of the set of parameters βj for model Mj . We will use the loss function where

is the Kullback-Leibler distance between two probability functions. The corresponding risk function is Notice that where c = ∑x f(x) log f(x) does not depend on and

Thus, minimizing the risk is equivalent to maximizing

It is tempting to estimate but, just as the training error in regression is a highly biased estimate of prediction risk, it is also the case that is a highly biased estimate of . In fact, the bias is approximately equal to |Mj|. Thus:

13.18 Theorem. AIC(Mj) is an approximately unbiased estimate of

13.10 Exercises

1.

Prove Theorem 13.4.

2.

Prove the formulas for the standard errors in Theorem 13.8. You should regard the Xi’s as fixed constants.

3.

Consider the regression through the origin model:

Find the least squares estimate for β. Find the standard error of the estimate. Find conditions that guarantee that the estimate is consistent.

4.

Prove equation (13.25).

5.

In the simple linear regression model, construct a Wald test for H₀ : β₁ versus H₁ : β₁ ≠ 17β₀.

6.

Get the passenger car mileage data from

http://lib.stat.cmu.edu/DASL/Datafiles/carmpgdat.html

(a)

Fit a simple linear regression model to predict MPG (miles per gallon) from HP (horsepower). Summarize your analysis including a plot of the data with the fitted line.

(b)

Repeat the analysis but use log(MPG) as the response. Compare the analyses.

7.

Get the passenger car mileage data from

http://lib.stat.cmu.edu/DASL/Datafiles/carmpgdat.html

(a)

Fit a multiple linear regression model to predict MPG (miles per gallon) from the other variables. Summarize your analysis.

(b)

Use Mallow Cp to select a best sub-model. To search through the models try (i) forward stepwise, (ii) backward stepwise. Summarize your findings.

(c)

Use the Zheng-Loh model selection method and compare to (b).

(d)

Perform all possible regressions. Compare Cp and BIC. Compare the results.

8.

Assume a linear regression model with Normal errors. Take σ known. Show that the model with highest AIC (equation (13.27)) is the model with the lowest Mallows Cp statistic.

9.

In this question we will take a closer look at the AIC method. Let X₁,..., Xn be IID observations. Consider two models and . Under the data are assumed to be N (0, 1) while under the data are assumed to be N (θ, 1) for some unknown θ ∈ ℝ:

This is just another way to view the hypothesis testing problem: H₀ : θ = 0 versus H₁ : θ ≠ 0. Let be the log-likelihood function. The AIC score for a model is the log-likelihood at the mle minus the number of parameters. (Some people multiply this score by 2 but that is irrelevant.) Thus, the AIC score for is AIC₀ = ℓn (0) and the AIC score for is . Suppose we choose the model with the highest AIC score. Let Jn denote the selected model:

(a)

Suppose that is the true model, i.e. θ = 0. Find

Now compute limn→∞ ℙ(Jn = 0) when θ ≠ 0.

(b)

The fact that limn→∞ ℙ(Jn = 0) ≠ 1 when θ = 0 is why some people say that AIC “overfits.” But this is not quite true as we shall now see. Let ϕθ(x) denote a Normal density function with mean θ and variance 1. Define

If θ = 0, show that where

is the Kullback-Leibler distance. Show also that Hence, AIC consistently estimates the true density even if it “over-shoots” the correct model.

(c)

Repeat this analysis for BIC which is the log-likelihood minus (p/2)log n where p is the number of parameters and n is sample size.

10.

In this question we take a closer look at prediction intervals. Let θ = β₀ + β₁X* and let . Thus, while Y* = θ + ϵ. Now, where

Note that is the same as . Now, is an approximate 95 percent confidence interval for θ = β₀ + β₁x* using the usual argument for a confidence interval. But, as you shall now show, it is not a valid confidence interval for Y*.

(a)

Let . Show that

(b)

The problem is that the quantity of interest Y* is equal to a parameter θ plus a random variable. We can fix this by defining

In practice, we substitute for σ and we denote the resulting quantity by . Now consider the interval . Show that

11.

Get the Coronary Risk-Factor Study (CORIS) data from the book web site. Use backward stepwise logistic regression based on AIC to select a model. Summarize your results.

¹

The term “regression” is due to Sir Francis Galton (1822–1911) who noticed that tall and short men tend to have sons with heights closer to the mean. He called this “regression towards the mean.”

²

Recall from equation (10.5) that the Wald statistic for testing H₀ : = β = β₀ versus H₁ : = β ≠ β₀ .

³

Some texts use a slightly difFerent definition of Ale which involves multiplying the definition here by 2 or −2. This has no efFect on which model is selected.

⁴

This is just one version of their method. In particular, the penalty j log n is only one choice from a set of possible penalty functions.

14
Multivariate Models

Larry Wasserman1

(1)

Department of Statistics, Carnegie Mellon University, Baker Hall 228A, 15213-3890, Pittsburgh, PA, USA

Larry Wasserman

Email: larry@stat.cmu.edu

In this chapter we revisit the Multinomial model and the multivariate Normal. Let us first review some notation from linear algebra. In what follows, x and y are vectors and A is a matrix.

Linear Algebra Notation

xTy

inner product ∑j xjyj

|A|

determinant

AT

transpose of A

A⁻¹

inverse of A

I

the identity matrix

tr(A)

trace of a square matrix; sum of its diagonal elements

A1/2

square root matrix

The trace satisfies tr(AB) = tr(BA) and tr(A) + tr(B). Also, tr(a) = a if a is a scalar. A matrix is positive definite if xTΣx > 0 for all nonzero vectors x. If a matrix A is symmetric and positive definite, its square root A1/2 exists and has the following properties: (1) A1/2 is symmetric; (2) A = Al/2 Al/2; (3) A1/2 A−1/2 = A−1/2 A1/2 = I where A−1/2 = (A1/2)⁻¹.

14.1 Random Vectors

Multivariate models involve a random vector X of the form

The mean of a random vector X is defined by

(14.1)

The covariance matrix Σ, also written , is defined to be

(14.2)

This is also called the variance matrix or the variance—covariance matrix. The inverse Σ⁻¹ is called the precision matrix.

14.1 Theorem. Let a be a vector of length k and let X be a random vector of the same length with mean μ and variance Σ. Then and . If A is a matrix with k columns, then and .

Now suppose we have a random sample of n vectors:

(14.3)

The sample mean is a vector defined by

where . The sample variance matrix, also called the covariance matrix or the variance—covariance matrix, is

(14.4)

where

It follows that . and .

14.2 Estimating the Correlation

Consider n data points from a bivariate distribution:

Recall that the correlation between X₁ and X₂ is

(14.5)

where . The nonparametric plug-in estimator is the sample correlation ¹

(14.6)

where

We can construct a confidence interval for ρ by applying the delta method. However, it turns out that we get a more accurate confidence interval by first constructing a confidence interval for a function θ = f(ρ) and then applying the inverse function f⁻¹. The method, due to Fisher, is as follows: Define f and its inverse by

Approximate Confidence Interval for The Correlation

1.

Compute

2.

Compute the approximate standard error of which can be shown to be

3.

An approximate 1 − α confidence interval for θ = f(ρ) is

4.

Apply the inverse transformation f⁻¹(z) to get a confidence interval for ρ:

Yet another method for getting a confidence interval for ρ is to use the bootstrap.

14.3 Multivariate Normal

Recall that a vector X has a multivariate Normal distribution, denoted by X ∼ N(μ, Σ), if its density is

(14.7)

where μ is a vector of length k and ∑ is a k × k symmetric, positive definite matrix. Then and .

14.2 Theorem. The following properties hold:

1.

If Z ∼ N(0, 1) and X = μ + Σ1/2Z, then X ∼ N(μ, Σ).

2.

If X ∼ N(μ, Σ), then Σ−1/2 (X− μ) ∼ N(0, 1).

3.

If X ∼ N(μ, Σ) a is a vector of the same length as X, then aTX ∼ N(aTμ, aTΣa).

4.

Let

Then .

14.3 Theorem. Given a random sample of size n from a N(μ, Σ), the log-likelihood is (up to a constant not depending on μ or Σ) given by

The mle is

(14.8)

14.4 Multinomial

Let us now review the Multinomial distribution. The data take the form X = (X₁,..., Xk) where each Xj is a count. Think of drawing n balls (with replacement) from an urn which has balls with k different colors. In this case, Xj is the number of balls of the kth color. Let p = (p₁,..., pk) where pj ≥ 0 and and suppose that pj is the probability of drawing a ball of color j.

14.4 Theorem. Let X ∼ Multinomial(n, p). Then the marginal distribution of Xj is Xj ∼ Binomial(n, pj). The mean and variance of X are

and

Proof. That Xj ∼ Binomial(n, pj) follows easily. Hence, and . To compute Cov(Xi, Xj) we proceed as follows: Notice that Xi + Xj ∼ Binomial(n, pi + pj) and so . On the other hand,

Equating this last expression with n(pi + pj) (1 − pi − pj) implies that Cov(Xi, Xj) = −npipj. ■

14.5 Theorem. The maximum likelihood estimator of p is

Proof. The log-likelihood (ignoring a constant) is

When we maximize ℓ we have to be careful since we must enforce the constraint that ∑j pj = 1. We use the method of Lagrange multipliers and instead maximize

Now

Setting yields . Since we see that λ = −n and hence as claimed. ■

Next we would like to know the variability of the mle. We can either compute the variance matrix of directly or we can approximate the variability of the mle by computing the Fisher information matrix. These two approaches give the same answer in this case. The direct approach is easy: , and so

where

For large n, has approximately a multivariate Normal distribution.

14.6 Theorem. As n → ∞,

14.5 Bibliographic Remarks

Some references on multivariate analysis are Johnson and Wichern (1982) and Anderson (1984). The method for constructing the confidence interval for the correlation described in this chapter is due to Fisher (1921).

14.6 Appendix

Proof of Theorem 14.3. Denote the ith random vector by Xi. The log-likelihood is

Now,

since . Also, notice that (Xi − μ)TΣ⁻¹(Xi − μ) is a scalar, so

and the conclusion follows. ■

14.7 Exercises

1.

Prove Theorem 14.1.

2.

Find the Fisher information matrix for the mle of a Multinomial.

3.

(Computer Experiment.) Write a function to generate nsim observations from a Multinomial(n, p) distribution.

4.

(Computer Experiment.) Write a function to generate nsim observations from a Multivariate normal with given mean μ and covariance matrix Σ.

5.

(Computer Experiment.) Generate 100 random vectors from a N(μ, Σ) distribution where

Plot the simulation as a scatterplot. Estimate the mean and covariance matrix Σ. Find the correlation ρ between X₁ and X₂. Compare this with the sample correlations from your simulation. Find a 95 percent confidence interval for ρ. Use two methods: the bootstrap and Fisher’s method. Compare.

6.

(Computer Experiment.) Repeat the previous exercise 1000 times. Compare the coverage of the two confidence intervals for ρ.

¹

More precisely, the plug-in estimator has n rather than n − 1 in the formula for sj but this difference is small.

15
Inference About Independence

Larry Wasserman1

(1)

Department of Statistics, Carnegie Mellon University, Baker Hall 228A, 15213-3890, Pittsburgh, PA, USA

Larry Wasserman

Email: larry@stat.cmu.edu

In this chapter we address the following questions:

(1)

How do we test if two random variables are independent?

(2)

How do we estimate the strength of dependence between two random variables?

When Y and Z are not independent, we say that they are dependent or associated or related. If Y and Z are associated, it does not imply that Y causes Z or that Z causes Y. Causation is discussed in Chapter 16.

Recall that we write Y ∐ Z to mean that Y and Z are independent and we write to mean that Y and Z are dependent.

15.1 Two Binary Variables

Suppose that Y and Z are both binary and consider data (Y₁, Z₁),..., (Yn, Zn). We can represent the data as a two-by-two table:

where

The dotted subscripts denote sums. Thus,

This is a convention we use throughout the remainder of the book. Denote the corresponding probabilities by:

where pij = ℙ(Z = i, Y = j). Let X = (X₀₀, X₀₁, X10 , X₁₁) denote the vector of counts. Then X ∼ Multinomial(n, p) where p = (p₀₀, p₀₁, p₁₀, p₁₁). It is now convenient to introduce two new parameters.

15.1 Definition. The odds ratio is defined to be

(15.1)

The log odds ratio is defined to be

(15.2)

15.2 Theorem. The following statements are equivalent:

1.

Y ∐ Z.

2.

ψ = 1.

3.

γ = 0.

4.

For i, j ∈ {0, 1}, = pij = pi.p.j.

Now consider testing

(15.3)

First we consider the likelihood ratio test. Under H₁, X ∼ Multinomial(n, p) and the mle is the vector . Under H₀, we again have that X ∼ Multinomial(n, p) but the restricted mle is computed under the constraint pij = pi.p.j This leads to the following test:

15.3 Theorem. The likelihood ratio test statistic for (15.3) is

(15.4)

Under Thus, an approximate level α test is obtained by rejecting H₀ when

Another popular test for independence is Pearson’s χ² test.

15.4 Theorem. Pearson’s χ² test statistic for independence is

(15.5)

where

Under H₀, Thus, an approximate level α test is obtained by rejecting H₀ when

Here is the intuition for the Pearson test. Under H₀, pij = pi.p.j, so the maximum likelihood estimator of pij under H₀ is

Thus, the expected number of observations in the (i,j) cell is

The statistic U compares the observed and expected counts.

15.5 Example. The following data from Johnson and Johnson (1972) relate tonsillectomy and Hodgkins disease. ¹

We would like to know if tonsillectomy is related to Hodgkins disease. The likelihood ratio statistic is T = 14.75 and the p-value is . The χ² statistic is U = 14.96 and the p-value is . We reject the null hypothesis of independence and conclude that tonsillectomy is associated with Hodgkins disease. This does not mean that tonsillectomies cause Hodgkins disease. Suppose, for example, that doctors gave tonsillectomies to the most seriously ill patients. Then the association between tonsillectomies and Hodgkins disease may be due to the fact that those with tonsillectomies were the most ill patients and hence more likely to have a serious disease. ■

We can also estimate the strength of dependence by estimating the odds ratio ψ and the log-odds ratio γ.

15.6 Theorem. The mles of ψ and γ are

(15.6)

The asymptotic standard errors (computed using the delta method) are

(15.7)

(15.8)

15.7 Remark. For small sample sizes, and can have a very large variance. In this case, we often use the modified estimator

(15.9)

Another test for independence is the Wald test for γ = 0 given by W = . A 1 − α confidence interval for γ is

A 1 − α confidence interval for ψ can be obtained in two ways. First, we could use . Second, since ψ = eγ we could use

(15.10)

This second method is usually more accurate.

15.8 Example. In the previous example,

and

So tonsillectomy patients were twice as likely to have Hodgkins disease. The standard error of is

The Wald statistic is W = .69/.18 = 3.84 whose p-value is ℙ(|Z| > 3. 84) = .0001, the same as the other tests. A 95 per cent confidence interval for γ is ±2(.18) = (.33, 1.05). A 95 per cent confidence interval for ψ is (e.33, e1.05) = (1.39, 2.86). ■

15.2 Two Discrete Variables

Now suppose that Y ∈ {1,..., I} and Z ∈ {1,..., J} are two discrete variables. The data can be represented as an I × J table of counts:

where

Consider testing

(15.11)

15.9 Theorem. The likelihood ratio test statistic for (15.11) is

(15.12)

The limiting distribution of T under the null hypothesis of independence is where v = (I − 1)(J − 1). Pearson’s χ² test statistic is

(15.13)

Asymptotically, under H₀, U has a distribution where v = (I − 1) (J − 1).

15.10 Example. These data are from Dunsmore et al. (1987). Patients with Hodgkins disease are classified by their response to treatment and by histological type.

The χ² test statistic is 75.89 with 2 × 3 = 6 degrees of freedom. The p-value is . The likelihood ratio test statistic is 68.30 with 2 × 3 = 6 degrees of freedom. The p-value is . Thus there is strong evidence that response to treatment and histological type are associated. ■

15.3 Two Continuous Variables

Now suppose that Y and Z are both continuous. If we assume that the joint distribution of Y and Z is bivariate Normal, then we measure the dependence between Y and Z by means of the correlation coefficient ρ. Tests, estimates, and confidence intervals for ρ in the Normal case are given in the previous chapter in Section 14.2. If we do not assume Normality then we can still use the methods in Section 14.2 to draw inferences about the correlation ρ. However, if we conclude that ρ is 0, we cannot conclude that Y and Z are independent, only that they are uncorrelated. Fortunately, the reverse direction is valid: if we conclude that Y and Z are correlated than we can conclude they are dependent.

15.4 One Continuous Variable and One Discrete

Suppose that Y ∈ {1,..., I} is discrete and Z is continuous. Let Fi(z) = ℙ(Z ≤ z|Y = i) denote the cdf of Z conditional on Y = i.

15.11 Theorem. When Y ∈ {1,..., I} is discrete and Z is continuous, then Y ∐ Z if and only if F₁ = ⋯ = FI.

It follows from the previous theorem that to test for independence, we need to test

For simplicity, we consider the case where I = 2. To test the null hypothesis that F₁ = F₂ we will use the two sample Kolmogorov-Smirnov test. Let n₁ denote the number of observations for which Yi = 1 and let n₂ denote the number of observations for which Yi = 2. Let

and

denote the empirical distribution function of Z given Y = 1 and Y = 2 respectively. Define the test statistic

15.12 Theorem. Let

(15.14)

Under the null hypothesis that F₁ = F₂,

It follows from the theorem that an approximate level α test is obtained by rejecting H₀ when

15.5 Appendix

Interpreting The Odds Ratios. Suppose event A as probability ℙ(A). The odds of A are defined as odds(A) = ℙ(A)/(1 − ℙ(A)). It follows that ℙ(A) = odds(A)/(1 + odds(A)). Let E be the event that someone is exposed to something (smoking, radiation, etc) and let D be the event that they get a disease. The odds of getting the disease given that you are exposed are:

and the odds of getting the disease given that you are not exposed are:

The odds ratio is defined to be

If ψ = 1 then disease probability is the same for exposed and unexposed. This implies that these events are independent. Recall that the log-odds ratio is defined as γ = log(ψ) Independence corresponds to γ = 0.

Consider this table of probabilities and corresponding table of data:

Now

and so

and therefore,

To estimate the parameters, we have to first consider how the data were collected. There are three methods.

Multinomial Sampling. We draw a sample from the population and, for each person, record their exposure and disease status. In this case, X = (X₀₀, X₀₁, X₁₀, X₁₁) ∼ Multinomial(n, p). We then estimate the probabilities in the table by and

Prospective Sampling. (Cohort Sampling). We get some exposed and unexposed people and count the number with disease in each group. Thus,

We should really write x₀. and x₁. instead of X₀. and X₁. since in this case, these are fixed not random, but for notational simplicity I’ll keep using capital letters. We can estimate ℙ(D|E) and ℙ(D|Ec) but we cannot estimate all the probabilities in the table. Still, we can estimate ψ since ψ is a function of ℙ(D|E) and ℙ(D|Ec). Now

Thus,

just as before.

Case-Control (Retrospective) Sampling. Here we get some diseased and non-diseased people and we observe how many are exposed. This is much more efficient if the disease is rare. Hence,

From these data we can estimate ℙ(E|D) and ℙ(E|Dc). Surprisingly, we can also still estimate ψ. To understand why, note that

By a similar argument,

Hence,

From the data, we form the following estimates:

Therefore,

So in all three data collection methods, the estimate of ψ turns out to be the same.

It is tempting to try to estimate ℙ(D|E) −ℙ(D|Ec). In a case-control design, this quantity is not estimable. To see this, we apply Bayes’ theorem to get

Because of the way we obtained the data, ℙ(D) is not estimable from the data. However, we can estimate ξ = ℙ(D|E)/ℙ(D|Ec), which is called the relative risk, under the rare disease assumption.

15.13 Theorem. Let ξ = ℙ(D|E)/ℙ(D|Ec). Then

asℙ(D) → 0.

Thus, under the rare disease assumption, the relative risk is approximately the same as the odds ratio and, as we have seen, we can estimate the odds ratio.

15.6 Exercises

1.

Prove Theorem 15.2.

2.

Prove Theorem 15.3.

3.

Prove Theorem 15.6.

4.

The New York Times (January 8, 2003, page A12) reported the following data on death sentencing and race, from a study in Maryland: ²

Death Sentence

No Death Sentence

Black Victim

14

641

White Victim

62

594

Analyze the data using the tools from this chapter. Interpret the results. Explain why, based only on this information, you can’t make causal conclusions. (The authors of the study did use much more information in their full report.)

5.

Analyze the data on the variables Age and Financial Status from: http://lib.stat.cmu.edu/DASL/Datafiles/montanadat.html

6.

Estimate the correlation between temperature and latitude using the data from http://lib.stat.cmu.edu/DASL/Datafiles/USTemperatures.html

Use the correlation coefficient. Provide estimates, tests, and confidence intervals.

7.

Test whether calcium intake and drop in blood pressure are associated. Use the data in http://lib.stat.cmu.edu/DASL/Datafiles/Calcium.html

¹

The data are actually from a case-control study; see the appendix for an explanation of case-control studies.

²

The data here are an approximate re-creation using the information in the article.

16
Causal Inference

Larry Wasserman1

(1)

Department of Statistics, Carnegie Mellon University, Baker Hall 228A, 15213-3890, Pittsburgh, PA, USA

Larry Wasserman

Email: larry@stat.cmu.edu

Roughly speaking, the statement “X causes Y” means that changing the value of X will change the distribution of Y. When X causes Y, X and Y will be associated but the reverse is not, in general, true. Association does not necessarily imply causation. We will consider two frameworks for discussing causation. The first uses counterfactual random variables. The second, presented in the next chapter, uses directed acyclic graphs.

16.1 The Counterfactual Model

Suppose that X is a binary treatment variable where X = 1 means “treated” and X = 0 means “not treated.” We are using the word “treatment” in a very broad sense. Treatment might refer to a medication or something like smoking. An alternative to “treated/not treated” is “exposed/not exposed” but we shall use the former.

Let Y be some outcome variable such as presence or absence of disease. To distinguish the statement “X is associated Y” from the statement “X causes Y” we need to enrich our probabilistic vocabulary. Specifically, we will decompose the response Y into a more fine-grained object.

We introduce two new random variables (C₀, C₁), called potential outcomes with the following interpretation: C₀ is the outcome if the subject is not treated (X = 0) and C₁ is the outcome if the subject is treated (X = 1). Hence,

We can express the relationship between Y and (C₀, C₁) more succinctly by

(16.1)

Equation (16.1) is called the consistency relationship.

Here is a toy dataset to make the idea clear:

The asterisks denote unobserved values. When X = 0 we don’t observe C₁, in which case we say that C₁ is a counterfactual since it is the outcome you would have had if, counter to the fact, you had been treated (X = 1). Similarly, when X = 1 we don’t observe C₀, and we say that C₀ is counterfactual. There are four types of subjects:

Type

C₀

C₁

Survivors

1

1

Responders

0

1

Anti-responders

1

0

Doomed

0

0

Think of the potential outcomes (C₀, C₁) as hidden variables that contain all the relevant information about the subject.

Define the average causal effect or average treatment effect to be

(16.2)

The parameter θ has the following interpretation: θ is the mean if everyone were treated (X = 1) minus the mean if everyone were not treated (X = 0). There are other ways of measuring the causal effect. For example, if C₀ and C₁ are binary, we define the causal odds ratio

and the causal relative risk

The main ideas will be the same whatever causal effect we use. For simplicity, we shall work with the average causal effect θ.

Define the association to be

(16.3)

Again, we could use odds ratios or other summaries if we wish.

16.1 Theorem (Association Is Not Causation). In general, θ ≠ α.

16.2 Example. Suppose the whole population is as follows:

Again, the asterisks denote unobserved values. Notice that C₀ = C₁ for every subject, thus, this treatment has no effect. Indeed,

Thus, the average causal effect is 0. The observed data are only the X’s and Y’s, from which we can estimate the association:

Hence, θ ≠ α.

To add some intuition to this example, imagine that the outcome variable is 1 if “healthy” and 0 if “sick”. Suppose that X = 0 means that the subject does not take vitamin C and that X = 1 means that the subject does take vitamin C. Vitamin C has no causal effect since C₀ = C₁ for each subject. In this example there are two types of people: healthy people (C₀, C₁) = (1, 1) and unhealthy people (C₀, C₁) = (0, 0). Healthy people tend to take vitamin C while unhealthy people don’t. It is this association between (C₀, C₁) and X that creates an association between X and Y. If we only had data on X and Y we would conclude that X and Y are associated. Suppose we wrongly interpret this causally and conclude that vitamin C prevents illness. Next we might encourage everyone to take vitamin C. If most people comply with our advice, the population will look something like this:

Now α = (4/7) − (0/1) = 4/7. We see that α went down from 1 to 4/7. Of course, the causal effect never changed but the naive observer who does not distinguish association and causation will be confused because his advice seems to have made things worse instead of better. ■

In the last example, θ = 0 and α = 1. It is not hard to create examples in which α > 0 and yet θ < 0. The fact that the association and causal effects can have different signs is very confusing to many people.

The example makes it clear that, in general, we cannot use the association to estimate the causal effect θ. The reason that θ ≠ α is that (C₀, C₁) was not independent of X. That is, treatment assignment was not independent of person type.

Can we ever estimate the causal effect? The answer is: sometimes. In particular, random assignment to treatment makes it possible to estimate θ.

16.3 Theorem. Suppose we randomly assign subjects to treatment and thatℙ(X = 0) > 0 and ℙ(X = 1) > 0. Then α = θ. Hence, any consistent estimator of α is a consistent estimator of θ. In particular, a consistent estimator is

is a consistent estimator of θ, where

and

Proof. Since X is randomly assigned, X is independent of (C₀, C₁). Hence,

The consistency follows from the law of large numbers. ■

If Z is a covariate, we define the conditional causal effect by

For example, if Z denotes gender with values Z = 0 (women) and Z = 1 (men), then θ₀ is the causal effect among women and θ₁ is the causal effect among men. In a randomized experiment, 0, Z = z) and we can estimate the conditional causal effect using appropriate sample averages.

Summary of the Counterfactual Model

Random variables: (C₀, C₁, X, Y).

Consistency relationship: Y = CX.

Causal Effect:

Association:

Random assignment ⇒ (C₀, C₁) ∐ X ⇒ θ = α.

16.2 Beyond Binary Treatments

Let us now generalize beyond the binary case. Suppose that X ∈ . For example, X could be the dose of a drug in which case X ∈ ℝ. The counterfactual vector (C₀, C₁) now becomes the counterfactual function C(x) where C(x) is the outcome a subject would have if he received dose x. The observed response is given by the consistency relation

(16.4)

See Figure 16.1. The causal regression function is

(16.5)

FIGURE 16.1.

A counterfactual function C(x). The outcome Y is the value of the curve C(x) evaluated at the observed dose X.

The regression function, which measures association, is

16.4 Theorem. In general, θ(x) ≠ r(x). However, when X is randomly assigned, θ(x) = r(x).

16.5 Example. An example in which θ(x) is constant but r(x) is not constant is shown in Figure 16.2. The figure shows the counterfactual functions for four subjects. The dots represent their X values X₁, X₂, X₃, X₄. Since Ci(x) is constant over x for all i, there is no causal effect and hence

is constant. Changing the dose x will not change anyone’s outcome. The four dots in the lower plot represent the observed data points Y₁ = C₁(X₁), Y₂ = C₂(X₂), Y₃ = C₃(X₃), Y₄ = C₄(X₄). The dotted line represents the regression Although there is no causal effect, there is an association since the regression curve r(x) is not constant. ■

FIGURE 16.2.

The top plot shows the counterfactual function C(x) for four subjects. The dots represent their X values. Since Ci(x) is constant over x for all i, there is no causal effect. Changing the dose will not change anyone’s outcome. The lower plot shows the causal regression function θ(x) =(C₁(x) + C₂(x) + C₃(x) + C₄(x))/4. The four dots represent the observed data points Y₁ = C₁(X₁), Y₂ = C₂(X₂), Y₃ = C₃(X₃), Y₄ = C₄(X₄). The dotted line represents the regression There is no causal effect since Ci(x) is constant for all i. But there is an association since the regression curve r(x) is not constant.

16.3 Observational Studies and Confounding

A study in which treatment (or exposure) is not randomly assigned is called an observational study. In these studies, subjects select their own value of the exposure X. Many of the health studies you read about in the newspaper are like this. As we saw, association and causation could in general be quite different. This discrepancy occurs in non-randomized studies because the potential outcome C is not independent of treatment X. However, suppose we could find groupings of subjects such that, within groups, X and {C(x): x ∈ } are independent. This would happen if the subjects are very similar within groups. For example, suppose we find people who are very similar in age, gender, educational background, and ethnic background. Among these people we might feel it is reasonable to assume that the choice of X is essentially random. These other variables are called confounding variables.¹ If we denote these other variables collectively as Z, then we can express this idea by saying that

(16.6)

Equation (16.6) means that, within groups of Z, the choice of treatment X does not depend on type, as represented by {C(x): x ∈ }. If (16.6) holds and we observe Z then we say that there is no unmeasured confounding.

16.6 Theorem. Suppose that (16.6) holds. Then,

(16.7)

If is a consistent estimate of the regression function z), then a consistent estimate of θ(x) is

In particular, if r(x, z) = β₀ + β₁x + β₂z is linear, then a consistent estimate of θ(x) is

(16.8)

where are the least squares estimators.

16.7 Remark. It is useful to compare equation (16.7) to which can be written as

Epidemiologists call (16.7) the adjusted treatment effect. The process of computing adjusted treatment effects is called adjusting (or controlling) for confounding. The selection of what confounders Z to measure and control for requires scientific insight. Even after adjusting for confounders, we cannot be sure that there are not other confounding variables that we missed. This is why observational studies must be treated with healthy skepticism. Results from observational studies start to become believable when: (i) the results are replicated in many studies, (ii) each of the studies controlled for plausible confounding variables, (iii) there is a plausible scientific explanation for the existence of a causal relationship.

A good example is smoking and cancer. Numerous studies have shown a relationship between smoking and cancer even after adjusting for many confounding variables. Moreover, in laboratory studies, smoking has been shown to damage lung cells. Finally, a causal link between smoking and cancer has been found in randomized animal studies. It is this collection of evidence over many years that makes this a convincing case. One single observational study is not, by itself, strong evidence. Remember that when you read the newspaper.

16.4 Simpson’s Paradox

Simpson’s paradox is a puzzling phenomenon that is discussed in most statistics texts. Unfortunately, most explanations are confusing (and in some cases incorrect). The reason is that it is nearly impossible to explain the paradox without using counterfactuals (or directed acyclic graphs).

Let X be a binary treatment variable, Y a binary outcome, and Z a third binary variable such as gender. Suppose the joint distribution of X, Y, Z is

The marginal distribution for (X, Y) is

From these tables we find that,

To summarize, we seem to have the following information:

Clearly, something is amiss. There can’t be a treatment which is good for men, good for women, but bad overall. This is nonsense. The problem is with the set of English statements in the table. Our translation from math into English is specious.

The phrase “treatment is harmful” should be written mathematically as ℙ(C₁ = 1) < ℙ(C₀ = 1). The phrase “treatment is harmful for men” should be written ℙ(C₁ = 1|Z = 1) < ℙ(C₀ = 1|Z = 1). The three mathematical statements in the table are not at all contradictory. It is only the translation into English that is wrong.

Let us now show that a real Simpson’s paradox cannot happen, that is, there cannot be a treatment that is beneficial for men and women but harmful overall. Suppose that treatment is beneficial for both sexes. Then

for all z. It then follows that

Hence, ℙ(C₁ = 1) > ℙ(C₀ = 1), so treatment is beneficial overall. No paradox.

16.5 Bibliographic Remarks

The use of potential outcomes to clarify causation is due mainly to Jerzy Neyman and Donald Rubin. Later developments are due to Jamie Robins, Paul Rosenbaum, and others. A parallel development took place in econometrics by various people including James Heckman and Charles Manski. Texts on causation include Pearl (2000), Rosenbaum (2002), Spirtes et al. (2000), and van der Laan and Robins (2003).

16.6 Exercises

1.

Create an example like Example 16.2 in which α > 0 and θ < 0.

2.

Prove Theorem 16.4.

3.

Suppose you are given data (X₁, Y₁),..., (Xn, Yn) from an observational study, where Xi ∈ {0, 1} and Yi ∈ {0, 1}. Although it is not possible to estimate the causal effect θ, it is possible to put bounds on θ. Find upper and lower bounds on θ that can be consistently estimated from the data. Show that the bounds have width 1.
Hint: Note that 0).

4.

Suppose that X ∈ ℝ and that, for each subject i, Ci(x) = β1ix. Each subject has their own slope β1i. Construct a joint distribution on (β₁, X) such that ℙ(β₁ > 0) = 1 but is a decreasing function of x, where Y = C(X). Interpret.

5.

Let X ∈ {0, 1} be a binary treatment variable and let (C₀, C₁) denote the corresponding potential outcomes. Let Y = CX denote the observed response. Let F₀ and F₁ be the cumulative distribution functions for C₀ and C₁. Assume that F₀ and F₁ are both continuous and strictly increasing. Let θ = m₁ − m₀ where is the median of C₀ and is the median of C₁. Suppose that the treatment X is assigned randomly. Find an expression for θ involving only the joint distribution of X and Y.

¹A more precise definition of confounding is given in the next chapter.

17
Directed Graphs and Conditional Independence

Larry Wasserman1

(1)

Department of Statistics, Carnegie Mellon University, Baker Hall 228A, 15213-3890, Pittsburgh, PA, USA

Larry Wasserman

Email: larry@stat.cmu.edu

17.1 Introduction

A directed graph consists of a set of nodes with arrows between some nodes. An example is shown in Figure 17.1.

FIGURE 17.1.

A directed graph with vertices V = {X, Y, Z} and edges E = {(Y, X), (Y, Z)}.

Graphs are useful for representing independence relations between variables. They can also be used as an alternative to counterfactuals to represent causal relationships. Some people use the phrase Bayesian network to refer to a directed graph endowed with a probability distribution. This is a poor choice of terminology. Statistical inference for directed graphs can be performed using frequentist or Bayesian methods, so it is misleading to call them Bayesian networks.

Before getting into details about directed acyclic graphs (DAGs), we need to discuss conditional independence.

17.2 Conditional Independence

17.1 Definition. Let X, Y and Z be random variables. X and Y are conditionally independent given Z, written X ∐ Y | Z, if

(17.1)

for all x, y and z.

Intuitively, this means that, once you know Z, Y provides no extra information about X. An equivalent definition is that

(17.2)

The conditional independence relation satisfies some basic properties.

17.2 Theorem. The following implications hold: ¹

17.3 DAGs

A directed graph consists of a set of vertices V and an edge set E of ordered pairs of vertices. For our purposes, each vertex will correspond to a random variable. If (X, Y) ∈ E then there is an arrow pointing from X to Y. See Figure 17.1.

If an arrow connects two variables X and Y (in either direction) we say that X and Y are adjacent. If there is an arrow from X to Y then X is a parent of Y and Y is a child of X. The set of all parents of X is denoted by πX or π(X). A directed path between two variables is a set of arrows all pointing in the same direction linking one variable to the other such as:

A sequence of adjacent vertices staring with X and ending with Y but ignoring the direction of the arrows is called an undirected path. The sequence {X, Y, Z} in Figure 17.1 is an undirected path. X is an ancestor of Y if there is a directed path from X to Y (or X = Y). We also say that Y is a descendant of X.

A configuration of the form:

is called a collider at Y. A configuration not of that form is called a non-collider, for example,

or

The collider property is path dependent. In Figure 17.7, Y is a collider on the path {X, Y, Z} but it is a non-collider on the path {X, Y, W}. When the variables pointing into the collider are not adjacent, we say that the collider is unshielded. A directed path that starts and ends at the same variable is called a cycle. A directed graph is acyclic if it has no cycles. In this case we say that the graph is a directed acyclic graph or DAG. From now on, we only deal with acyclic graphs.

17.4 Probability and DAGs

Let be a DAG with vertices V = (X₁,..., Xk).

17.3 Definition. If ℙ is a distribution for V with probability function f, we say that ℙ is Markov to , or that represents ℙ, if

(17.3)

where πi are the parents of Xi. The set of distributions represented by is denoted by M().

17.4 Example. Figure 17.2 shows a DAG with four variables. The probability function for this example factors as

FIGURE 17.2.

DAG for Example 17.4.

17.5 Example. For the DAG in Figure 17.3, ℙ ∈ M() if and only if its probability function f has the form

FIGURE 17.3.

Another DAG.

The following theorem says that ℙ ∈ M() if and only if the Markov Condition holds. Roughly speaking, the Markov Condition means that every variable W is independent of the “past” given its parents.

17.6 Theorem. A distribution ℙ ∈ M() if and only if the following Markov Condition holds: for every variable W,

(17.4)

where denotes all the other variables except the parents and descendants of W.

17.7 Example. In Figure 17.3, the Markov Condition implies that

17.8 Example. Consider the DAG in Figure 17.4. In this case probability function must factor like

The Markov Condition implies the following independence relations:

FIGURE 17.4.

Yet another DAG.

17.5 More Independence Relations

The Markov Condition allows us to list some independence relations implied by a DAG. These relations might imply other independence relations. Consider the DAG in Figure 17.5. The Markov Condition implies:

It turns out (but it is not obvious) that these conditions imply that

FIGURE 17.5.

And yet another DAG.

How do we find these extra independence relations? The answer is “d-separation” which means “directed separation.” d-separation can be summarized by three rules. Consider the four DAG’s in Figure 17.6 and the DAG in Figure 17.7. The first 3 DAG’s in Figure 17.6 have no colliders. The DAG in the lower right of Figure 17.6 has a collider. The DAG in Figure 17.7 has a collider with a descendant.

FIGURE 17.6.

The first three DAG’s have no colliders. The fourth DAG in the lower right corner has a collider at Y.

FIGURE 17.7.

A collider with a descendant.

The Rules of d-Separation

Consider the DAGs in Figures 17.6 and 17.7.

1.

When Y is not a collider, X and Z are d-connected, but they are d-separated given Y.

2.

If X and Z collide at Y, then X and Z are d-separated, but they are d-connected given Y.

3.

Conditioning on the descendant of a collider has the same effect as conditioning on the collider. Thus in Figure 17.7, X and Z are d-separated but they are d-connected given W.

Here is a more formal definition of d-separation. Let X and Y be distinct vertices and let W be a set of vertices not containing X or Y. Then X and Y are d-separated given W if there exists no undirected path U between X and Y such that (i) every collider on U has a descendant in W, and (ii) no other vertex on U is in W. If A, B, and W are distinct sets of vertices and A and B are not empty, then A and B are d-separated given W if for every X ∈ A and Y ∈ B, X and Y are d-separated given W. Sets of vertices that are not d-separated are said to be d-connected.

17.9 Example. Consider the DAG in Figure 17.8. From the d-separation rules we conclude that:

X and Y are d-separated (given the empty set);

X and Y are d-connected given {S₁, S₂};

X and Y are d-separated given {S₁, S₂, V}.

FIGURE 17.8.

d-separation explained.

17.10 Theorem. ² Let A, B, and C be disjoint sets of vertices. Then A∐B | C if and only if A and B are d-separated by C.

17.11 Example. The fact that conditioning on a collider creates dependence might not seem intuitive. Here is a whimsical example from Jordan (2004) that makes this idea more palatable. Your friend appears to be late for a meeting with you. There are two explanations: she was abducted by aliens or you forgot to set your watch ahead one hour for daylight savings time. (See Figure 17.9.) Aliens and Watch are blocked by a collider which implies they are marginally independent. This seems reasonable since — before we know anything about your friend being late — we would expect these variables to be independent. We would also expect that ℙ(Aliens = yes|Late = yes) > ℙ(Aliens = yes); learning that your friend is late certainly increases the probability that she was abducted. But when we learn that you forgot to set your watch properly, we would lower the chance that your friend was abducted. Hence, ℙ(Aliens = yes|Late = yes) ≠ ℙ(Aliens = yes|Late = yes, Watch = no). Thus, Aliens and Watch are dependent given Late. ■

FIGURE 17.9.

Jordan’s alien example (Example 17.11). Was your friend kidnapped by aliens or did you forget to set your watch?

17.12 Example. Consider the DAG in Figure 17.2. In this example, overweight and smoking are marginally independent but they are dependent given heart disease.■

Graphs that look different may actually imply the same independence relations. If is a DAG, we let denote all the independence statements implied by . Two DAGs and for the same variables V are Markov equivalent if . Given a DAG , let skeleton() denote the undirected graph obtained by replacing the arrows with undirected edges.

17.13 Theorem. Two DAGs and are Markov equivalent if and only if (i) skeleton() = skeleton() and (ii) and have the same unshielded colliders.

17.14 Example. The first three DAGs in Figure 17.6 are Markov equivalent. The DAG in the lower right of the Figure is not Markov equivalent to the others. ■

17.6 Estimation for DAGs

Two estimation questions arise in the context of DAGs. First, given a DAG and data V₁,..., Vn from a distribution f consistent with , how do we estimate f? Second, given data V₁,...,Vn how do we estimate ? The first question is pure estimation while the second involves model selection. These are very involved topics and are beyond the scope of this book. We will just briefly mention the main ideas.

Typically, one uses some parametric model f(x|πx; θx) for each conditional density. The likelihood function is then

where Xij is the value of Xj for the ith data point and θj are the parameters for the jth conditional density. We can then estimate the parameters by maximum likelihood.

To estimate the structure of the DAG itself, we could fit every possible DAG using maximum likelihood and use AIC (or some other method) to choose a DAG. However, there are many possible DAGs so you would need much data for such a method to be reliable. Also, searching through all possible DAGs is a serious computational challenge. Producing a valid, accurate confidence set for the DAG structure would require astronomical sample sizes. If prior information is available about part of the DAG structure, the computational and statistical problems are at least partly ameliorated.

17.7 Bibliographic Remarks

There are a number of texts on DAGs including Edwards (1995) and Jordan (2004). The first use of DAGs for representing causal relationships was by Wright (1934). Modern treatments are contained in Spirtes et al. (2000) and Pearl (2000). Robins et al. (2003) discuss the problems with estimating causal structure from data.

17.8 Appendix

Causation Revisited. We discussed causation in Chapter 16 using the idea of counterfactual random variables. A different approach to causation uses DAGs. The two approaches are mathematically equivalent though they appear to be quite different. In the DAG approach, the extra element is the idea of intervention. Consider the DAG in Figure 17.10.

FIGURE 17.10.

Conditioning versus intervening.

The probability function for a distribution consistent with this DAG has the form f(x, y, z) = f(x)f(y|x)f(z|x, y). The following is pseudocode for generating from this distribution.

Suppose we repeat this code many times, yielding data (x₁, y₁, z₁),...,(xn, yn, zn). Among all the times that we observe Y = y, how often is Z = z? The answer to this question is given by the conditional distribution of Z|Y. Specifically,

Now suppose we intervene by changing the computer code. Specifically, suppose we fix Y at the value y. The code now looks like this:

Having set Y = y, how often was Z = z? To answer, note that the intervention has changed the joint probability to be

The answer to our question is given by the marginal distribution

We shall denote this as ℙ(Z = z|Y := y) or f(z|Y := y). We call ℙ(Z = z|Y = y) conditioning by observation or passive conditioning. We call ℙ(Z = z|Y := y) conditioning by intervention or active conditioning.

Passive conditioning is used to answer a predictive question like:

“Given that Joe smokes, what is the probability he will get lung cancer?”

Active conditioning is used to answer a causal question like:

“If Joe quits smoking, what is the probability he will get lung cancer?”

Consider a pair (, ℙ) where is a DAG and ℙ is a distribution for the variables V of the DAG. Let p denote the probability function for ℙ. Consider intervening and fixing a variable X to be equal to x. We represent the intervention by doing two things:

(1)

Create a new DAG * by removing all arrows pointing into X;

(2)

Create a new distribution f*(v) = ℙ(V = v|X := x) by removing the term f(x|πX) from f(v).

The new pair (*, f*) represents the intervention “set X = x.”

17.15 Example. You may have noticed a correlation between rain and having a wet lawn, that is, the variable “Rain” is not independent of the variable “Wet Lawn” and hence pR, W(r, w) ≠ pR(r)pW(w) where R denotes Rain and W denotes Wet Lawn. Consider the following two DAGs:

The first DAG implies that f(w, r) = f(r)f(w|r) while the second implies that f(w, r) = f(w)f(r|w) No matter what the joint distribution f(w, r) is, both graphs are correct. Both imply that R and W are not independent. But, intuitively, if we want a graph to indicate causation, the first graph is right and the second is wrong. Throwing water on your lawn doesn’t cause rain. The reason we feel the first is correct while the second is wrong is because the interventions implied by the first graph are correct.

Look at the first graph and form the intervention W = 1 where 1 denotes “wet lawn.” Following the rules of intervention, we break the arrows into W to get the modified graph:

with distribution f*(r) = f(r). Thus ℙ(R = r | W := w) = ℙ(R = r) tells us that “wet lawn” does not cause rain.

Suppose we (wrongly) assume that the second graph is the correct causal graph and form the intervention W = 1 on the second graph. There are no arrows into W that need to be broken so the intervention graph is the same as the original graph. Thus f*(r) = f(r|w) which would imply that changing “wet” changes “rain.” Clearly, this is nonsense.

Both are correct probability graphs but only the first is correct causally. We know the correct causal graph by using background knowledge.

17.16 Remark. We could try to learn the correct causal graph from data but this is dangerous. In fact it is impossible with two variables. With more than two variables there are methods that can find the causal graph under certain assumptions but they are large sample methods and, furthermore, there is no way to ever know if the sample size you have is large enough to make the methods reliable.

We can use DAGs to represent confounding variables. If X is a treatment and Y is an outcome, a confounding variable Z is a variable with arrows into both X and Y; see Figure 17.11. It is easy to check, using the formalism of interventions, that the following facts are true:

FIGURE 17.11.

Randomized study;, Observational study with measured confounders; Observational study with unmeasured confounders. The circled variables are unobserved.

In a randomized study, the arrow between Z and X is broken. In this case, even with Z unobserved (represented by enclosing Z in a circle), the causal relationship between X and Y is estimable because it can be shown that which does not involve the unobserved Z. In an observational study, with all confounders observed, we get as in formula (16.7). If Z is unobserved then we cannot estimate the causal effect because involves the unobserved Z. We can’t just use X and Y since in this case. ℙ(Y = y|X = x) ≠ ℙ(Y = y|X := x) which is just another way of saying that causation is not association.

In fact, we can make a precise connection between DAGs and counterfactuals as follows. Suppose that X and Y are binary. Define the confounding variable Z by

From this, you can make the correspondence between the DAG approach and the counterfactual approach explicit. I leave this for the interested reader.

17.9 Exercises

1.

Show that (17.1) and (17.2) are equivalent.

2.

Prove Theorem 17.2.

FIGURE 17.12.

DAG for exercise 7.

3.

Let X, Y and Z have the following joint distribution:

(a)

Find the conditional distribution of X and Y given Z = 0 and the conditional distribution of X and Y given Z = 1.

(b)

Show that X ∐ Y|Z.

(c)

Find the marginal distribution of X and Y.

(d)

Show that X and Y are not marginally independent.

4.

Consider the three DAGs in Figure 17.6 without a collider. Prove that X ∐ Z|Y.

5.

Consider the DAG in Figure 17.6 with a collider. Prove that X ∐ Z and that X and Z are dependent given Y.

6.

Let X ∈ {0, 1}, Y ∈ {0, 1}, Z ∈ {0, 1, 2}. Suppose the distribution of (X, Y, Z) is Markov to:

Create a joint distribution f(x, y, z) that is Markov to this DAG. Generate 1000 random vectors from this distribution. Estimate the distribution from the data using maximum likelihood. Compare the estimated distribution to the true distribution. Let θ = (θ₀₀₀, θ₀₀₁,...,θ₁₁₂) where θrst = ℙ(X = r, Y = s, Z = t). Use the bootstrap to get standard errors and 95 percent confidence intervals for these 12 parameters.

7.

Consider the DAG in Figure 17.12.

(a)

Write down the factorization of the joint density.

(b)

Prove that X ∐ Zj

8.

Let V = (X, Y, Z) have the following joint distribution

(a)

Find an expression for ℙ(Z = z | Y = y). In particular, find ℙ(Z = 1 | Y = 1).

(b)

Write a program to simulate the model. Conduct a simulation and compute ℙ(Z = 1 | Y = 1) empirically. Plot this as a function of the simulation size N. It should converge to the theoretical value you computed in (a).

(c)

(Refers to material in the appendix.) Write down an expression for ℙ(Z = 1 | Y := y). In particular, find ℙ(Z = 1 | Y := 1).

(d)

(Refers to material in the appendix.) Modify your program to simulate the intervention “set Y = 1.” Conduct a simulation and compute ℙ(Z = 1 | Y := 1) empirically. Plot this as a function of the simulation size N. It should converge to the theoretical value you computed in (c).

9.

This is a continuous, Gaussian version of the last question. Let V = (X, Y, Z) have the following joint distribution

Here, α, β and γ are fixed parameters. economists refer to models like this as structural equation models.

(a)

Find an explicit expression for f(z | y) and .

(b)

(Refers to material in the appendix.) Find an explicit expression for f(z | Y := y) and then find . Compare to (b).

(c)

Find the joint distribution of (Y, Z). Find the correlation ρ between Y and Z.

(d)

(Refers to material in the appendix.) Suppose that X is not observed and we try to make causal conclusions from the marginal distribution of (Y, Z). (Think of X as unobserved confounding variables.) In particular, suppose we declare that Y causes Z if ρ ≠ 0 and we declare that Y does not cause Z if ρ = 0. Show that this will lead to erroneous conclusions.

(e)

(Refers to material in the appendix.) Suppose we conduct a randomized experiment in which Y is randomly assigned. To be concrete, suppose that

Show that the method in (d) now yields correct conclusions (i.e., ρ = 0 if and only if f(z | Y := y) does not depend on y).

¹

The last property requires the assumption that all events have positive probability; the first four do not.

²

We implicitly assume that ℙ is faithful to which means that ℙ has no extra independence relations other than those logically implied by the Markov Condition.

18
Undirected Graphs

Larry Wasserman1

(1)

Department of Statistics, Carnegie Mellon University, Baker Hall 228A, 15213-3890, Pittsburgh, PA, USA

Larry Wasserman

Email: larry@stat.cmu.edu

Undirected graphs are an alternative to directed graphs for representing independence relations. Since both directed and undirected graphs are used in practice, it is a good idea to be facile with both. The main difference between the two is that the rules for reading independence relations from the graph are different.

18.1 Undirected Graphs

An undirected graph = (V, E) has a finite set V of vertices (or nodes) and a set E of edges (or arcs) consisting of pairs of vertices. The vertices correspond to random variables X, Y, Z, ... and edges are written as unordered pairs. For example, (X, Y) ∈ E means that X and Y are joined by an edge. An example of a graph is in Figure 18.1.

Figure 18.1.

A graph with vertices V = {X, Y, Z}. The edge set is E = {(X, Y), (Y, Z)}.

Two vertices are adjacent, written X ∼ Y, if there is an edge between them. In Figure 18.1, X and Y are adjacent but X and Z are not adjacent. A sequence X₀,..., Xn is called a path if Xi−1 ∼ Xi for each i. In Figure 18.1, X, Y, Z is a path. A graph is complete if there is an edge between every pair of vertices. A subset U ⊂ V of vertices together with their edges is called a subgraph.

If A, B and C are three distinct subsets of V, we say that C separates A and B if every path from a variable in A to a variable in B intersects a variable in C. In Figure 18.2 {Y, W} and {Z} are separated by {X}. Also, W and Z are separated by {X, Y}.

Figure 18.2.

{Y, W} and {Z} are separated by {X}. Also, W and Z are separated by {X, Y}.

18.2 Probability and Graphs

Let V be a set of random variables with distribution ℙ. Construct a graph with one vertex for each random variable in V. Omit the edge between a pair of variables if they are independent given the rest of the variables:

where “rest” refers to all the other variables besides X and Y. The resulting graph is called a pairwise Markov graph. Some examples are shown in Figures 18.3, 18.4, 18.5, and 18.6.

Figure 18.3.

X ∐ Z|Y.

Figure 18.4.

No implied independence relations.

Figure 18.5.

X ∐ Z|{Y, W} and Y ∐ W|{X, Z}.

Figure 18.6.

Pairwise independence implies that X ∐ Z|{Y, W}. But is X ∐ Z|Y?

The graph encodes a set of pairwise conditional independence relations. These relations imply other conditional independence relations. How can we figure out what they are? Fortunately, we can read these other conditional independence relations directly from the graph as well, as is explained in the next theorem.

18.1 Theorem. Let = (V, E) be a pairwise Markov graph for a distribution ℙ. Let A, B and C be distinct subsets of V such that C separates A and B. Then A ∐ B|C.

18.2 Remark. If A and B are not connected (i.e., there is no path from A to B) then we may regard A and B as being separated by the empty set. Then Theorem 18.1 implies that A ∐ B.

The independence condition in Theorem 18.1 is called the global Markov property. We thus see that the pairwise and global Markov properties are equivalent. Let us state this more precisely. Given a graph , let Mpair() be the set of distributions which satisfy the pairwise Markov property: thus ℙ ∈ Mpair() if, under ℙ, X ∐ Y|rest if and only if there is no edge between X and Y. Let Mglobal() be the set of distributions which satisfy the global Markov property: thus ℙ ∈ Mpair() if, under ℙ, A ∐ B|C if and only if C separates A and B.

18.3 Theorem. Let be a graph. Then, Mpair() = Mglobal().

Theorem 18.3 allows us to construct graphs using the simpler pairwise property and then we can deduce other independence relations using the global Markov property. Think how hard this would be to do algebraically. Returning to 18.6, we now see that X ∐ Z|Y and Y ∐ W|Z.

18.4 Example. Figure 18.7 implies that X ∐ Y, X ∐ Z and X ∐ (Y, Z). ■

Figure 18.7.

X ∐ Y, X ∐ Z and X ∐ (Y, Z).

18.5 Example. Figure 18.8 implies that X ∐ W|(Y, Z) and X ∐ Z|Y. ■

Figure 18.8.

X ∐ W| (Y,Z) and X ∐ Z|Y.

18.3 Cliques and Potentials

A clique is a set of variables in a graph that are all adjacent to each other. A set of variables is a maximal clique if it is a clique and if it is not possible to include another variable and still be a clique. A potential is any positive function. Under certain conditions, it can be shown that ℙ is Markov if and only if its probability function f can be written as

(18.1)

where C is the set of maximal cliques and

18.6 Example. The maximal cliques for the graph in Figure 18.1 are C₁ = {X, Y} and C₂ = {Y, Z}. Hence, if ℙ is Markov to the graph, then its probability function can be written

for some positive functions ψ₁ and ψ₂. ■

18.7 Example. The maximal cliques for the graph in Figure 18.9 are

Figure 18.9.

The maximumly cliques of this graph are {X₁, X₂}, {X₁, X₃}, {X₂, X₄}, {X₃, X₅}, {X₂, X₅, X₆}.

Thus we can write the probability function as

■

18.4 Fitting Graphs to Data

Given a data set, how do we find a graphical model that fits the data? As with directed graphs, this is a big topic that we will not treat here. However, in the discrete case, one way to fit a graph to data is to use a log-linear model, which is the subject of the next chapter.

18.5 Bibliographic Remarks

Thorough treatments of undirected graphs can be found in Whittaker (1990) and Lauritzen (1996). Some of the exercises below are from Whittaker (1990).

18.6 Exercises

1.

Consider random variables (X₁, X₂, X₃). In each of the following cases, draw a graph that has the given independence relations.

(a)

X₁ ∐ X₃ | X₂.

(b)

X₁ ∐ X₂ | X₃ and X₁ ∐ X₃ | X₂.

(c)

X₁ ∐ X₂ | X₃ and X₁ ∐ X₃ | X₂ and X₂ ∐ X₃ | X₁.

2.

Consider random variables (X₁, X₂, X₃, X₄). In each of the following cases, draw a graph that has the given independence relations.

(a)

X₁ ∐ X₃ | X₂, X₄ and X₁ ∐ X₄ | X₂, X₃ and X₂ ∐ X₄ | X₁, X₃.

(b)

X₁ ∐ X₂ | X₃, X₄ and X₁ ∐ X₃ | X₂, X₄ and X₂ ∐ X₃ | X₁, X₄.

(c)

X₁ ∐ X₃ | X₂, X₄ and X₂ ∐ X₄ | X₁, X₃.

3.

A conditional independence between a pair of variables is minimal if it is not possible to use the Separation Theorem to eliminate any variable from the conditioning set, i.e. from the right hand side of the bar Whittaker (1990). Write down the minimal conditional independencies from: (a) Figure 18.10; (b) Figure 18.11; (c) Figure 18.12; (d) Figure 18.13.

Figure 18.10.

Figure 18.11.

Figure 18.12.

Figure 18.13.

4.

Let X₁, X₂, X₃ be binary random variables. Construct the likelihood ratio test for

5.

Here are breast cancer data from Morrison et al. (1973) on diagnostic center (X₁), nuclear grade (X₂), and survival (X₃):

(a)

Treat this as a multinomial and find the maximum likelihood estimator.

(b)

If someone has a tumor classified as benign at the Glamorgan clinic, what is the estimated probability that they will die? Find the standard error for this estimate.

(c)

Test the following hypotheses:

Use the test from question 4. Based on the results of your tests, draw and interpret the resulting graph.

19
Log-Linear Models

Larry Wasserman1

(1)

Department of Statistics, Carnegie Mellon University, Baker Hall 228A, 15213-3890, Pittsburgh, PA, USA

Larry Wasserman

Email: larry@stat.cmu.edu

In this chapter we study log-linear models which are useful for modeling multivariate discrete data. There is a strong connection between log-linear models and undirected graphs.

19.1 The Log-Linear Model

Let X = (X₁,..., Xm) be a discrete random vector with probability function

where x = (x₁,..., xm). Let rj be the number of values that Xj takes. Without loss of generality, we can assume that Xj ∈ {0, 1,..., rj − 1}. Suppose now that we have n such random vectors. We can think of the data as a sample from a Multinomial with N = r₁ × r₂ × ⋯ × rm categories. The data can be represented as counts in a r₁ × r₂ × ⋯ × rm table. Let p = (p₁,..., pN) denote the multinomial parameter.

Let S = {1,..., m}. Given a vector x = (x₁,..., xm) and a subset A ⊂ S, let xA = (xj : j ∈ A). For example, if A = {1, 3} then xA = (x₁, x₃).

19.1 Theorem. The joint probability function f(x) of a single random vector X = (X₁,..., Xm) can be written as

(19.1)

where the sum is over all subsets A of S = {1,..., m} and the ψ’s satisfy the following conditions:

1.

ψØ(x) is a constant;

2.

For every A ⊂ S, ψA(x) is only a function of xA and not the rest of the .

3.

If i ∈ A and xi = 0, then ψA(x) = 0.

The formula in equation (19.1) is called the log-linear expansion of f. Each ψA(x) may depend on some unknown parameters βA. Let β = (βA : A ⊂ S) be the set of all these parameters. We will write f(x) = f(x; β) when we want to emphasize the dependence on the unknown parameters β.

In terms of the multinomial, the parameter space is

This is an N − 1 dimensional space. In the log-linear representation, the parameter space is

where β(p) is the set of β values associated with p. The set Θ is a N − 1 dimensional surface in ℝN. We can always go back and forth between the two parameterizations we can write β = β(p) and p = p(β).

19.2 Example. Let X ∼ Bernoulli(p) where 0 < p < 1. We can write the probability mass function for X as

for x = 0, 1, where p₁ = p and p₂ = 1 − p. Hence,

where

Notice that ψØ(x) is a constant (as a function of x) and ψ₁(x) = 0 when x = 0. Thus the three conditions of Theorem 19.1 hold. The log-linear parameters are

The original, multinomial parameter space is 1}. The log-linear parameter space is

Given (p₁, p₂) we can solve for (β₀, β₁). Conversely, given (β₀, β₁) we can solve for (p₁, p₂). ■

19.3 Example. Let X = (X₁, X₂) where X₁ ∈ {0, 1} and X₂ ∈ {0, 1, 2}. The joint distribution of n such random vectors is a multinomial with 6 categories. The multinomial parameters can be written as a 2-by-3 table as follows:

The n data vectors can be summarized as counts:

For x = (x₁, x₂), the log-linear expansion takes the form

where

Convince yourself that the three conditions on the ψ’s of the theorem are satisfied. The six parameters of this model are:

■

The next theorem gives an easy way to check for conditional independence in a log-linear model.

19.4 Theorem. Let (Xa, Xb, Xc) be a partition of a vectors (X₁, ..., Xm). Then Xb ∐ Xc|Xa if and only if all the ψ-terms in the log-linear expansion that have at least one coordinate in b and one coordinate in c are 0.

To prove this theorem, we will use the following lemma whose proof follows easily from the definition of conditional independence.

19.5 Lemma. A partition (Xa, Xb, Xc) satisfies Xb ∐ Xc|Xa if and only if f(xa, xb, xe) = g(xa, xb)h(xa, xe) for some functions g and h

Proof. (Theorem 19.4.) Suppose that ψt is 0 whenever t has coordinates in b and c. Hence, ψt is 0 if t ⊄ a ∪ b or t ⊄ a ∪ c. Therefore

Exponentiating, we see that the joint density is of the form g(xa, xb)h(xa, xc). By Lemma 19.5, Xb ∐ Xc|Xa. The converse follows by reversing the argument. ■

19.2 Graphical Log-Linear Models

A log-linear model is graphical if missing terms correspond only to conditional independence constraints.

19.6 Definition. Let log f(x) = ∑A⊂S ψA(x) be a log-linear model. Then f is graphical if all ψ-terms are nonzero except for any pair of coordinates not in the edge set for some graph . In other words, ψA(x) = 0 if and only if {i, j} ⊂ A and (i, j) is not an edge.

Here is a way to think about the definition above:

If you can add a term to the model and the graph does not change, then the model is not graphical.

19.7 Example. Consider the graph in Figure 19.1.

FIGURE 19.1.

Graph for Example 19.7.

The graphical log-linear model that corresponds to this graph is

Let’s see why this model is graphical. The edge (1, 5) is missing in the graph. Hence any term containing that pair of indices is omitted from the model. For example,

are all omitted. Similarly, the edge (2, 4) is missing and hence

are all omitted. There are other missing edges as well. You can check that the model omits all the corresponding ψ terms. Now consider the model

This is the same model except that the three way interactions were removed. If we draw a graph for this model, we will get the same graph. For example, no ψ terms contain (1, 5) so we omit the edge between X₁ and X₅. But this is not graphical since it has extra terms omitted. The independencies and graphs for the two models are the same but the latter model has other constraints besides conditional independence constraints. This is not a bad thing. It just means that if we are only concerned about presence or absence of conditional independences, then we need not consider such a model. The presence of the three-way interaction ψ₂₃₅ means that the strength of association between X₂ and X₃ varies as a function of X₅. Its absence indicates that this is not so. ■

19.3 Hierarchical Log-Linear Models

There is a set of log-linear models that is larger than the set of graphical models and that are used quite a bit. These are the hierarchical log-linear models.

19.8 Definition. A log-linear model is hierarchical if ψA = 0 and A ⊂ B implies that ψB = 0.

19.9 Lemma. A graphical model is hierarchical but the reverse need not be true.

19.10 Example. Let

The model is hierarchical; its graph is given in Figure 19.2. The model is graphical because all terms involving (2,3) are omitted. It is also hierarchical. ■

FIGURE 19.2.

Graph for Example 19.10.

19.11 Example. Let

The model is hierarchical. It is not graphical. The graph corresponding to this model is complete; see Figure 19.3. It is not graphical because ψ₁₂₃(x) = 0 which does not correspond to any pairwise conditional independence. ■

FIGURE 19.3.

The graph is complete. The model is hierarchical but not graphical.

19.12 Example. Let

The graph corresponding is in Figure 19.4. This model is not hierarchical since ψ₂ = 0 but ψ₁₂ is not. Since it is not hierarchical, it is not graphical either. ■

FIGURE 19.4.

The model for this graph is not hierarchical.

19.4 Model Generators

Hierarchical models can be written succinctly using generators. This is most easily explained by example. Suppose that X = (X₁, X₂, X₃). Then, M = 1.2 + 1.3 stands for

The formula M = 1.2 + 1.3 says: “include ψ₁₂ and ψ₁₃.” We have to also include the lower order terms or it won’t be hierarchical. The generator M = 1.2.3 is the saturated model

The saturated models corresponds to fitting an unconstrained multinomial. Consider M = 1 + 2 + 3 which means

This is the mutual independence model. Finally, consider M = 1.2 which has log-linear expansion

This model makes X₃|X₂ = x₂, X₁ = x₁ a uniform distribution.

19.5 Fitting Log-Linear Models to Data

Let β denote all the parameters in a log-linear model M. The loglikelihood for β is

where f(Xi; β) is the probability function for the ith random vector Xi = (Xi1,..., Xim) as give by equation (19.1). The mle generally has to be found numerically. The Fisher information matrix is also found numerically and we can then get the estimated standard errors from the inverse Fisher information matrix.

When fitting log-linear models, one has to address the following model selection problem: which terms should we include in the model? This is essentially the same as the model selection problem in linear regression.

One approach is is to use AIC. Let M denote some log-linear model. Different models correspond to setting different ψ terms to 0. Now we choose the model M which maximizes

(19.2)

where |M| is the number of parameters in model M and is the value of the log-likelihood evaluated at the mle for that model. Usually the model search is restricted to hierarchical models. This reduces the search space. Some also claim that we should only search through the hierarchical models because other models are less interpretable.

A different approach is based on hypothesis testing. The model that includes all possible ψ-terms is called the saturated model and we denote it by Msat. Now for each M we test the hypothesis

The likelihood ratio test for this hypothesis is called the deviance.

19.13 Definition. For any submodel M, define the deviance dev(M) by

where is the log-likelihood of the saturated model evaluated at the mle and is the log-likelihood of the model M evaluated at its mle.

19.14 Theorem. The deviance is the likelihood ratio test statistic for

Under H₀, with ν degrees of freedom equal to the difference in the number of parameters between the saturated model and M.

One way to find a good model is to use the deviance to test every sub-model. Every model that is not rejected by this test is then considered a plausible model. However, this is not a good strategy for two reasons. First, we will end up doing many tests which means that there is ample opportunity for making Type I and Type II errors. Second, we will end up using models where we failed to reject H₀. But we might fail to reject H₀ due to low power. The result is that we end up with a bad model just due to low power.

After finding a “best model” this way we can draw the corresponding graph.

19.15 Example. The following breast cancer data are from Morrison et al. (1973). The data are on diagnostic center (X₁), nuclear grade (X₂), and survival (X₃):

The saturated log-linear model is:

The best sub-model, selected using AIC and backward searching is:

The graph for this model M is shown in Figure 19.5. To test the fit of this model, we compute the deviance of M which is 0.6. The appropriate χ² has 8 − 6 = 2 degrees of freedom. The p-value is . So we have no evidence to suggest that the model is a poor fit. ■

FIGURE 19.5.

The graph for Example 19.15.

19.6 Bibliographic Remarks

For this chapter, I drew heavily on Whittaker (1990) which is an excellent text on log-linear models and graphical models. Some of the exercises are from Whittaker. A classic reference on log-linear models is Bishop et al. (1975).

19.7 Exercises

1.

Solve for the in terms of the β’s in Example 19.3.

2.

Prove Lemma 19.5.

3.

Prove Lemma 19.9.

4.

Consider random variables (X₁, X₂, X₃, X₄). Suppose the log-density is

(a)

Draw the graph G for these variables.

(b)

Write down all independence and conditional independence relations implied by the graph.

(c)

Is this model graphical? Is it hierarchical?

5.

Suppose that parameters p(x₁, x₂, x₃) are proportional to the following values:

Find the ψ-terms for the log-linear expansion. Comment on the model.

6.

Let X₁,..., X₄ be binary. Draw the independence graphs corresponding to the following log-linear models. Also, identify whether each is graphical and/or hierarchical (or neither).

(a)

log f = 7 + 11x₁ + 2x₂ + 1.5x₃ + 17x₄

(b)

log f = 7 + 11x₁ + 2x₂ + 1.5x₃ + 17x₄ + 12x₂x₃ + 78x₂x₄ + 3x₃x₄ + 32x₂x₃x₄

(c)

log f = 7 + 11x₁ + 2x₂ + 1.5x₃ + 17x₄ + 12x₂x₃ + 3x₃x₄ + x₁x₄ + 2x₁x₂

(d)

log f = 7 + 5055x₁x₂x₃x₄

20
Nonparametric Curve Estimation

Larry Wasserman1

(1)

Department of Statistics, Carnegie Mellon University, Baker Hall 228A, 15213-3890, Pittsburgh, PA, USA

Larry Wasserman

Email: larry@stat.cmu.edu

In this Chapter we discuss nonparametric estimation of probability density functions and regression functions which we refer to as curve estimation or smoothing.

In Chapter 7 we saw that it is possible to consistently estimate a cumulative distribution function F without making any assumptions about F. If we want to estimate a probability density function f(x) or a regression function r(x) = (Y|X = x) the situation is different. We cannot estimate these functions consistently without making some smoothness assumptions. Correspondingly, we need to perform some sort of smoothing operation on the data.

An example of a density estimator is a histogram, which we discuss in detail in Section 20.2. To form a histogram estimator of a density f, we divide the real line to disjoint sets called bins. The histogram estimator is a piecewise constant function where the height of the function is proportional to number of observations in each bin; see Figure 20.3. The number of bins is an example of a smoothing parameter. If we smooth too much (large bins) we get a highly biased estimator while if we smooth too little (small bins) we get a highly variable estimator. Much of curve estimation is concerned with trying to optimally balance variance and bias.

FIGURE 20.3.

Three versions of a histogram for the astronomy data. The top left histogram has too few bins. The bottom left histogram has too many bins. The top right histogram is just right. The lower, right plot shows the estimated risk versus the number of bins.

20.1 The Bias-Variance Tradeoff

Let g denote an unknown function such as a density function or a regression function. Let denote an estimator of g. Bear in mind that is a random function evaluated at a point x. The estimator is random because it depends on the data. See Figure 20.1.

FIGURE 20.1.

A curve estimate is random because it is a function of the data. The point x at which we evaluate is not a random variable.

As a loss function, we will use the integrated squared error (ISE): ¹

(20.1)

The risk or mean integrated squared error (MISE) with respect to squared error loss is

(20.2)

20.1 Lemma. The risk can be written as

(20.3)

where

(20.4)

is the bias of at a fixed x and

(20.5)

is the variance of at a fixed x.

In summary,

(20.6)

When the data are oversmoothed, the bias term is large and the variance is small. When the data are undersmoothed the opposite is true; see Figure 20.2. This is called the bias-variance tradeoff. Minimizing risk corresponds to balancing bias and variance.

FIGURE 20.2.

The Bias-Variance trade-off. The bias increases and the variance decreases with the amount of smoothing. The optimal amount of smoothing, indicated by the vertical line, minimizes the risk = bias² + variance.

20.2 Histograms

Let X₁,..., Xn be iid on [0,1] with density f. The restriction to [0,1] is not crucial; we can always rescale the data to be on this interval. Let m be an integer and definebins

(20.7)

Define the binwidth h = 1/m, let vj be the number of observations in Bj, let and let pj = ∫Bj f(u)du.

The histogram estimator is defined by

which we can write more succinctly as

(20.8)

To understand the motivation for this estimator, let pj = ∫Bj f(u)du and note that, for x ∈ Bj and h small,

20.2 Example. Figure 20.3 shows three different histograms based on n = 1, 266 data points from an astronomical sky survey. Each data point represents the distance from us to a galaxy. The galaxies lie on a “pencilbeam” pointing directly from the Earth out into space. Because of the finite speed of light, looking at galaxies farther and farther away corresponds to looking back in time. Choosing the right number of bins involves finding a good tradeoff between bias and variance. We shall see later that the top left histogram has too few bins resulting in oversmoothing and too much bias. The bottom left histogram has too many bins resulting in undersmoothing and too few bins. The top right histogram is just right. The histogram reveals the presence of clusters of galaxies. Seeing how the size and number of galaxy clusters varies with time, helps cosmologists understand the evolution of the universe. ■

The mean and variance of are given in the following Theorem.

20.3 Theorem. Consider fixed x and fixed m, and let Bj be the bin containing x. Then,

(20.9)

Let’s take a closer look at the bias-variance tradeoff using equation (20.9). Consider some x ∈ Bj. For any other u ∈ Bj

and so

Therefore, the bias b(x) is

If is the center of the bin, then

Therefore,

Note that this increases as a function of h. Now consider the variance. For h small, 1 − pj ≈ 1, so

where we have kept only the dominant term. So,

Note that this decreases with h. Putting all this together, we get:

20.4 Theorem. Suppose that ∫(f′(u))²du < ∞. Then

(20.10)

The value h* that minimizes (20.10) is

(20.11)

With this choice of binwidth,

(20.12)

where C = (3/4)²/³(∫(f′(u))²du)1/3.

Theorem 20.4 is quite revealing. We see that with an optimally chosen binwidth, the MISE decreases to 0 at rate n−2/3. By comparison, most parametric estimators converge at rate n⁻¹. The slower rate of convergence is the price we pay for being nonparametric. The formula for the optimal binwidth h* is of theoretical interest but it is not useful in practice since it depends on the unknown function f.

A practical way to choose the binwidth is to estimate the risk function and minimize over h. Recall that the loss function, which we now write as a function of h, is

The last term does not depend on the binwidth h so minimizing the risk is equivalent to minimizing the expected value of

We shall refer to (J(h)) as the risk, although it differs from the true risk by the constant term ∫ f²(x)dx.

20.5 Definition. The cross-validation estimator of risk is

(20.13)

where is the histogram estimator obtained after removing the ith observation. We refer to as the cross-validation score or estimated risk.

20.6 Theorem. The cross-validation estimator is nearly unbiased:

In principle, we need to recompute the histogram n times to compute . Moreover, this has to be done for all values of h. Fortunately, there is a shortcut formula.

20.7 Theorem. The following identity holds:

(20.14)

20.8 Example. We used cross-validation in the astronomy example. The cross-validation function is quite flat near its minimum. Any m in the range of 73 to 310 is an approximate minimizer but the resulting histogram does not change much over this range. The histogram in the top right plot in Figure 20.3 was constructed using m = 73 bins. The bottom right plot shows the estimated risk, or more precisely, , plotted versus the number of bins. ■

Next we want a confidence set for f. Suppose is a histogram with m bins and binwidth h = 1/m. We cannot realistically make confidence statements about the fine details of the true density f. Instead, we shall make confidence statements about f at the resolution of the histogram. To this end, define

(20.15)

where pj = ∫ Bj f(u)du. Think of as a “histogramized” version of f.

20.9 Definition. A pair of functions (ℓn(x), un(x)) is a 1 − α confidence band (or confidence envelope) if

(20.16)

20.10 Theorem. Let m = m(n) be the number of bins in the histogram . Assume that m(n) → ∞ and m(n) log n/n → 0 as n → ∞. Define

(20.17)

where

(20.18)

Then, (ℓn(x), un(x)) is an approximate 1 − α confidence band.

Proof. Here is an outline of the proof. From the central limit theorem, N(pj, pj (1 − pj)/n). By the delta method, . Moreover, it can be shown that the are approximately independent. Therefore,

(20.19)

where Z₁,..., Zm ∼ N(0, 1). Let

Then,

■

20.11 Example. Figure 20.4 shows a 95 percent confidence envelope for the astronomy data. We see that even with over 1,000 data points, there is still substantial uncertainty. ■

FIGURE 20.4.

95 percent confidence envelope for astronomy data using m = 73 bins.

20.3 Kernel Density Estimation

Histograms are discontinuous. Kernel density estimators are smoother and they converge faster to the true density than histograms.

Let X₁,..., Xn denote the observed data, a sample from f. In this chapter, a kernel is defined to be any smooth function K such that K(x) ≥ 0, ∫ K(x)dx = 1, ∫ xK(x)dx = 0 and . Two examples of kernels are the Epanechnikov kernel

(20.20)

and the Gaussian (Normal) kernel K(x) = (2π)−1/2e−x²/2.

20.12 Definition. Given a kernel K and a positive number h, called the bandwidth, the kernel density estimator is defined to be

(20.21)

An example of a kernel density estimator is show in Figure 20.5. The kernel estimator effectively puts a smoothed-out lump of mass of size 1/n over each data point Xi. The bandwidth h controls the amount of smoothing. When h is close to 0, consists of a set of spikes, one at each data point. The height of the spikes tends to infinity as h → 0. When h → ∞, tends to a uniform density.

FIGURE 20.5.

A kernel density estimator . At each point x, is the average of the kernels centered over the data points Xi. The data points are indicated by short vertical bars.

20.13 Example. Figure 20.6 shows kernel density estimators for the astronomy data using three different bandwidths. In each case we used a Gaussian kernel. The properly smoothed kernel density estimator in the top right panel shows similar structure as the histogram. However, it is easier to see the dusters with the kernel estimator. ■

FIGURE 20.6.

Kernel density estimators and estimated risk for the astronomy data. Top left: oversmoothed. Top right: just right (bandwidth chosen by cross-validation). Bottom left: undersmoothed. Bottom right: cross-validation curve as a function of bandwidth h. The bandwidth was chosen to be the value of h where the curve is a minimum.

To construct a kernel density estimator, we need to choose a kernel K and a bandwidth h. It can be shown theoretically and empirically that the choice of K is not crucial.² However, the choice of bandwidth h is very important. As with the histogram, we can make a theoretical statement about how the risk of the estimator depends on the bandwidth.

20.14 Theorem. Under weak assumptions on f and K,

(20.22)

where . The optimal bandwidth is

(20.23)

where c₁ = ∫ x²K(x)dx, c₂ = ∫ K(x)²dx and c₃ = ∫(f″(x))²dx. With this choice of bandwidth,

for some constant c₄ > 0.

Proof. Write Kh (x, X) = h⁻¹K ((x − X)/h) and . Thus, and . Now,

since ∫ K(x) dx = 1 and ∫ x K(x) dx = 0. The bias is

By a similar calculation,

The result follows from integrating the squared bias plus the variance. ■

We see that kernel estimators converge at rate n−4/5 while histograms converge at the slower rate n−2/3. It can be shown that, under weak assumptions, there does not exist a nonparametric estimator that converges faster than n−4/5.

The expression for h* depends on the unknown density f which makes the result of little practical use. As with the histograms, we shall use cross-validation to find a bandwidth. Thus, we estimate the risk (up to a constant) by

(20.24)

where is the kernel density estimator after omitting the ith observation.

20.15 Theorem. For any h > 0,

Also,

(20.25)

where K*(x) = K⁽²⁾(x) − 2K(x) and K⁽²⁾(z) = ∫K(z − y)K(y)dy. In particular, if K is a N(0,1) Gaussian kernel then K⁽²⁾ (z) is the N(0,2) density.

We then choose the bandwidth hn that minimizes .³ A justification for this method is given by the following remarkable theorem due to Stone.

20.16 Theorem (Stone’s Theorem). Suppose that f is bounded. Let denote the kernel estimator with bandwidth h and let hn denote the bandwidth chosen by cross-validation. Then,

(20.26)

20.17 Example. The top right panel of Figure 20.6 is based on cross-validation. These data are rounded which problems for cross-validation. Specifically, it causes the minimizer to be h = 0. To overcome this problem, we added a small amount of random Normal noise to the data. The result is that is very smooth with a well defined minimum. ■

20.18 Remark. Do not assume that, if the estimator is wiggly, then cross-validation has let you down. The eye is not a good judge of risk.

To construct confidence bands, we use something similar to histograms. Again, the confidence band is for the smoothed version,

of the true density f.⁴ Assume the density is on an interval (a, b). The band is

(20.27)

where

where ω is the width of the kernel. In case the kernel does not have finite width then we take ω to be the effective width, that is, the range over which the kernel is non-negligible. In particular, we take ω = 3h for the Normal kernel.

20.19 Example. Figure 20.7 shows approximate 95 percent confidence bands for the astronomy data. ■

FIGURE 20.7.

95 percent confidence bands for kernel density estimate for the astronomy data.

Suppose now that the data Xi = (Xi1,..., Xid) are d-dimensional. The kernel estimator can easily be generalized to d dimensions. Let h = (h₁,..., hd) be a vector of bandwidths and define

(20.28)

where

(20.29)

where h₁,..., hd are bandwidths. For simplicity, we might take hj = sjh where sj is the standard deviation of the jth variable. There is now only a single bandwidth h to choose. Using calculations like those in the one-dimensional case, the risk is given by

where fjj is the second partial derivative of f. The optimal bandwidth satisfies hi ≈ c₁n−1/(4+d), leading to a risk of order n−4/(4+d). From this fact, we see that the risk increases quickly with dimension, a problem usually called the curse of dimensionality. To get a sense of how serious this problem is, consider the following table from Silverman (1986) which shows the sample size required to ensure a relative mean squared error less than 0.1 at 0 when the density is multivariate normal and the optimal bandwidth is selected:

Dimension

Sample Size

1

4

2

19

3

67

4

223

5

768

6

2790

7

10,700

8

43,700

9

187,000

10

842,000

This is bad news indeed. It says that having 842,000 observations in a tendimensional problem is really like having 4 observations in a one-dimensional problem.

20.4 Nonparametric Regression

Consider pairs of points (x₁, Y₁),..., (xn, Yn) related by

(20.30)

where (εi) = 0. We have written the xi’s in lower case since we will treat them as fixed. We can do this since, in regression, it is only the mean of Y conditional on x that we are interested in. We want to estimate the regression function r(x) = (Y|X = x).

There are many nonparametric regression estimators. Most involve estimating r(x) by taking some sort of weighted average of the Yi’s, giving higher weight to those points near x. A popular version is the Nadaraya-Watson kernel estimator.

20.20 Definition. The Nadaraya-Watson kernel estimator is defined by

(20.31)

where K is a kernel and the weights w i(x) are given by

(20.32)

The form of this estimator comes from first estimating the joint density f(x, y) using kernel density estimation and then inserting the estimate into the formula,

20.21 Theorem. Suppose that . The risk of the Nadaraya-Watson kernel estimator is

The optimal bandwidth decreases at rate n−1/5 and with this choice the risk decreases at rate n−4/5

In practice, to choose the bandwidth h we minimize the cross validation score

(20.34)

where is the estimator we get by omitting the ith variable. Fortunately, there is a shortcut formula for computing .

20.22 Theorem. can be written as

(20.35)

20.23 Example. Figures 20.8 shows cosmic microwave background (CMB) data from BOOMERaNG (Netterfield et al. (2002)), Maxima (Lee et al. (2001)), and DASI (Halverson et al. (2002))). The data consist of n pairs (x₁, Y₁),..., (xn, Yn) where xi is called the multipole moment and Yz is the estimated power spectrum of the temperature fluctuations. What you are seeing are sound waves in the cosmic microwave background radiation which is the heat, left over from the big bang. If r(x) denotes the true power spectrum, then

where εi is a random error with mean 0. The location and size of peaks in r(x) provides valuable clues about the behavior of the early universe. Figure 20.8 shows the fit based on cross-validation as well as an undersmoothed and oversmoothed fit. The cross-validation fit shows the presence of three well-defined peaks, as predicted by the physics of the big bang. ■

FIGURE 20.8.

Regression analysis of the CMB data. The first fit is undersmoothed, the second is oversmoothed, and the third is based on cross-validation. The last panel shows the estimated risk versus the bandwidth of the smoother. The data are from BOOMERaNG, Maxima, and DASI.

The procedure for finding confidence bands is similar to that for density estimation. However, we first need to estimate σ². Suppose that the xi’s are ordered. Assuming r(x) is smooth, we have r(xi+1 ) − r(xi) ≈ 0 and hence

and hence

We can thus use the average of the n − 1 differences Yi+1 − Yi to estimate σ². Hence, define

(20.36)

As with density estimate, the confidence band is for the smoothed version of the true regression function r.

Confidence Bands for Kernel Regression

An approximate 1 − α confidence band for is

(20.37)

where

is defined in (20.36) and ω is the width of the kernel. In case the kernel does not have finite width then we take ω to be the effective width, that is, the range over which the kernel is non-negligible. In particular, we take ω = 3h for the Normal kernel.

20.24 Example. Figure 20.9 shows a 95 percent confidence envelope for the CMB data. We see that we are highly confident of the existence and position of the first peak. We are more uncertain about the second and third peak. At the time of this writing, more accurate data are becoming available that apparently provide sharper estimates of the second and third peak. ■

FIGURE 20.9.

95 percent confidence envelope for the CMB data.

The extension to multiple regressors X = (X₁,..., Xp) is straightforward. As with kernel density estimation we just replace the kernel with a multivariate kernel. However, the same caveats about the curse of dimensionality apply. In some cases, we might consider putting some restrictions on the regression function which will then reduce the curse of dimensionality. For example, additive regression is based on the model

(20.38)

Now we only need to fit p one-dimensional functions. The model can be enriched by adding various interactions, for example,

(20.39)

Additive models are usually fit by an algorithm called backfitting.

Backfitting

1.

Initialize r₁(x₁),..., rp(xp).

2.

For j = 1,..., p:

(a)

Let εi = Yi − ∑s≠jrs(xi).

(b)

Let rj be the function estimate obtained by regressing the εi’s on the jth covariate.

3.

If converged STOP. Else, go back to step 2.

Additive models have the advantage that they avoid the curse of dimensionality and they can be fit quickly, but they have one disadvantage: the model is not fully nonparametric. In other words, the true regression function r(x) may not be of the form (20.38).

20.5 Appendix

Confidence Sets and Bias. The confidence bands we computed are not for the density function or regression function but rather for the smoothed function. For example, the confidence band for a kernel density estimate with bandwidth h is a band for the function one gets by smoothing the true function with a kernel with the same bandwidth. Getting a confidence set for the true function is complicated for reasons we now explain.

Let denote an estimate of the function f(x). Denote the mean and standard deviation of by and sn(x). Then,

Typically, the first term converges to a standard Normal from which one derives confidence bands. The second term is the bias divided by the standard deviation. In parametric inference, the bias is usually smaller than the standard deviation of the estimator so this term goes to 0 as the sample size increases. In nonparametric inference, optimal smoothing leads us to balance the bias and the standard deviation. Thus the second term does not vanish even with large sample sizes. This means that the confidence interval will not be centered around the true function f.

20.6 Bibliographic Remarks

Two very good books on density estimation are Scott (1992) and Silverman (1986). The literature on nonparametric regression is very large. Two good starting points are Hardle (1990) and Loader (1999). The latter emphasizes a class of techniques called local likelihood methods.

20.7 Exercises

1.

Let X₁,..., Xn ∼ f and let be the kernel density estimator using the boxcar kernel:

(a)

Show that

and

(b)

Show that if h → 0 and nh → ∞ as n → ∞, then .

2.

Get the data on fragments of glass collected in forensic work from the book website. Estimate the density of the first variable (refractive index) using a histogram and use a kernel density estimator. Use cross-validation to choose the amount of smoothing. Experiment with different binwidths and bandwidths. Comment on the similarities and differences. Construct 95 percent confidence bands for your estimators.

3.

Consider the data from question 2. Let Y be refractive index and let x be aluminum content (the fourth variable). Perform a nonparametric regression to fit the model Y = f(x) + ε. Use cross-validation to estimate the bandwidth. Construct 95 percent confidence bands for your estimate.

4.

Prove Lemma 20.1.

5.

Prove Theorem 20.3.

6.

Prove Theorem 20.7.

7.

Prove Theorem 20.15.

8.

Consider regression data (x₁, Y₁),..., (xn, Yn). Suppose that 0 ≤ xi ≤ 1 for all i. Define bins Bj as in equation (20.7). For x ∈ Bj define

where is the mean of all the Yi’s corresponding to those xi’s in Bj. Find the approximate risk of this estimator. From this expression for the risk, find the optimal bandwidth. At what rate does the risk go to zero?

9.

Show that with suitable smoothness assumptions on r(x), in equation (20.36) is a consistent estimator of σ².

10.

Prove Theorem 20.22.

¹

We could use other loss functions. The results are similar but the analysis is much more complicated.

²

It can be shown that the Epanechnikov kernel is optimal in the sense of giving smallest asymptotic mean squared error, but it is really the choice of bandwidth which is crucial.

³

For large data sets, and (20.25) can be computed quickly using the fast Fourier transform.

⁴

This is a modified version of the band described in Chaudhuri and Marron (1999).

21
Smoothing Using Orthogonal Functions

Larry Wasserman1

(1)

Department of Statistics, Carnegie Mellon University, Baker Hall 228A, 15213-3890, Pittsburgh, PA, USA

Larry Wasserman

Email: larry@stat.cmu.edu

In this chapter we will study an approach to nonparametric curve estimation based on orthogonal functions. We begin with a brief introduction to the theory of orthogonal functions, then we turn to density estimation and regression.

21.1 Orthogonal Functions and L₂ Spaces

Let v = (vi, v₂, v₃) denote a three-dimensional vector, that is, a list of three real numbers. Let denote the set of all such vectors. If a is a scalar (a number) and v is a vector, we define av = (av₁, av₂, av₃). The sum of vectors v and w is defined by v + w = (v₁ + w₁, v₂ + w₂, v₃ + w₃). The inner product between two vectors v and w is defined by . The norm (or length) of a vector v is defined by

(21.1)

Two vectors are orthogonal (or perpendicular) if 〈v, w〉 = 0. A set of vectors are orthogonal if each pair in the set is orthogonal. A vector is normal if ‖v‖ = 1.

Let ϕ₁ = (1, 0, 0), ϕ₂ = (0, 1, 0), ϕ₃ = (0, 0, 1). These vectors are said to be an orthonormal basis for since they have the following properties:

(i)

they are orthogonal;

(ii)

they are normal;

(iii)

they form a basis for , which means that any v ∈ can be written as a linear combination of ϕ₁, ϕ₂, ϕ₃:

(21.2)

For example, if v = (12, 3, 4) then v = 12ϕ₁ + 3ϕ₂ + 4ϕ₃. There are other orthonormal bases for , for example,

You can check that these three vectors also form an orthonormal basis for . Again, if v is any vector then we can write

For example, if v = (12, 3, 4) then

Now we make the leap from vectors to functions. Basically, we just replace vectors with functions and sums with integrals. Let L₂(a, b) denote all functions defined on the interval [a, b] such that

(21.3)

We sometimes write L₂ instead of L₂(a, b). The inner product between two functions f, g ∈ L₂ is defined by ∫ f(x)g(x)dx. The norm of f is

(21.4)

Two functions are orthogonal if ∫ f(x)g(x)dx = 0. A function is normal if ‖f‖ = 1.

A sequence of functions ϕ₁, ϕ₂, ϕ₃, ... is orthonormal if for each j and ∫ ϕi (x)ϕj(x)dx = 0 for i ≠ j. An orthonormal sequence is complete if the only function that is orthogonal to each ϕj is the zero function. In this case, the functions ϕ₁, ϕ₂, ϕ₃, ... form in basis, meaning that if f ∈ L₂ then f can be written as¹

(21.5)

A useful result is Parseval’s relation which says that

(21.6)

where β = (β₁, β₂, ...).

21.1 Example. An example of an orthonormal basis for L₂(0, 1) is the cosine basis defined as follows. Let ϕ₀(x) = 1 and for j ≥ 1 define

(21.7)

The first six functions are plotted in Figure 21.1. ■

FIGURE 21.1.

The first six functions in the cosine basis.

21.2 Example. Let

which is called the “doppler function.” Figure 21.2 shows f (top left) and its approximation

with J equal to 5 (top right), 20 (bottom left), and 200 (bottom right). As J increases we see that fJ(x) gets closer to f(x). The coefficients βj = were computed numerically. ■

FIGURE 21.2.

Approximating the doppler function with its expansion in the cosine basis. The function f (top left) and its approximation with J equal to 5 (top right), 20 (bottom left), and 200 (bottom right). The coefficients were computed numerically.

21.3 Example. The Legendre polynomials on [−1, 1] are defined by

(21.8)

It can be shown that these functions are complete and orthogonal and that

(21.9)

It follows that the functions , j = 0, 1, ... form an orthonormal basis for L₂ (−1, 1). The first few Legendre polynomials are:

These polynomials may be constructed explicitly using the following recursive relation.

(21.10)

The coefficients β₁, β₂, ... are related to the smoothness of the function f. To see why, note that if f is smooth, then its derivatives will be finite. Thus we expect that, for some k, where f(k) is the kth derivative of f. Now consider the cosine basis (21.7) and let . Then,

The only way that can be finite is if the βj’s get small when j gets large. To summarize:

If the function f is smooth, then the coefficients βj will be small when j is large.

For the rest of this chapter, assume we are using the cosine basis unless otherwise specified.

21.2 Density Estimation

Let X₁, ..., Xn, be iid observations from a distribution on [0, 1] with density f. Assuming f ∈ L₂ we can write

where ϕ₁, ϕ₂, ... is an orthonormal basis. Define

(21.11)

21.4 Theorem. The mean and variance of are

(21.12)

where

(21.13)

Proof. The mean is

The calculation for the variance is similar. ■

Hence, is an unbiased estimate of βj. It is tempting to estimate f by but this turns out to have a very high variance. Instead, consider the estimator

(21.14)

The number of terms J is a smoothing parameter. Increasing J will decrease bias while increasing variance. For technical reasons, we restrict J to lie in the range

where . To emphasize the dependence of the risk function on J, we write the risk function as R(J).

21.5 Theorem. The risk of is

(21.15)

An estimate of the risk is

(21.16)

where a₊ = max {a, 0} and

(21.17)

To motivate this estimator, note that is an unbiased estimate of and is an unbiased estimator of . We take the positive part of the latter term since we know that cannot be negative. We now choose to minimize . Here is a summary:

Summary of Orthogonal Function Density Estimation

1.

Let

(21.17)

2.

Choose to minimize over where is given in equation (21.16).

3.

Let

The estimator can be negative. If we are interested in exploring the shape of f, this is not a problem. However, if we need our estimate to be a probability density function, we can truncate the estimate and then normalize it. That is, we take .

Now let us construct a confidence band for f. Suppose we estimate f using J orthogonal functions. We are essentially estimating not the true density . Thus, the confidence band should be regarded as a band for fJ(x).

21.6 Theorem. An approximate 1 − α confidence band for fJ is (ℓ(x), u(x)) where

(21.18)

where

(21.19)

and

For the cosine basis, .

Proof. Here is an outline of the proof. Let . By the central limit theorem, . Hence where εj ∼ N (0, 1), and therefore

(21.20)

Thus we have, approximately, that

Also,

where the third inequality is from the Cauchy-Schwartz inequality (Theorem 4.8). So,

21.7 Example. Let

where ϕ(x; μ, σ) denotes a Normal density with mean μ and standard deviation σ, and (μ₁, ..., μ₅) = (−1, −1/2, 0, 1/2, 1). Marron and Wand (1992) call this “the claw” although the “Bart Simpson” might be more appropriate. Figure 21.3 shows the true density as well as the estimated density based on n = 5, 000 observations and a 95 percent confidence band. The density has been rescaled to have most of its mass between 0 and 1 using the transformation y = (x + 3)/6. ■

FIGURE 21.3.

The top plot is the true density for the Bart Simpson distribution (rescaled to have most of its mass between 0 and 1). The bottom plot is the orthogonal function density estimate and 95 percent confidence band.

21.3 Regression

Consider the regression model

(21.21)

where the εi are independent with mean 0 and variance σ². We will initially focus on the special case where x₂ = i/n. We assume that r ∈ L₂ (0, 1) and hence we can write

(21.22)

where ϕ₁, ϕ₂, ... where is an orthonormal basis for [0,1].

Define

(21.23)

Since is an average, the central limit theorem tells us that will be approximately Normally distributed.

21.8 Theorem.

(21.24)

Proof. The mean of is

where the approximate equality follows from the definition of a Riemann integral: where △n = 1/n. The variance is

since . ■

Let

and let

be the risk of the estimator.

21.9 Theorem. The risk R(J) of the estimator is

(21.25)

To estimate for we use

(21.26)

where k = n/4. To motivate this estimator, recall that if f is smooth, then βj ≈ 0 for large j. So, for and thus, for for j ≥ k, where Zj ∼ N (0, 1). Therefore,

since a sum of k Normals has a distribution. Now and hence . Also, and hence as n → ∞. Thus we expect to be a consistent estimator of σ². There is nothing special about the choice k = n/4. Any k that increases with n at an appropriate rate will suffice.

We estimate the risk with

(21.27)

21.10 Example. Figure 21.4 shows the doppler function f and n = 2,048 observations generated from the model

where xi = i/n, εi ∼N (0, (.1)²). The figure shows the data and the estimated function. The estimate was based on terms. ■

FIGURE 21.4.

Data from the doppler test function and the estimated function. See Example 21.10.

We are now ready to give a complete description of the method.

Orthogonal Series Regression Estimator

1.

Let

2.

Let

(21.28)

where k ≈ n/4.

3.

For 1 ≤ J ≤ n, compute the risk estimate

4.

Choose to minimize .

5.

Let

Finally, we turn to confidence bands. As before, these bands are not really for the true function r(x) but rather for the smoothed version of the function .

21.11 Theorem. Suppose the estimate is based on J terms and is defined as in equation (21.28). Assume that J < n − k + 1. An approximate 1 − α confidence band for rJ is (ℓ, u) where

(21.29)

where

and is given in equation (21.28).

Proof. Let . By the central limit theorem, N(βj, σ²/n). Hence, where εj ∼ N (0, 1) and therefore

Thus,

Also,

by the Cauchy-Schwartz inequality (Theorem 4.8). So,

and the result follows. ■

21.12 Example. Figure 21.5 shows the confidence envelope for the doppler signal. The first plot is based on J = 234 (the value of J that minimizes the estimated risk). The second is based on . Larger J yields a higher resolution estimator at the cost of large confidence bands. Smaller J yields a lower resolution estimator but has tighter confidence bands. ■

FIGURE 21.5.

Estimates and confidence bands for the doppler test function using n = 2, 048 observations. First plot: J = 234 terms. Second plot: J = 45 terms.

So far, we have assumed that the xi’s are of the form {1/n, 2/n, ..., 1}. If the xi’s are on interval [a, b], then we can rescale them so that are in the interval [0, 1]. If the xi’s are not equally spaced, the methods we have discussed still apply so long as the xi’s “fill out” the interval [0,1] in such a way so as to not be too clumped together. If we want to treat the xi’s as random instead of fixed, then the method needs significant modifications which we shall not deal with here.

21.4 Wavelets

Suppose there is a sharp jump in a regression function f at some point x but that f is otherwise very smooth. Such a function f is said to be spatially inhomogeneous. The doppler function is an example of a spatially inhomogeneous function; it is smooth for large x and unsmooth for small x.

It is hard to estimate f using the methods we have discussed so far. If we use a cosine basis and only keep low order terms, we will miss the peak; if we allow higher order terms we will find the peak but we will make the rest of the curve very wiggly. Similar comments apply to kernel regression. If we use a large bandwidth, then we will smooth out the peak; if we use a small bandwidth, then we will find the peak but we will make the rest of the curve very wiggly.

One way to estimate inhomogeneous functions is to use a more carefully chosen basis that allows us to place a “blip” in some small region without adding wiggles elsewhere. In this section, we describe a special class of bases called wavelets, that are aimed at fixing this problem. Statistical inference using wavelets is a large and active area. We will just discuss a few of the main ideas to get a flavor of this approach.

We start with a particular wavelet called the Haar wavelet. The Haar father wavelet or Haar scaling function is defined by

(21.30)

The mother Haar wavelet is defined by

(21.31)

For any integers j and k define

(21.32)

The function ψj, k has the same shape as ψ but it has been rescaled by a factor of 2j/2 and shifted by a factor of k.

See Figure 21.6 for some examples of Haar wavelets. Notice that for large j, ψj, k is a very localized function. This makes it possible to add a blip to a function in one place without adding wiggles elsewhere. Increasing j is like looking in a microscope at increasing degrees of resolution. In technical terms, we say that wavelets provide a multiresolution analysis of L₂(0,1).

FIGURE 21.6.

Some Haar wavelets. Left: the mother wavelet ψ(x); Right: ψ2, 2 (x).

Let

be the set of rescaled and shifted mother wavelets at resolution j.

21.13 Theorem. The set of functions

is an orthonormal basis for L ₂ (0, 1).

It follows from this theorem that we can expand any function f ∈ L₂ (0, 1) in this basis. Because each Wj is itself a set of functions, we write the expansion as a double sum:

(21.33)

where

We call α the scaling coefficient and the βj,k’s are called the detail coefficients. We call the finite sum

(21.34)

the resolution J approximation to f. The total number of terms in this sum is

21.14 Example. Figure 21.7 shows the doppler signal, and its reconstruction using J = 3, 5 and J = 8. ■

FIGURE 21.7.

The doppler signal and its reconstruction based on J = 3, J = 5, and J = 8.

Haar wavelets are localized, meaning that they are zero outside an interval. But they are not smooth. This raises the question of whether there exist smooth, localized wavelets that from an orthonormal basis. In 1988, Ingrid Daubechie showed that such wavelets do exist. These smooth wavelets are difficult to describe. They can be constructed numerically but there is no closed form formula for the smoother wavelets. To keep things simple, we will continue to use Haar wavelets.

Consider the regression model Yi = r(xi) + σεi where εi ∼ N (0, 1) and xi = i/n. To simplify the discussion we assume that n = 2J for some J.

There is one major difference between estimation using wavelets instead of a cosine (or polynomial) basis. With the cosine basis, we used all the terms 1 ≤ j ≤ J for some J. The number of terms J acted as a smoothing parameter. With wavelets, we control smoothing using a method called thresholding where we keep a term in the function approximation if its coefficient is large, otherwise, we throw out that term. There are many versions of thresholding. The simplest is called hard, universal thresholding. Let J = log₂ (n) and define

(21.35)

for 0 ≤ j ≤ J − 1.

Haar Wavelet Regression

1.

Compute and Dj,k as in (21.35), for 0 ≤ j ≤ J − 1.

2.

Estimate σ; see (21.37).

3.

Apply universal thresholding:

(21.36)

4.

Set .

In practice, we do not compute Sk and Dj,k using (21.35). Instead, we use the discrete wavelet transform (DWT) which is very fast. The DWT for Haar wavelets is described in the appendix. The estimate of σ is

(21.37)

The estimate for σ may look strange. It is similar to the estimate we used for the cosine basis but it is designed to be insensitive to sharp peaks in the function.

To understand the intuition behind universal thresholding, consider what happens when there is no signal, that is, when βj,k = 0 for all j and k.

21.15 Theorem. Suppose that βj,k = 0 for all j and k and let k be the universal threshold estimator. Then

as n → ∞.

Proof. To simplify the proof, assume that σ is known. Now Dj,k ≈ N (0, σ²/n). We will need Mill’s inequality (Theorem 4.7): if Z ∼ N (0, 1) then where is a constant. Thus,

21.16 Example. Consider Yi = r(xi) + σεi where f is the doppler signal, σ = .1 and n = 2,048. Figure 21.8 shows the data and the estimated function using universal thresholding. Of course, the estimate is not smooth since Haar wavelets are not smooth. Nonetheless, the estimate is quite accurate. ■

FIGURE 21.8.

Estimate of the Doppler function using Haar wavelets and universal thresholding.

21.5 Appendix

The DWT for Haar Wavelets. Let y be the vector of Yi’s (length n) and let J = log₂ (n). Create a list D with elements

Set:

Then do:

21.6 Bibliographic Remarks

Efromovich (1999) is a reference for orthogonal function methods. See also Beran (2000) and Beran and Dümbgen (1998). An introduction to wavelets is given in Ogden (1997). A more advanced treatment can be found in Härdle et al. (1998). The theory of statistical estimation using wavelets has been developed by many authors, especially David Donoho and Ian Johnstone. See Donoho and Johnstone (1994), Donoho and Johnstone (1995), Donoho et al. (1995), and Donoho and Johnstone (1998).

21.7 Exercises

1.

Prove Theorem 21.5.

2.

Prove Theorem 21.9.

3.

Let

Show that these vectors have norm 1 and are orthogonal.

4.

Prove Parseval’s relation equation (21.6).

5.

Plot the first five Legendre polynomials. Verify, numerically, that they are orthonormal.

6.

Expand the following functions in the cosine basis on [0, 1]. For (a) and (b), find the coefficients βj analytically. For (c) and (d), find the coefficients βj numerically, i.e.

for some large integer N. Then plot the partial sum for increasing values of n.

(a)

(b)

f(x) = sin(πx).

(c)

where K(t) = (1 + sign(t))/2, sign(x) = − 1 if x < 0, sign(x) = 0 if x = 0, sign(x) = 1 if x > 0,

(tj) = (.1, .13, .15, .23, .25, .40, .44, .65, .76, .78, .81),

(hj) = (4, −5, 3, −4, 5, −4.2, 2.1, 4.3, −3.1, 2.1, −4.2).

(d)

7.

Consider the glass fragments data from the book’s website. Let Y be refractive index and let X be aluminum content (the fourth variable).

(a)

Do a nonparametric regression to fit the model Y = f(x) + ε using the cosine basis method. The data are not on a regular grid. Ignore this when estimating the function. (But do sort the data first according to x.) Provide a function estimate, an estimate of the risk, and a confidence band.

(b)

Use the wavelet method to estimate f.

8.

Show that the Haar wavelets are orthonormal.

9.

Consider again the doppler signal:

Let n = 1,024, σ = 0.1, and let (x₁, ..., xn) = (1/n, ..., 1). Generate data

where εi ∼ N (0, 1).

(a)

Fit the curve using the cosine basis method. Plot the function estimate and confidence band for J = 10, 20, ..., 100.

(b)

Use Haar wavelets to fit the curve.

10.

(Haar density Estimation.) Let X₁, ..., Xn ∼ f for some density f on [0,1]. Let’s consider constructing a wavelet histogram. Let and be the Haar father and mother wavelet. Write

where J ≈ log₂ (n). Let

(a)

Show that is an unbiased estimate of βj, k.

(b)

Define the Haar histogram

for 0 ≤ B ≤ J − 1.

(c)

Find an approximate expression for the MSE as a function of B.

(d)

Generate n = 1,000 observations from a Beta (15,4) density. Estimate the density using the Haar histogram. Use leave-one-out cross validation to choose B.

11.

In this question, we will explore the motivation for equation (21.37). Let X₁, ..., Xn ∼ N (0, σ²). Let

(a)

Show that .

(b)

Simulate n = 100 observations from a N(0,1) distribution. Compute as well as the usual estimate of σ. Repeat 1,000 times and compare the MSE.

(c)

Repeat (b) but add some outliers to the data. To do this, simulate each observation from a N(0,1) with probability .95 and simulate each observation from a N(0,10) with probability .95.

12.

Repeat question 6 using the Haar basis.

¹

The equality in the displayed equation means that ∫(f(x) − fn(x))² dx → 0 where fn = .

22
Classification

Larry Wasserman1

(1)

Department of Statistics, Carnegie Mellon University, Baker Hall 228A, 15213-3890, Pittsburgh, PA, USA

Larry Wasserman

Email: larry@stat.cmu.edu

22.1 Introduction

The problem of predicting a discrete random variable Y from another random variable X is called classification, supervised learning, discrimination, or pattern recognition.

Consider iid data (X₁, Y₁),..., (Xn, Yn) where

is a d-dimensional vector and Yi takes values in some finite set . A classification rule is a function . When we observe a new X, we predict Y to be h(X).

22.1 Example. Here is a an example with fake data. Figure 22.1 shows 100 data points. The covariate X = (X₁, X₂) is 2-dimensional and the outcome . The Y values are indicated on the plot with the triangles representing Y = 1 and the squares representing Y = 0. Also shown is a linear classification rule represented by the solid line. This is a rule of the form

FIGURE 22.1.

Two covariates and a linear decision boundary. △ means Y = 1. □ means Y = 0. These two groups are perfectly separated by the linear decision boundary; you probably won’t see real data like this.

Everything above the line is classified as a 0 and everything below the line is classified as a 1. ■

22.2 Example. Recall the the Coronary Risk-Factor Study (CORIS) data from Example 13.17. There are 462 males between the ages of 15 and 64 from three rural areas in South Africa. The outcome Y is the presence (Y = 1) or absence (Y = 0) of coronary heart disease and there are 9 covariates: systolic blood pressure, cumulative tobacco (kg), ldl (low density lipoprotein cholesterol), adiposity, famhist (family history of heart disease), typea (type-A behavior), obesity, alcohol (current alcohol consumption), and age. I computed a linear decision boundary using the LDA method based on two of the covariates, systolic blood pressure and tobacco consumption. The LDA method will be explained shortly. In this example, the groups are hard to tell apart. In fact, 141 of the 462 subjects are misclassified using this classification rule. ■

At this point, it is worth revisiting the Statistics/Data Mining dictionary:

Statistics

Computer Science

Meaning

classification

supervised learning

predicting a discrete Y from X

data

training sample

(X₁, Y₁),..., (Xn, Yn)

covariates

features

the Xi’s

classifier

hypothesis

map

estimation

learning

finding a good classifier

22.2 Error Rates and the Bayes Classifier

Our goal is to find a classification rule h that makes accurate predictions. We start with the following definitions:

22.3 Definition. The true error rate¹ of a classifier h is

(22.1)

and the empirical error rate or training error rate is

(22.2)

First we consider the special case where . Let

denote the regression function. From Bayes’ theorem we have that

(22.3)

where

22.4 Definition. The Bayes classification rule h* is

(22.4)

The set is called the decision boundary.

Warning! The Bayes rule has nothing to do with Bayesian inference. We could estimate the Bayes rule using either frequentist or Bayesian methods.

The Bayes rule may be written in several equivalent forms:

(22.5)

and

(22.6)

22.5 Theorem. The Bayes rule is optimal, that is, if h is any other classification rule then L(h*) ≤ L(h).

The Bayes rule depends on unknown quantities so we need to use the data to find some approximation to the Bayes rule. At the risk of oversimplifying, there are three main approaches:

1.

Empirical Risk Minimization. Choose a set of classifiers and find that minimizes some estimate of L(h).

2.

Regression. Find an estimate of the regression function r and define

3.

Density Estimation. Estimate f₀ from the Xi’s for which Yi = 0, estimate f₁ from the Xi’s for which Yi = 1 and let Define

and

Now let us generalize to the case where Y takes on more than two values as follows.

22.6 Theorem. Suppose that Y ∈ = {1,..., K}. The optimal rule is

(22.7)

(22.8)

where

(22.9)

πr = P(Y = r), fr(x) = f(x|Y = r) and argmaxk means “the value of k that maximizes that expression.”

22.3 Gaussian and Linear Classifiers

Perhaps the simplest approach to classification is to use the density estimation strategy and assume a parametric model for the densities. Suppose that and that f₀(x) = f(x|Y = 0) and f₁(x) = f(x|Y = 1) are both multivariate Gaussians:

Thus, X|Y = 0 ∼ N(μ₀, Σ₀) and X|Y = 1 ∼N(μ₁, Σ₁).

22.7 Theorem. If X|Y = 0 ∼ N(μ₀, Σ₀) and X|Y = 1 ∼ N(μ₁, Σ₁), then the Bayes rule is

(22.10)

where

(22.11)

is the Manalahobis distance. An equivalent way of expressing the Bayes’ rule is

where

(22.12)

and |A| denotes the determinant of a matrix A.

The decision boundary of the above classifier is quadratic so this procedure is called quadratic discriminant analysis (QDA). In practice, we use sample estimates of π, μ₁, μ₂, Σ₀, Σ₁ in place of the true value, namely:

where n₀ = ∑i(1 − Yi) and n₁ = ∑i Yi.

A simplification occurs if we assume that Σ₀ = Σ₀ = Σ. In that case, the Bayes rule is

(22.13)

where now

(22.14)

The parameters are estimated as before, except that the mle of Σ is

The classification rule is

(22.15)

where

is called the discriminant function. The decision boundary {x : δ₀(x) = δ₁(x)} is linear so this method is called linear discrimination analysis (LDA).

22.8 Example. Let us return to the South African heart disease data. The decision rule in in Example 22.2 was obtained by linear discrimination. The outcome was

The observed misclassification rate is 141/462 = .31. Including all the covariates reduces the error rate to .27. The results from quadratic discrimination are

which has about the same error rate 143/462 = .31. Including all the covariates reduces the error rate to .26. In this example, there is little advantage to QDA over LDA. ■

Now we generalize to the case where Y takes on more than two values.

22.9 Theorem. Suppose that Y ∈ {1,..., K}. If fk(x) = f(x|Y = k) is Gaussian, the Bayes rule is

where

(22.16)

If the variances of the Gaussians are equal, then

(22.17)

We estimate δk(x) by by inserting estimates of μk, Σk and πk. There is another version of linear discriminant analysis due to Fisher. The idea is to first reduce the dimension of covariates to one dimension by projecting the data onto a line. Algebraically, this means replacing the covariate X = (X₁,..., Xd) with a linear combination . The goal is to choose the vector w = (w₁,..., wd) that “best separates the data.” Then we perform classification with the one-dimensional covariate Z instead of X.

We need define what we mean by separation of the groups. We would like the two groups to have means that are far apart relative to their spread. Let μj denote the mean of X for Yj and let Σ be the variance matrix of X. Then ². Define the separation by

We estimate J as follows. Let be the number of observations in group j, let be the sample mean vector of the X’s for group j, and let Sj be the sample covariance matrix in group j. Define

(22.18)

where

22.10 Theorem. The vector

(22.19)

is a minimizer of . We call

(22.20)

the Fisher linear discriminant function. The midpoint m between and is

(22.21)

Fisher’s classification rule is

Fisher’s rule is the same as the Bayes linear classifier in equation (22.14) when

22.4 Linear Regression and Logistic Regression

A more direct approach to classification is to estimate the regression function without bothering to estimate the densities fk. For the rest of this section, we will only consider the case where . Thus, and once we have an estimate we will use the classification rule

(22.22)

The simplest regression model is the linear regression model

(22.23)

where This model can’t be correct since it does not force Y = 0 or 1. Nonetheless, it can sometimes lead to a decent classifier.

Recall that the least squares estimate of β = (β₀, β₁,..., βd)T minimizes the residual sums of squares

Let X denote the N × (d + 1) matrix of the form

Also let Y = (Y₁,..., Yn)T. Then,

and the model can be written as

where ϵ = (ϵ₁,..., ϵn)T. From Theorem 13.13,

The predicted values are

Now we use (22.22) to classify, where

An alternative is to use logistic regression which was also discussed in Chapter 13. The model is

(22.24)

and the mle is obtained numerically.

22.11 Example. Let us return to the heart disease data. The mle is given in Example 13.17. The error rate, using this model for classification, is .27. The error rate from a linear regression is .26.

We can get a better classifier by fitting a richer model. For example, we could fit

(22.25)

More generally, we could add terms of up to order r for some integer r. Large values of r give a more complicated model which should fit the data better. But there is a bias-variance tradeoff which we’ll discuss later.

22.12 Example. If we use model (22.25) for the heart disease data with r = 2, the error rate is reduced to .22. ■

22.5 Relationship Between Logistic Regression and LDA

LDA and logistic regression are almost the same thing. If we assume that each group is Gaussian with the same covariance matrix, then we saw earlier that

On the other hand, the logistic model is, by assumption,

These are the same model since they both lead to classification rules that are linear in x. The difference is in how we estimate the parameters.

The joint density of a single observation is f(x, y) = f(x|y)f(y) = f(y|x)f(x). In LDA we estimated the whole joint distribution by maximizing the likelihood

(22.26)

In logistic regression we maximized the conditional likelihood Πif(yi|xi) but we ignored the second term f(xi):

(22.27)

Since classification only requires knowing f(y|x), we don’t really need to estimate the whole joint distribution. Logistic regression leaves the marginal distribution f(x) unspecified so it is more nonparametric than LDA. This is an advantage of the logistic regression approach over LDA.

To summarize: LDA and logistic regression both lead to a linear classification rule. In LDA we estimate the entire joint distribution f(x, y) = f(x|y) f(y). In logistic regression we only estimate f(y|x) and we don’t bother estimating f(x).

22.6 Density Estimation and Naive Bayes

The Bayes rule is h(x) = argmaxk πk fk (x). If we can estimate πk and fk then we can estimate the Bayes classification rule. Estimating πk is easy but what about fk? We did this previously by assuming fk was Gaussian. Another strategy is to estimate fk with some nonparametric density estimator such as a kernel estimator. But if x = (x₁,..., xd) is high-dimensional, nonparametric density estimation is not very reliable. This problem is amelio-rated if we assume that X₁,..., Xd are independent, for then, fk(x₁,..., xd) = . This reduces the problem to d one-dimensional density estimation problems, within each of the k groups. The resulting classifier is called the naive Bayes classifier. The assumption that the components of X are independent is usually wrong yet the resulting classifier might still be accurate. Here is a summary of the steps in the naive Bayes classifier:

The Naive Bayes Classifier

1.

For each group k, compute an estimate of the density fkj for Xj, using the data for which Yi = k.

2.

Let

3.

Let

where I(Yi = k) = 1 if Yi = k and I(Yi = k) = 0 if Yi ≠ k.

4.

Let

The naive Bayes classifier is popular when x is high-dimensional and discrete. In that case, is especially simple.

22.7 Trees

Trees are classification methods that partition the covariate space into disjoint pieces and then classify the observations according to which partition element they fall in. As the name implies, the classifier can be represented as a tree.

For illustration, suppose there are two covariates, X₁ = age and X₂ = blood pressure. Figure 22.2 shows a classification tree using these variables.

FIGURE 22.2.

A simple classification tree.

The tree is used in the following way. If a subject has Age ≥ 50 then we classify him as Y = 1. If a subject has Age < 50 then we check his blood pressure. If systolic blood pressure is < 100 then we classify him as Y = 1, otherwise we classify him as Y = 0. Figure 22.3 shows the same classifier as a partition of the covariate space.

FIGURE 22.3.

Partition representation of classification tree.

Here is how a tree is constructed. First, suppose that and that there is only a single covariate X. We choose a split point t that divides the real line into two sets A₁ = (−∞, t] and A₂ = (t, ∞). Let be the proportion of observations in As such that Yi = j:

(22.28)

for s = 1, 2 and j = 0, 1. The impurity of the split t is defined to be

(22.29)

where

(22.30)

This particular measure of impurity is known as the Gini index. If a partition element As contains all 0’s or all 1’s, then γs = 0. Otherwise, γs > 0. We choose the split point t to minimize the impurity. (Other indices of impurity besides can be used besides the Gini index.)

When there are several covariates, we choose whichever covariate and split that leads to the lowest impurity. This process is continued until some stopping criterion is met. For example, we might stop when every partition element has fewer than n₀ data points, where n₀ is some fixed number. The bottom nodes of the tree are called the leaves. Each leaf is assigned a 0 or 1 depending on whether there are more data points with Y = 0 or Y = 1 in that partition element.

This procedure is easily generalized to the case where Y ∈ {1,..., K}. We simply define the impurity by

(22.31)

where is the proportion of observations in the partition element for which Y = j.

22.13 Example. A classification tree for the heart disease data yields a misclassification rate of .21. If we build a tree using only tobacco and age, the misclassification rate is then .29. The tree is shown in Figure 22.4. ■

FIGURE 22.4.

A classification tree for the heart disease data using two covariates.

Our description of how to build trees is incomplete. If we keep splitting until there are few cases in each leaf of the tree, we are likely to overfit the data. We should choose the complexity of the tree in such a way that the estimated true error rate is low. In the next section, we discuss estimation of the error rate.

22.8 Assessing Error Rates and Choosing a Good Classifier

How do we choose a good classifier? We would like to have a classifier h with a low true error rate L(h). Usually, we can’t use the training error rate as an estimate of the true error rate because it is biased downward.

22.14 Example. Consider the heart disease data again. Suppose we fit a sequence of logistic regression models. In the first model we include one covariate. In the second model we include two covariates, and so on. The ninth model includes all the covariates. We can go even further. Let’s also fit a tenth model that includes all nine covariates plus the first covariate squared. Then we fit an eleventh model that includes all nine covariates plus the first covariate squared and the second covariate squared. Continuing this way we will get a sequence of 18 classifiers of increasing complexity. The solid line in Figure 22.5 shows the observed classification error which steadily decreases as we make the model more complex. If we keep going, we can make a model with zero observed classification error. The dotted line shows the 10-fold cross-validation estimate of the error rate (to be explained shortly) which is a better estimate of the true error rate than the observed classification error. The estimated error decreases for a while then increases. This is essentially the bias-variance tradeoff phenomenon we have seen in Chapter 20. ■

FIGURE 22.5.

The solid line is the observed error rate and dashed line is the cross-validation estimate of true error rate.

There are many ways to estimate the error rate. We’ll consider two: cross-validation and probability inequalities.

Cross-Validation. The basic idea of cross-validation, which we have already encountered in curve estimation, is to leave out some of the data when fitting a model. The simplest version of cross-validation involves randomly splitting the data into two pieces: the training set and the validation set Often, about 10 per cent of the data might be set aside as the validation set. The classifier h is constructed from the training set. We then estimate the error by

(22.32)

where m is the size of the validation set. See Figure 22.6.

FIGURE 22.6.

Cross-validation. The data are divided into two groups: the training data and the validation data. The training data are used to produce an estimated h classifier . Then, is applied to the validation data to obtain an estimate of the error rate of .

Another approach to cross-validation is K-fold cross-validation which is obtained from the following algorithm.

K-fold cross-validation.

1.

Randomly divide the data into K chunks of approximately equal size. A common choice is K = 10.

2.

For k = 1 to K, do the following:

(a)

Delete chunk k from the data.

(b)

Compute the classifier from the rest of the data.

(c)

Use to the predict the data in chunk k. Let denote the observed error rate.

3.

Let

(22.33)

22.15 Example. We applied 10-fold cross-validation to the heart disease data. The minimum cross-validation error as a function of the number of leaves occurred at six. Figure 22.7 shows the tree with six leaves. ■

FIGURE 22.7.

Smaller classification tree with size chosen by cross-validation.

Probability Inequalities. Another approach to estimating the error rate is to find a confidence interval for using probability inequalities. This method is useful in the context of empirical risk minimization.

Let be a set of classifiers, for example, all linear classifiers. Empirical risk minimization means choosing the classifier to minimize the training error , also called the empirical risk. Thus,

(22.34)

Typically, underestimates the true error rate because was chosen to make small. Our goal is to assess how much underestimation is taking place. Our main tool for this analysis is Hoeffding’s inequality (Theorem 4.5). Recall that if X₁,..., Xn ∼ Bernoulli(p), then, for any ε > 0,

(22.35)

where

First, suppose that consists of finitely many classifiers. For any fixed h, converges in almost surely to L(h) by the law of large numbers. We will now establish a stronger result.

22.16 Theorem (Uniform Convergence). Assume is finite and has m elements. Then,

Proof. We will use Hoeffding’s inequality and we will also use the fact that if A₁,..., Am is a set of events then . Now,

22.17 Theorem. Let

Then is a 1 − α confidence interval for .

Proof. This follows from the fact that

When is large the confidence interval for is large. The more functions there are in the more likely it is we have “overfit” which we compensate for by having a larger confidence interval.

In practice we usually use sets that are infinite, such as the set of linear classifiers. To extend our analysis to these cases we want to be able to say something like

One way to develop such a generalization is by way of the Vapnik-Chervonenkis or VC dimension.

Let be a class of sets. Give a finite set F = {x₁,..., xn} let

(22.36)

be the number of subsets of F “picked out” by . Here #(B) denotes the number of elements of a set B. The shatter coefficient is defined by

(22.37)

where consists of all finite sets of size n. Now let X₁,..., Xn ∼ ℙ and let

denote the empirical probability measure. The following remarkable theorem bounds the distance between ℙ and ℙn.

22.18 Theorem (Vapnik and Chervonenkis (1971)). For any ℙ, n and ε > 0,

(22.38)

The proof, though very elegant, is long and we omit it. If is a set of classifiers, define to be the class of sets of the form {x: h(x) = 1}. We then define .

22.19 Theorem.

A 1 − α confidence interval for is where

These theorems are only useful if the shatter coefficients do not grow too quickly with n. This is where VC dimension enters.

22.20 Definition. The VC (Vapnik-Chervonenkis) dimension of a class of sets is defined as follows. If = 2n for all n, set = ∞. Otherwise, define to be the largest k for which = 2k.

Thus, the VC-dimension is the size of the largest finite set F that can be shattered by meaning that picks out each subset of F. If is a set of classifiers we define where is the class of sets of the form {x: h(x) = 1} as h varies in . The following theorem shows that if has finite VC-dimension, then the shatter coefficients grow as a polynomial in n.

22.21 Theorem. If has finite VC-dimension v, then

22.22 Example. Let . The shatters every 1-point set {x} but it shatters no set of the form {x, y}. Therefore, = 1. ■

22.23 Example. Let be the set of closed intervals on the real line. Then shatters S = {x, y} but it cannot shatter sets with 3 points. Consider S = {x, y, z} where x < y < z. One cannot find an interval A such that A ∩ S = {x, z}. So, = 2. ■

22.24 Example. Let be all linear half-spaces on the plane. Any 3-point set (not all on a line) can be shattered. No 4 point set can be shattered. Consider, for example, 4 points forming a diamond. Let T be the left and rightmost points. This can’t be picked out. Other configurations can also be seen to be unshatterable. So = 3. In general, halfspaces in have VC dimension d + 1. ■

22.25 Example. Let be all rectangles on the plane with sides parallel to the axes. Any 4 point set can be shattered. Let S be a 5 point set. There is one point that is not leftmost, rightmost, uppermost, or lowermost. Let T be all points in S except this point. Then T can’t be picked out. So = 4. ■

22.26 Theorem. Let x have dimension d and let be th set of linear classifiers. The VC-dimension of is d + 1. Hence, a 1 − α confidence interval for the true error rate is where

22.9 Support Vector Machines

In this section we consider a class of linear classifiers called support vector machines. Throughout this section, we assume that Y is binary. It will be convenient to label the outcomes as −1 and +1 instead of 0 and 1. A linear classifier can then be written as

where x = (x₁,..., xd),

and

First, suppose that the data are linearly separable, that is, there exists a hyperplane that perfectly separates the two classes.

22.27 Lemma. The data can be separated by some hyperplane if and only if there exists a hyperplane such that

(22.39)

Proof. Suppose the data can be separated by a hyperplane W(x) = b₀ + . It follows that there exists some constant c such that Yi = 1 implies W(Xi) ≥ c and Yi = −1 implies W(Xi) ≤ −c. Therefore, YiW(Xi) ≥ c for all i. Let where aj = bj/c. Then YiH(Xi) ≥ 1 for all i. The reverse direction is straightforward. ■

In the separable case, there will be many separating hyperplanes. How should we choose one? Intuitively, it seems reasonable to choose the hyperplane “furthest” from the data in the sense that it separates the +1s and −1s and maximizes the distance to the closest point. This hyperplane is called the maximum margin hyperplane. The margin is the distance to from the hyperplane to the nearest point. Points on the boundary of the margin are called support vectors. See Figure 22.8.

FIGURE 22.8.

The hyperplane H(x) has the largest margin of all hyperplanes that separate the two classes.

22.28 Theorem. The hyperplane that separates the data and maximizes the margin is given by minimizing subject to (22.39).

It turns out that this problem can be recast as a quadratic programming problem. Let denote the inner product of Xi and Xk.

22.29 Theorem. Let denote the optimal (largest margin) hyperplane. Then, for j = 1,..., d,

where Xj(i) is the value of the covariate Xj for the ith data point, and is the vector that maximizes

(22.40)

subject to

and

The points Xi for which are called support vectors. can be found by solving

for any support point Xi. may be written as

There are many software packages that will solve this problem quickly. If there is no perfect linear classifier, then one allows overlap between the groups by replacing the condition (22.39) with

(22.41)

The variables ξ₁,..., ξn are called slack variables.

We now maximize (22.40) subject to

and

The constant c is a tuning parameter that controls the amount of overlap.

22.10 Kernelization

There is a trick called kernelization for improving a computationally simple classifier h. The idea is to map the covariate X — which takes values in — into a higher dimensional space and apply the classifier in the bigger space . This can yield a more flexible classifier while retaining computationally simplicity.

The standard example of this idea is illustrated in Figure 22.9. The covariate x = (x₁, x₂). The Yis can be separated into two groups using an ellipse. Define a mapping ϕ by

Thus, ϕ maps = ℝ² into = ℝ³. In the higher-dimensional space , the Yi’s are separable by a linear decision boundary. In other words,

a linear classifier in a higher-dimensional space corresponds to a nonlinear classifier in the original space.

The point is that to get a richer set of classifiers we do not need to give up the convenience of linear classifiers. We simply map the covariates to a higher-dimensional space. This is akin to making linear regression more flexible by using polynomials.

FIGURE 22.9.

Kernelization. Mapping the covariates into a higher-dimensional space can make a complicated decision boundary into a simpler decision boundary.

There is a potential drawback. If we significantly expand the dimension of the problem, we might increase the computational burden. For example, if x has dimension d = 256 and we wanted to use all fourth-order terms, then z = ϕ(x) has dimension 183,181,376. We are spared this computational nightmare by the following two facts. First, many classifiers do not require that we know the values of the individual points but, rather, just the inner product between pairs of points. Second, notice in our example that the inner product in can be written

Thus, we can compute without ever computing Zi = ϕ(Xi).

To summarize, kernelization involves finding a mapping ϕ: → and a classifier such that:

1.

has higher dimension than and so leads a richer set of classifiers.

2.

The classifier only requires computing inner products.

3.

There is a function K, called a kernel, such that

4.

Everywhere the term appears in the algorithm, replace it with .

In fact, we never need to construct the mapping ϕ at all. We only need to specify a kernel that corresponds to for some ϕ. This raises an interesting question: given a function of two variables K(x, y), does there exist a function ϕ(x) such that K(x, y) = 〈ϕ(x), ϕ(y)〉? The answer is provided by Mercer’s theorem which says, roughly, that if K is positive definite — meaning that

for square integrable functions f — then such a ϕ exists. Examples of commonly used kernels are:

Let us now see how we can use this trick in LDA and in support vector machines.

Recall that the Fisher linear discriminant method replaces X with U = wTX where w is chosen to maximize the Rayleigh coefficient

and

In the kernelized version, we replace Xi with Zi = ϕ(Xi) and we find w to maximize

(22.42)

where

and

Here, is the sample of covariance of the Zi’s for which Y = j. However, to take advantage of kernelization, we need to re-express this in terms of inner products and then replace the inner products with kernels.

It can be shown that the maximizing vector w is a linear combination of the Zi’s. Hence we can write

Also,

Therefore,

where Mj is a vector whose ith component is

It follows that

where M = (M₀ − M₁)(M₀ − M₁)T. By similar calculations, we can write

where

I is the identity matrix, 1 is a matrix of all one’s, and Kj is the n × nj matrix with entries (Kj)rs = K(xr, xs) with xs varying over the observations in group j. Hence, we now find α to maximize

All the quantities are expressed in terms of the kernel. Formally, the solution is α = N⁻¹(M₀ − M₁). However, N might be non-invertible. In this case one replaces N by N + bI, for some constant b. Finally, the projection onto the new subspace can be written as

The support vector machine can similarly be kernelized. We simply replace 〈Xi, Xj〉 with K(Xi, Xj). For example, instead of maximizing (22.40), we now maximize

(22.43)

The hyperplane can be written as

22.11 Other Classifiers

There are many other classifiers and space precludes a full discussion of all of them. Let us briefly mention a few.

The k-nearest-neighbors classifier is very simple. Given a point x, find the k data points closest to x. Classify x using the majority vote of these k neighbors. Ties can be broken randomly. The parameter k can be chosen by cross-validation.

Bagging is a method for reducing the variability of a classifier. It is most helpful for highly nonlinear classifiers such as trees. We draw B bootstrap samples from the data. The bth bootstrap sample yields a classifier hb. The final classifier is

Boosting is a method for starting with a simple classifier and gradually improving it by refitting the data giving higher weight to misclassified samples. Suppose that is a collection of classifiers, for example, trees with only one split. Assume that Yi ∈ {−1, 1} and that each h is such that h(x) ∈ {−1, 1}. We usually give equal weight to all data points in the methods we have discussed. But one can incorporate unequal weights quite easily in most algorithms. For example, in constructing a tree, we could replace the impurity measure with a weighted impurity measure. The original version of boosting, called AdaBoost, is as follows.

1.

Set the weights wi = 1/n, i = 1,..., n.

2.

For j = 1,..., J, do the following steps:

(a)

Constructing a classifier hj from the data using the weights w₁,..., wn.

(b)

Compute the weighted error estimate:

(c)

Let

(d)

Update the weights:

3.

The final classifier is

There is now an enormous literature trying to explain and improve on boosting. Whereas bagging is a variance reduction technique, boosting can be thought of as a bias reduction technique. We starting with a simple — and hence highly-biased — classifier, and we gradually reduce the bias. The disadvantage of boosting is that the final classifier is quite complicated.

Neural Networks are regression models of the form ³

where σ is a smooth function, often taken to be σ(υ) = eυ/(1 + eυ). This is really nothing more than a nonlinear regression model. Neural nets were fashionable for some time but they pose great computational difficulties. In particular, one often encounters multiple minima when trying to find the least squares estimates of the parameters. Also, the number of terms p is essentially a smoothing parameter and there is the usual problem of trying to choose p to find a good balance between bias and variance.

22.12 Bibliographic Remarks

The literature on classification is vast and is growing quickly. An excellent reference is Hastie et al. (2001). For more on the theory, see Devroye et al. (1996) and Vapnik (1998). Two recent books on kernels are Scholkopf and Smola (2002) and Herbich (2002).

22.13 Exercises

1.

Prove Theorem 22.5.

2.

Prove Theorem 22.7.

3.

Download the spam data from:
http://www-stat.stanford.edu/∼tibs/ElemStatLearn/index.html
The data file can also be found on the course web page. The data contain 57 covariates relating to email messages. Each email message was classified as spam (Y=1) or not spam (Y=0). The outcome Y is the last column in the file. The goal is to predict whether an email is spam or not.

(a)

Construct classification rules using (i) LDA, (ii) QDA, (iii) logistic regression, and (iv) a classification tree. For each, report the observed misclassification error rate and construct a 2-by-2 table of the form

(b)

Use 5-fold cross-validation to estimate the prediction accuracy of LDA and logistic regression.

(c)

Sometimes it helps to reduce the number of covariates. One strategy is to compare Xi for the spam and email group. For each of the 57 covariates, test whether the mean of the covariate is the same or different between the two groups. Keep the 10 covariates with the smallest p-values. Try LDA and logistic regression using only these 10 variables.

4.

Let be the set of two-dimensional spheres. That is, A ∈ if A = {(x, y): (x − a)² + (y − b)² ≤ c²} for some a, b, c. Find the VC-dimension of .

5.

Classify the spam data using support vector machines. Free software for the support vector machine is at http://svmlight.joachims.org/

6.

Use VC theory to get a confidence interval on the true error rate of the LDA classifier for the iris data (from the book web site).

7.

Suppose that Xi ∈ ℝ and that Yi = 1 whenever |Xi| ≤ 1 and Yi = 0 whenever |Xi| > 1. Show that no linear classifier can perfectly classify these data. Show that the kernelized data can be linearly separated.

8.

Repeat question 5 using the kernel . Choose p by cross-validation.

9.

Apply the k nearest neighbors classifier to the “iris data.” Choose k by cross-validation.

10.

(Curse of Dimensionality.) Suppose that X has a uniform distribution on the d-dimensional cube [−1/2, 1/2]d. Let R be the distance from the origin to the closest neighbor. Show that the median of R is

where

is the volume of a sphere of radius r. For what dimension d does the median of R exceed the edge of the cube when n = 100, n = 1,000, n = 10,000? (Hastie et al. (2001), p. 22–27.)

11.

Fit a tree to the data in question 3. Now apply bagging and report your results.

12.

Fit a tree that uses only one split on one variable to the data in question 3. Now apply boosting.

13.

Let r(x) = ℙ(Y = 1|X = x) and let be an estimate of r(x). Consider the classifier

Assume that for some functions and σ²(x). Show that, for fixed x,

where Φ is the standard Normal CDF and h* is the Bayes rule. Regard as a type of bias term. Explain the implications for the bias-variance tradeoff in classification (Friedman (1997)).
Hint: first show that

¹

One can use other loss functions. For simplicity we will use the error rate as our loss function.

²

The quantity J arises in physics, where it is called the Rayleigh coefficient.

³

This is the simplest version of a neural net. There are more complex versions of the model.

23
Probability Redux: Stochastic Processes

Larry Wasserman1

(1)

Department of Statistics, Carnegie Mellon University, Baker Hall 228A, 15213-3890, Pittsburgh, PA, USA

Larry Wasserman

Email: larry@stat.cmu.edu

23.1 Introduction

Most of this book has focused on iid sequences of random variables. Now we consider sequences of dependent random variables. For example, daily temperatures will form a sequence of time-ordered random variables and clearly the temperature on one day is not independent of the temperature on the previous day.

A stochastic process {Xt : t ∈ T} is a collection of random variables. We shall sometimes write X(t) instead of Xt. The variables Xt take values in some set χ called the state space. The set T is called the index set and for our purposes can be thought of as time. The index set can be discrete T = {0, 1, 2, . . .} or continuous T = [0, ∞) depending on the application.

23.1 Example (iid observations). A sequence of iid random variables can be written as {Xt : t ∈ T} where T = {1, 2, 3, . . .,}. Thus, a sequence of iid random variables is an example of a stochastic process. ■

23.2 Example (The Weather). Let χ = {sunny, cloudy}. A typical sequence (depending on where you live) might be

This process has a discrete state space and a discrete index set. ■

23.3 Example (Stock Prices). Figure 23.1 shows the price of a fictitious stock over time. The price is monitored continuously so the index set T is continuous. Price is discrete but for all practical purposes we can treat it as a continuous variable. ■

FIGURE 23.1.

Stock price over ten week period.

23.4 Example (Empirical Distribution Function). Let X₁, . . ., Xn ∼ F where F is some cdf on [0, 1]. Let

be the empirical cdf. For any fixed value t, is a random variable. But the whole empirical cdf

is a stochastic process with a continuous state space and a continuous index set. ■

We end this section by recalling a basic fact. If X₁, . . ., Xn are random variables, then we can write the joint density as

(23.1)

where pasti = (X₁, . . ., Xi−1).

23.2 Markov Chains

A Markov chain is a stochastic process for which the distribution of Xt depends only on Xt−1. In this section we assume that the state space is discrete, either χ = {1, . . ., N} or χ = {1, 2, . . .,} and that the index set is T = {0, 1, 2, . . .}. Typically, most authors write Xn instead of Xt when discussing Markov chains and I will do so as well.

23.5 Definition. The process {Xn : n ∈ T} is a Markov chain if

(23.2)

for all n and for all x ∈ χ.

For a Markov chain, equation (23.1) simplifies to

A Markov chain can be represented by the following DAG:

Each variable has a single parent, namely, the previous observation.

The theory of Markov chains is a very rich and complex. We have to get through many definitions before we can do anything interesting. Our goal is to answer the following questions:

1.

When does a Markov chain “settle down” into some sort of equilibrium?

2.

How do we estimate the parameters of a Markov chain?

3.

How can we construct Markov chains that converge to a given equilibrium distribution and why would we want to do that?

We will answer questions 1 and 2 in this chapter. We will answer question 3 in the next chapter. To understand question 1, look at the two chains in Figure 23.2. The first chain oscillates all over the place and will continue to do so forever. The second chain eventually settles into an equilibrium. If we constructed a histogram of the first process, it would keep changing as we got more and more observations. But a histogram from the second chain would eventually converge to some fixed distribution.

FIGURE 23.2.

Two Markov chains. The first chain does not settle down into an equilibrium. The second does.

Transition Probabilities. The key quantities of a Markov chain are the probabilities of jumping from one state into another state. A Markov chain is homogeneous if ℙ(Xn+1 = j|Xn = i) does not change with time. Thus, for a homogeneous Markov chain, ℙ(Xn+1 = j|Xn = i) = ℙ(X₁ = j|X₀ = i). We shall only deal with homogeneous Markov chains.

23.6 Definition. We call

(23.3)

the transition probabilities. The matrix P whose (i, j) element is pij is called the transition matrix.

We will only consider homogeneous chains. Notice that P has two properties: (i) pij ≥ 0 and (ii) ∑i pij = 1. Each row can be regarded as a probability mass function.

23.7 Example (Random Walk With Absorbing Barriers). Let χ = {1, . . ., N}. Suppose you are standing at one of these points. Flip a coin with ℙ(Heads) = p and ℙ(Tails) = q = 1 − p. If it is heads, take one step to the right. If it is tails, take one step to the left. If you hit one of the endpoints, stay there. The transition matrix is

23.8 Example. Suppose the state space is χ = {sunny, cloudy}. Then X₁, X₂, . . . represents the weather for a sequence of days. The weather today clearly depends on yesterday’s weather. It might also depend on the weather two days ago but as a first approximation we might assume that the dependence is only one day back. In that case the weather is a Markov chain and a typical transition matrix might be

For example, if it is sunny today, there is a 60 per cent chance it will be cloudy tomorrow. ■

Let

(23.4)

be the probability of of going from state i to state j in n steps. Let Pn be the matrix whose (i, j) element is pij(n). These are called the n-step transition probabilities.

23.9 Theorem (The Chapman-Kolmogorov equations). The n-step probabilities satisfy

(23.5)

Proof. Recall that, in general,

This fact is true in the more general form

Also, recall the law of total probability:

Using these facts and the Markov property we have

Look closely at equation (23.5). This is nothing more than the equation for matrix multiplication. Hence we have shown that

(23.6)

By definition, P₁ = P. Using the above theorem, P₂ = P₁₊₁ = P₁P₁ = PP = P². Continuing this way, we see that

(23.7)

Let μn = (μn(1), . . ., μn(N)) be a row vector where

(23.8)

is the marginal probability that the chain is in state i at time n. In particular, μ₀ is called the initial distribution. To simulate a Markov chain, all you need to know is μ₀ and P. The simulation would look like this:
Step 1: Draw X₀ ∼ μ₀. Thus, ℙ(X₀ = i) = μ₀ (i).
Step 2: Denote the outcome of step 1 by i. Draw X₁ ∼ P. In other words, ℙ(X₁ = j|X₀ = i) = pij.
Step 3: Suppose the outcome of step 2 is j. Draw X₂ ∼ P. In other words, ℙ(X₂ = k|X₁ = j) = pjk.

And so on.

It might be difficult to understand the meaning of μn. Imagine simulating the chain many times. Collect all the outcomes at time n from all the chains. This histogram would look approximately like μn. A consequence of theorem 23.9 is the following:

23.10 Lemma. The marginal probabilities are given by

Proof.

Summary of Terminology

1.

Transition matrix: P(i, j) = ℙ(Xn+1 = j|Xn = i) = pij.

2.

n-step matrix: Pn (i, j) = ℙ(Xn+m = j|Xm = i).

3.

Pn = Pn.

4.

Marginal: μn(i) = ℙ(Xn = i).

5.

μn = μ₀Pn.

States. The states of a Markov chain can be classified according to various properties.

23.11 Definition. We say that i reaches j (or j is accessible from i) if pij(n) > 0 for some n, and we write i → j. If i → j and j → i then we write i ↔ j and we say that i and j communicate.

23.12 Theorem. The communication relation satisfies the following properties:

1.

i ↔ i.

2.

If i ↔ j then j ↔ i.

3.

If i ↔ j and j ↔ k then i ↔ k.

4.

The set of states χ can be written as a disjoint union of classes χ = χ₁ ⋃ χ₂ ⋃ ⋯ where two states i and j communicate with each other if and only if they are in the same class.

If all states communicate with each other, then the chain is called irreducible. A set of states is closed if, once you enter that set of states you never leave. A closed set consisting of a single state is called an absorbing state.

23.13 Example. Let χ = {1, 2, 3, 4} and

The classes are {1, 2}, {3} and {4}. State 4 is an absorbing state. ■

Suppose we start a chain in state i. Will the chain ever return to state i? If so, that state is called persistent or recurrent.

23.14 Definition. State i is recurrent or persistent if

Otherwise, state i is transient.

23.15 Theorem. A state i is recurrent if and only if

(23.9)

A state i is transient if and only if

(23.10)

Proof. Define

The number of times that the chain is in state i is . The mean of Y, given that the chain starts in state i, is

Define ai = ℙ(Xn = i for some n ≥ 1 | X₀ = i). If i is recurrent, ai = 1. Thus, the chain will eventually return to i. Once it does return to i, we argue again that since ai = 1, the chain will return to state i again. By repeating this argument, we conclude that . If i is transient, then ai < 1. When the chain is in state i, there is a probability 1 − ai > 0 that it will never return to state i. Thus, the probability that the chain is in state i exactly n times is . This is a geometric distribution which has finite mean. ■

23.16 Theorem. Facts about recurrence.

1.

If state i is recurrent and i ↔ j, then j is recurrent.

2.

If state i is transient and i ↔ j, then j is transient.

3.

A finite Markov chain must have at least one recurrent state.

4.

The states of a finite, irreducible Markov chain are all recurrent.

23.17 Theorem (Decomposition Theorem). The state space χ can be written as the disjoint union

where χT are the transient states and each χi is a closed, irreducible set of recurrent states.

23.18 Example (Random Walk). Let χ = {. . ., −2, −1, 0, 1, 2, . . .,} and suppose that pi,i+1 = p, pi,i−1 = q = 1 − p. All states communicate, hence either all the states are recurrent or all are transient. To see which, suppose we start at X₀ = 0. Note that

(23.11)

since the only way to get back to 0 is to have n heads (steps to the right) and n tails (steps to the left). We can approximate this expression using Stirling’s formula which says that

Inserting this approximation into (23.11)) shows that

It is easy to check that ∑n p₀₀(n) < ∞ if and only if ∑n p₀₀ (2n) < ∞. Moreover, ∑n p₀₀(2n) = ∞ if and only if p = q = 1/2. By Theorem (23.15), the chain is recurrent if p = 1/2 otherwise it is transient. ■

Convergence of Markov Chains. To discuss the convergence of chains, we need a few more definitions. Suppose that X₀ = i. Define the recurrence time

(23.12)

assuming Xn ever returns to state i, otherwise define Tij = ∞. The mean recurrence time of a recurrent state i is

(23.13)

where

A recurrent state is null if mi = ∞ otherwise it is called non-null or positive.

23.19 Lemma. If a state is null and recurrent, then .

23.20 Lemma. In a finite state Markov chain, all recurrent states are positive.

Consider a three-state chain with transition matrix

Suppose we start the chain in state 1. Then we will be in state 3 at times 3, 6, 9, . . .. This is an example of a periodic chain. Formally, the period of state i is d if pii(n) = 0 whenever n is not divisible by d and d is the largest integer with this property. Thus, d = gcd{n : pii(n) > 0} where gcd means “greater common divisor.” State i is periodic if d(i) > 1 and aperiodic if d(i) = 1. A state with period 1 is called aperiodic.

23.21 Lemma. If state i has period d and i ↔ j then j has period d.

23.22 Definition. A state is ergodic if it is recurrent, non-null and aperiodic. A chain is ergodic if all its states are ergodic.

Let π = (πi : i ∈ χ) be a vector of non-negative numbers that sum to one. Thus π can be thought of as a probability mass function.

23.23 Definition. We say that π is a stationary (or invariant) distribution if π = πP.

Here is the intuition. Draw X₀ from distribution π and suppose that π is a stationary distribution. Now draw X₁ according to the transition probability of the chain. The distribution of X₁ is then μ₁ = μ₀P = πP = π. The distribution of X₂ is πP² = (πP)P = πP = π. Continuing this way, we see that the distribution of Xn is πPn = π. In other words:

If at any time the chain has distribution π, then it will continue to have distribution π forever.

23.24 Definition. We say that a chain has limiting distribution if

for some π, that is, exists and is independent of i.

Here is the main theorem about convergence. The theorem says that an ergodic chain converges to its stationary distribution. Also, sample averages converge to their theoretical expectations under the stationary distribution.

23.25 Theorem. An irreducible, ergodic Markov chain has a unique stationary distribution π. The limiting distribution exists and is equal to π. If g is any bounded function, then, with probability 1,

(23.14)

Finally, there is another definition that will be useful later. We say that π satisfies detailed balance if

(23.15)

Detailed balance guarantees that π is a stationary distribution.

23.26 Theorem. If π satisfies detailed balance, then π is a stationary distribution.

Proof. We need to show that πP = π. The jth element of πP is ∑i πipij = ∑i πjpji = πj ∑i pji = πj. ■

The importance of detailed balance will become clear when we discuss Markov chain Monte Carlo methods in Chapter 24.

Warning! Just because a chain has a stationary distribution does not mean it converges.

23.27 Example. Let

Let π = (1/3, 1/3, 1/3). Then πP = π so π is a stationary distribution. If the chain is started with the distribution π it will stay in that distribution. Imagine simulating many chains and checking the marginal distribution at each time n. It will always be the uniform distribution π. But this chain does not have a limit. It continues to cycle around forever. ■

Examples of Markov Chains.

23.28 Example. Let χ = {1, 2, 3, 4, 5, 6}. Let

Then C₁ = {1, 2} and C₂ = {5, 6} are irreducible closed sets. States 3 and 4 are transient because of the path 3 → 4 → 6 and once you hit state 6 you cannot return to 3 or 4. Since pii(1) > 0, all the states are aperiodic. In summary, 3 and 4 are transient while 1, 2, 5, and 6 are ergodic. ■

23.29 Example (Hardy-Weinberg). Here is a famous example from genetics. Suppose a gene can be type A or type a. There are three types of people (called genotypes): AA, Aa, and aa. Let (p, q, r) denote the fraction of people of each genotype. We assume that everyone contributes one of their two copies of the gene at random to their children. We also assume that mates are selected at random. The latter is not realistic however, it is often reasonable to assume that you do not choose your mate based on whether they are AA, Aa, or aa. (This would be false if the gene was for eye color and if people chose mates based on eye color.) Imagine if we pooled everyone’s genes together. The proportion of A genes is P = p + (q/2) and the proportion of a genes is Q = r + (q/2). A child is AA with probability P², aA with probability 2PQ, and aa with probability Q². Thus, the fraction of A genes in this generation is

However, r = 1 − p − q. Substitute this in the above equation and you get P² + PQ = P. A similar calculation shows that the fraction of “a” genes is Q. We have shown that the proportion of type A and type a is P and Q and this remains stable after the first generation. The proportion of people of type AA, Aa, aa is thus (P², 2PQ, Q²) from the second generation and on. This is called the Hardy-Weinberg law.

Assume everyone has exactly one child. Now consider a fixed person and let Xn be the genotype of their nth descendant. This is a Markov chain with state space χ = {AA, Aa, aa}. Some basic calculations will show you that the transition matrix is

The stationary distribution is π = (P², 2PQ, Q²). ■

23.30 Example (Markov chain Monte Carlo). In Chapter 24 we will present a simulation method called Markov chain Monte Carlo (MCMC). Here is a brief description of the idea. Let f(x) be a probability density on the real line and suppose that f(x) = cg(x) where g(x) is a known function and c > 0 is unknown. In principle, we can compute c since ∫ f(x)dx = 1 implies that c = 1/ ∫ g(x)dx. However, it may not be feasible to perform this integral, nor is it necessary to know c in the following algorithm. Let X₀ be an arbitrary starting value. Given X₀, . . ., Xi, draw Xi₊₁ as follows. First, draw W ∼ N(Xi, b²) where b > 0 is some fixed constant. Let

Draw U ∼ Uniform(0, 1) and set

We will see in Chapter 24 that, under weak conditions, X₀, X₁, . . ., is an ergodic Markov chain with stationary distribution f. Hence, we can regard the draws as a sample from f. ■

Inference for Markov Chains. Consider a chain with finite state space χ = {1, 2, . . ., N}. Suppose we observe n observations X₁, . . ., Xn from this chain. The unknown parameters of a Markov chain are the initial probabilities μ₀ = (μ₀(1), μ₀(2), . . .,) and the elements of the transition matrix P. Each row of P is a multinomial distribution. So we are essentially estimating N distributions (plus the initial probabilities). Let nij be the observed number of transitions from state i to state j. The likelihood function is

There is only one observation on μ₀ so we can’t estimate that. Rather, we focus on estimating P. The mle is obtained by maximizing ℒ(μ₀, P) subject to the constraint that the elements are non-negative and the rows sum to 1. The solution is

where . Here we are assuming that ni > 0. If not, then we set by convention.

23.31 Theorem (Consistency and Asymptotic Normality of the mle). Assume that the chain is ergodic. Let denote the mle after n observations. Then . Also,

where the left-hand side is a matrix, and

23.3 Poisson Processes

The Poisson process arises when we count occurrences of events over time, for example, traffic accidents, radioactive decay, arrival of email messages, etc. As the name suggests, the Poisson process is intimately related to the Poisson distribution. Let’s first review the Poisson distribution.

Recall that X has a Poisson distribution with parameter λ — written X ∼ Poisson(λ) — if

Also recall that and . If X ∼ Poisson(λ), Y ∼ Poisson(ν) and X∐Y, then X+Y ∼ Poisson(λ+ν). Finally, if N ∼ Poisson(λ) and Y|N = n ∼ Binomial(n, p), then the marginal distribution of Y is Y ∼ Poisson(λp).

Now we describe the Poisson process. Imagine that you are at your computer. Each time a new email message arrives you record the time. Let Xt be the number of messages you have received up to and including time t. Then, {Xt : t ∈ [0, ∞)} is a stochastic process with state space χ = {0, 1, 2, . . .}. A process of this form is called a counting process. A Poisson process is a counting process that satisfies certain conditions. In what follows, we will sometimes write X(t) instead of Xt. Also, we need the following notation. Write f(h) = o(h) if f(h)/h → 0 as h → 0. This means that f(h) is smaller than h when h is close to 0. For example, h² = o(h).

23.32 Definition. A Poisson process is a stochastic process {Xt : t ∈ [0, ∞) } with state space χ = {0, 1, 2, . . .} such that

1.

X(0) = 0.

2.

For any 0 = t₀ < t₁ < t₂ < ⋯ < tn, the increments

are independent.

3.

There is a function λ(t) such that

(23.16)

(23.17)

We call λ(t) the intensity function.

The last condition means that the probability of an event in [t, t + h] is approximately hλ(t) while the probability of more than one event is small.

23.33 Theorem. If Xt is a Poisson process with intensity function λ(t), then

where

In particular, X(t) ∼ Poisson(m(t)). Hence, and m(t).

23.34 Definition. A Poisson process with intensity function λ(t) ≡ λ for some λ > 0 is called a homogeneous Poisson process with rate λ. In this case,

Let X(t) be a homogeneous Poisson process with rate λ. Let Wn be the time at which the nth event occurs and set W₀ = 0. The random variables W₀, W₁, . . ., are called waiting times. Let Sn = Wn+1 − Wn. Then S₀, S₁, . . . are called sojourn times or interarrival times.

23.35 Theorem. The sojourn times S₀, S₁, . . . are iid random variables. Their distribution is exponential with mean 1/λ, that is, they have density

The waiting time Wn ∼ Gamma(n, 1/λ) i.e., it has density

Hence, and .

Proof. First, we have

with shows that the cdf for S₁ is 1 − e−λt. This shows the result for S₁. Now,

Hence, S₂ has an exponential distribution and is independent of S₁. The result follows by repeating the argument. The result for Wn follows since a sum of exponentials has a Gamma distribution. ■

23.36 Example. Figure 23.3 shows requests to a WWW server in Calgary.¹ Assuming that this is a homogeneous Poisson process, N ≡ X(T) ∼ Poisson(λT). The likelihood is

FIGURE 23.3.

Hits on a web server. Each vertical line represents one event.

which is maximized at

in units per minute. Let’s now test the assumption that the data follow a homogeneous Poisson process using a goodness-of-fit test. We divide the interval [0, T] into 4 equal length intervals I₁, I₂, I₃, I₄. If the process is a homogeneous Poisson process then, given the total number of events, the probability that an event falls into any of these intervals must be equal. Let pi be the probability of a point being in Ii. The null hypothesis is that p₁ = p₂ = p₃ = p₄ = 1/4. We can test this hypothesis using either a likelihood ratio test or a χ² test. The latter is

where Oi is the number of observations in Ii and Ei = n/4 is the expected number under the null. This yields χ² = 252 with a p-value near 0. This is strong evidence against the null so we reject the hypothesis that the data are from a homogeneous Poisson process. This is hardly surprising since we would expect the intensity to vary as a function of time. ■

23.4 Bibliographic Remarks

This is standard material and there are many good references including Grimmett and Stirzaker (1982), Taylor and Karlin (1994), Guttorp (1995), and Ross (2002). The following exercises are from those texts.

23.5 Exercises

1.

Let X₀, X₁, . . . be a Markov chain with states {0, 1, 2} and transition matrix

Assume that μ₀ = (0. 3, 0.4, 0.3). Find ℙ(X₀ = 0, X₁ = 1, X₂ = 2) and ℙ(X₀ = 0, X₁ = 1, X₂ = 1).

2.

Let Y₁, Y₂, . . . be a sequence of iid observations such that ℙ(Y = 0) = 0.1, ℙ(Y = 1) = 0.3, ℙ(Y = 2) = 0.2, ℙ(Y = 3) = 0.4. Let X₀ = 0 and let

Show that X₀, X₁, . . . is a Markov chain and find the transition matrix.

3.

Consider a two-state Markov chain with states χ = {1, 2} and transition matrix

where 0 < a < 1 and 0 < b < 1. Prove that

4.

Consider the chain from question 3 and set a = .1 and b = .3. Simulate the chain. Let

be the proportion of times the chain is in state 1 and state 2. Plot and versus n and verify that they converge to the values predicted from the answer in the previous question.

5.

An important Markov chain is the branching process which is used in biology, genetics, nuclear physics, and many other fields. Suppose that an animal has Y children. Let pk = ℙ(Y = k). Hence, pk ≥ 0 for all k and . Assume each animal has the same lifespan and that they produce offspring according to the distribution pk. Let Xn be the number of animals in the nth generation. Let be the offspring produced in the nth generation. Note that

Let and . Assume throughout this question that X₀ = 1. Let and .

(a)

Show that M(n + 1) = μM(n) and V(n + 1) = σ²M(n) + μ²V(n).

(b)

Show that M(n) = μn and that V(n) = σ²μn−1 (1 + μ + ⋯ + μn−1)

(c)

What happens to the variance if μ > 1? What happens to the variance if μ = 1? What happens to the variance if μ < 1?

(d)

The population goes extinct if Xn = 0 for some n. Let us thus define the extinction time N by

Let F(n) = ℙ(N ≤ n) be the cdf of the random variable N. Show that

Hint: Note that the event {N ≤ n} is the same as event {Xn = 0}. Thus, ℙ({N ≤ n}) = ℙ({Xn = 0}). Let k be the number of offspring of the original parent. The population becomes extinct at time n if and only if each of the k sub-populations generated from the k offspring goes extinct in n − 1 generations.

(e)

Suppose that p₀ = 1/4, p₁ = 1/2, p₂ = 1/4. Use the formula from (5d) to compute the cdf F(n).

6.

Let

Find the stationary distribution π.

7.

Show that if i is a recurrent state and i ↔ j, then j is a recurrent state.

8.

Let

Which states are transient? Which states are recurrent?

9.

Let

Show that π = (1/2, 1/2) is a stationary distribution. Does this chain converge? Why/why not?

10.

Let 0 < p < 1 and q = 1 − p. Let

Find the limiting distribution of the chain.

11.

Let X(t) be an inhomogeneous Poisson process with intensity function λ(t) > 0. Let . Define Y(s) = X(t) where s = Λ(t). Show that Y(s) is a homogeneous Poisson process with intensity λ = 1.

12.

Let X(t) be a Poisson process with intensity λ. Find the conditional distribution of X(t) given that X(t + s) = n.

13.

Let X(t) be a Poisson process with intensity λ. Find the probability that X(t) is odd, i.e. ℙ(X(t) = 1, 3, 5, . . .).

14.

Suppose that people logging in to the University computer system is described by a Poisson process X(t) with intensity λ. Assume that a person stays logged in for some random time with cdf G. Assume these times are all independent. Let Y(t) be the number of people on the system at time t. Find the distribution of Y(t).

15.

Let X(t) be a Poisson process with intensity λ. Let W₁, W₂, . . ., be the waiting times. Let f be an arbitrary function. Show that

16.

A two-dimensional Poisson point process is a process of random points on the plane such that (i) for any set A, the number of points falling in A is Poisson with mean λμ(A) where μ(A) is the area of A, (ii) the number of events in non-overlapping regions is independent. Consider an arbitrary point x₀ in the plane. Let X denote the distance from x₀ to the nearest random point. Show that

and

¹

See http://ita.ee.lbl.gov/html/contrib/Calgary-HTTP.html for more information.

24
Simulation Methods

Larry Wasserman1

(1)

Department of Statistics, Carnegie Mellon University, Baker Hall 228A, 15213-3890, Pittsburgh, PA, USA

Larry Wasserman

Email: larry@stat.cmu.edu

In this chapter we will show how simulation can be used to approximate integrals. Our leading example is the problem of computing integrals in Bayesian inference but the techniques are widely applicable. We will look at three integration methods: (i) basic Monte Carlo integration, (ii) importance sampling, and (iii) Markov chain Monte Carlo (MCMC).

24.1 Bayesian Inference Revisited

Simulation methods are especially useful in Bayesian inference so let us briefly review the main ideas in Bayesian inference. See Chapter 11 for more details.

Given a prior f(θ) and data Xn = (X₁,..., Xn) the posterior density is

where (θ) is the likelihood function and

is the normalizing constant. The posterior mean is

If θ = (θ₁,..., θk) is multidimensional, then we might be interested in the posterior for one of the components, θ₁, say. This marginal posterior density is

which involves high-dimensional integration.

When θ is high-dimensional, it may not be feasible to calculate these integrals analytically. Simulation methods will often be helpful.

24.2 Basic Monte Carlo Integration

Suppose we want to evaluate the integral

for some function h. If h is an “easy” function like a polynomial or trigonometric function, then we can do the integral in closed form. If h is complicated there may be no known closed form expression for I. There are many numerical techniques for evaluating I such as Simpson’s rule, the trapezoidal rule and Gaussian quadrature. Monte Carlo integration is another approach for approximating I which is notable for its simplicity, generality and scalability.

Let us begin by writing

(24.1)

where w(x) = h(x)(b−a) and f(x) = 1/(b−a). Notice that f is the probability density for a uniform random variable over (a, b). Hence,

where X ∼ Unif(a, b). If we generate X₁,..., XN ∼ Unif(a, b), then by the law of large numbers

(24.2)

This is the basic Monte Carlo integration method. We can also compute the standard error of the estimate

where

where Yi = w(Xi). A 1 − α confidence interval for I is . We can take N as large as we want and hence make the length of the confidence interval very small.

24.1 Example. Let h(x) = x³. Then, I = = 1/4. Based on N = 10, 000 observations from a Uniform(0, 1) we get with a standard error of .0028. ■

A generalization of the basic method is to consider integrals of the form

(24.3)

where f(x) is a probability density function. Taking f to be a Uniform (a, b) gives us the special case above. Now we draw X₁,..., XN ∼ f and take

as before.

24.2 Example. Let

be the standard Normal pdf. Suppose we want to compute the cdf at some point x:

Write

where

Now we generate X₁,..., XN ∼ N(0, 1) and set

For example, with x = 2, the true answer is Φ(2) = .9772 and the Monte Carlo estimate with N = 10, 000 yields .9751. Using N = 100, 000 we get .9771. ■

24.3 Example (Bayesian Inference for Two Binomials). Let X ∼ Binomial(n, p₁) and Y ∼ Binomial(m, p₂). We would like to estimate δ = p₂ − p₁. The mle is . We can get the standard error using the delta method which yields

and then construct a 95 percent confidence interval . Now consider a Bayesian analysis. Suppose we use the prior f(p₁, p₂) = f(p₁) f(p₂) = 1, that is, a flat prior on (p₁, p₂). The posterior is

The posterior mean of δ is

If we want the posterior density of δ we can first get the posterior cdf

where A = {(p₁, p₂) : p₂ − p₁ ≤ c}. The density can then be obtained by differentiating F.

To avoid all these integrals, let’s use simulation. Note that f(p₁, p₂|X, Y) = f(p₁|X)f(p₂|Y) which implies that p₁ and p₂ are independent under the posterior distribution. Also, we see that p₁|X ∼ Beta(X + 1, n − X + 1) and p₂|Y ∼Beta(Y + 1, m − Y + 1). Hence, we can simulate from the posterior by drawing

for i = 1,..., N. Now let . Then,

We can also get a 95 percent posterior interval for δ by sorting the simulated values, and finding the .025 and .975 quantile. The posterior density f(δ|X, Y) can be obtained by applying density estimation techniques to δ¹,..., δ(N) or, simply by plotting a histogram. For example, suppose that n = m = 10, X = 8 and Y = 6. From a posterior sample of size 1000 we get a 95 percent posterior interval of (−0.52,0.20). The posterior density can be estimated from a histogram of the simulated values as shown in Figure 24.1. ■

FIGURE 24.1.

Posterior of δ from simulation.

24.4 Example (Bayesian Inference for Dose Response). Suppose we conduct an experiment by giving rats one of ten possible doses of a drug, denoted by x₁ < x₂ < ... < x₁₀. For each dose level xi we use n rats and we observe Yi, the number that survive. Thus we have ten independent binomials Yi ∼ Binomial(n, pi). Suppose we know from biological considerations that higher doses should have higher probability of death. Thus, p₁ ≤ p₂ ≤ ⋯ ≤ p₁₀. We want to estimate the dose at which the animals have a 50 percent chance of dying. This is called the LD50. Formally, δ = xj where

Notice that δ is implicitly a (complicated) function of p₁,..., p₁₀ so we can write δ = g(p₁,..., p₁₀) for some g. This just means that if we know (p₁,..., p₁₀) then we can find δ. The posterior mean of δ is

The integral is over the region

The posterior cdf of δ is

where

We need to do a 10-dimensional integral over a restricted region A. Instead, we will use simulation. Let us take a flat prior truncated over A. Except for the truncation, each Pi has once again a Beta distribution. To draw from the posterior we do the following steps:

(1)

Draw Pi ∼ Beta(Yi + 1, n − Yi + 1), i = 1,..., 10.

(2)

If P₁ ≤ P₂ ≤ ⋯ ≤ P₁₀ keep this draw. Otherwise, throw it away and draw again until you get one you can keep.

(3)

Let δ = xj where

We repeat this N times to get δ⁽¹⁾,..., δ(N) and take

δ is a discrete variable. We can estimate its probability mass function by

For example, consider the following data:

The posterior draws for p₁,..., p₁₀ are shown in the second panel in the figure. We find that that with a 95 percent interval of (3,5). ■

24.3 Importance Sampling

Consider again the integral I = ∫ h(x)f(x)dx where f is a probability density. The basic Monte Carlo method involves sampling from f. However, there are cases where we may not know how to sample from f. For example, in Bayesian inference, the posterior density density is is obtained by multiplying the likelihood (θ) times the prior f(θ). There is no guarantee that f(θ|x) will be a known distribution like a Normal or Gamma or whatever.

Importance sampling is a generalization of basic Monte Carlo which overcomes this problem. Let g be a probability density that we know how to simulate from. Then

(24.4)

where Y = h(X)f(X)/g(X) and the expectation is with respect to g. We can simulate X₁, ..., XN ∼ g and estimate I by

(24.5)

This is called importance sampling. By the law of large numbers, . However, there is a catch. It’s possible that might have an infinite standard error. To see why, recall that I is the mean of w(x) = h(x) f(x)/g(x). The second moment of this quantity is

(24.6)

If g has thinner tails than f, then this integral might be infinite. To avoid this, a basic rule in importance sampling is to sample from a density g with thicker tails than f. Also, suppose that g(x) is small over some set A where f(x) is large. Again, the ratio of f/g could be large leading to a large variance. This implies that we should choose g to be similar in shape to f. In summary, a good choice for an importance sampling density g should be similar to f but with thicker tails. In fact, we can say what the optimal choice of g is.

24.5 Theorem. The choice of g that minimizes the variance of is

Proof. The variance of w = f h/g is

The second integral does not depend on g, so we only need to minimize the first integral. From Jensen’s inequality (Theorem 4.9) we have

This establishes a lower bound on . However, ( equals this lower bound which proves the claim.

This theorem is interesting but it is only of theoretical interest. If we did not know how to sample from f then it is unlikely that we could sample from |h(x)| f(x)/ ∫ |h(s)|f(s)ds. In practice, we simply try to find a thick-tailed distribution g which is similar to f|h|.

24.6 Example (Tail Probability). Let’s estimate I = ℙ(Z > 3) = .0013 where Z ∼ N(0, 1). Write I = ∫ h(x) f(x)dx where f(x) is the standard Normal density and h(x) = 1 if x > 3, and 0 otherwise. The basic Monte Carlo estimator is where X₁, ..., XN ∼ N(0, 1). Using N = 100 we find (from simulating many times) that and . Notice that most observations are wasted in the sense that most are not near the right tail. Now we will estimate this with importance sampling taking g to be a Normal(4,1) density. We draw values from g and the estimate is now . In this case we find that and We have reduced the standard deviation by a factor of 20. ■

24.7 Example (Measurement Model With Outliers). Suppose we have measurements X₁,..., Xn of some physical quantity θ. A reasonable model is

If we assume that ϵi ∼ N(0, 1) then Xi ∼ N(θi, 1). However, when taking measurements, it is often the case that we get the occasional wild observation, or outlier. This suggests that a Normal might be a poor model since Normals have thin tails which implies that extreme observations are rare. One way to improve the model is to use a density for ϵi with a thicker tail, for example, a t-distribution with v degrees of freedom which has the form

Smaller values of v correspond to thicker tails. For the sake of illustration we will take v = 3. Suppose we observe n Xi = θ + ϵi, i = 1, ..., n where ϵi has a t distribution with v = 3. We will take a flat prior on θ. The likelihood is and the posterior mean of θ is

We can estimate the top and bottom integral using importance sampling. We draw θ₁,..., θN ∼ g and then

To illustrate the idea, we drew n = 2 observations. The posterior mean (computed numerically) is −0.54. Using a Normal importance sampler g yields an estimate of −0.74. Using a Cauchy (t-distribution with 1 degree of freedom) importance sampler yields an estimate of −0.53. ■

24.4 MCMC Part I: The Metropolis-Hastings Algorithm

Consider once more the problem of estimating the integral I = ∫ h(x) f(x)dx. Now we introduce Markov chain Monte Carlo (MCMC) methods. The idea is to construct a Markov chain X₁, X₂,..., whose stationary distribution is f. Under certain conditions it will then follow that

This works because there is a law of large numbers for Markov chains; see Theorem 23.25.

The Metropolis-Hastings algorithm is a specific MCMC method that works as follows. Let q(y|x) be an arbitrary, friendly distribution (i.e., we know how to sample from q(y|x)). The conditional density q(y|x) is called the proposal distribution. The Metropolis-Hastings algorithm creates a sequence of observations X₀, X₁,..., as follows.

Metropolis-Hastings Algorithm

Choose X₀ arbitrarily. Suppose we have generated X₀, X₁,..., X. To generate Xi+1 do the following:

(1)

Generate a proposal or candidate value Y ∼ q(y|Xi).

(2)

Evaluate r ≡ r(Xi, Y) where

(3)

Set

24.8 Remark. A simple way to execute step (3) is to generate U ∼ (0, 1). If U < r set Xi+1 = Y otherwise set Xi+1 = Xi.

24.9 Remark. A common choice for q(y|x) is N(x, b²) for some b > 0. This means that the proposal is draw from a Normal, centered at the current value. In this case, the proposal density q is symmetric, q(y|x) = q(x|y), and r simplifies to

By construction, X₀, X₁,... is a Markov chain. But why does this Markov chain have f as its stationary distribution? Before we explain why, let us first do an example.

24.10 Example. The Cauchy distribution has density

Our goal is to simulate a Markov chain whose stationary distribution is f. As suggested in the remark above, we take q(y|x) to be a N(x, b²). So in this case,

So the algorithm is to draw Y ∼ N(Xi, b²) and set

The simulator requires a choice of b. Figure 24.2 shows three chains of length N = 1,000 using b = .1, b = 1 and b = 10. Setting b = .1 forces the chain to take small steps. As a result, the chain doesn’t “explore” much of the sample space. The histogram from the sample does not approximate the true density very well. Setting b = 10 causes the proposals to often be far in the tails, making r small and hence we reject the proposal and keep the chain at its current position. The result is that the chain “gets stuck” at the same place quite often. Again, this means that the histogram from the sample does not approximate the true density very well. The middle choice avoids these extremes and results in a Markov chain sample that better represents the density sooner. In summary, there are tuning parameters and the efficiency of the chain depends on these parameters. We, 11 discuss this in more detail later. ■

FIGURE 24.2.

Three Metropolis chains corresponding to b = .1, b = 1, b = 10.

If the sample from the Markov chain starts to “look like” the target distribution f quickly, then we say that the chain is “mixing well.” Constructing a chain that mixes well is somewhat of an art.

Why It Works. Recall from Chapter 23 that a distribution π satisfies detailed balance for a Markov chain if

We showed that if π satisfies detailed balance, then it is a stationary distribution for the chain.

Because we are now dealing with continuous state Markov chains, we will change notation a little and write p(x, y) for the probability of making a transition from x to y. Also, let’s use f(x) instead of π for a distribution. In this new notation, f is a stationary distribution if f(x) = ∫f(y)p(y, x)dy and detailed balance holds for f if

(24.7)

Detailed balance implies that f is a stationary distribution since, if detailed balance holds, then

which shows that f(x) = ∫f(y)p(y, x)dy as required. Our goal is to show that f satisfies detailed balance which will imply that f is a stationary distribution for the chain.

Consider two points x and y. Either

We will ignore ties (which occur with probability zero for continuous distributions). Without loss of generality, assume that f(x)q(y|x) > f(y)q(x|y). This implies that

and that r(y, x) = 1. Now p(x, y) is the probability of jumping from x to y. This requires two things: (i) the proposal distribution must generate y, and (ii) you must accept y. Thus,

Therefore,

(24.8)

On the other hand, p(y, x) is the probability of jumping from y to x. This requires two things: (i) the proposal distribution must generate x, and (ii) you must accept x. This occurs with probability p(y, x) = q(x|y)r(y, x) = q(x|y). Hence,

(24.9)

Comparing (24.8) and (24.9), we see that we have shown that detailed balance holds.

24.5 MCMC Part II: Different Flavors

There are different types of MCMC algorithm. Here we will consider a few of the most popular versions.

Random-Walk-Metropolis-Hastings. In the previous section we considered drawing a proposal Y of the form

where ϵi comes from some distribution with density g. In other words, q(y|x = g(y − x). We saw that in this case,

This is called a random-walk-Metropolis-Hastings method. The reason for the name is that, if we did not do the accept-reject step, we would be simulating a random walk. The most common choice for g is a N(0, b²). The hard part is choosing b so that the chain mixes well. A good rule of thumb is: choose b so that you accept the proposals about 50 percent of the time.

Warning! This method doesn’t make sense unless X takes values on the whole real line. If X is restricted to some interval then it is best to transform X. For example, if X ∈ (0, ∞) then you might take Y = logX and then simulate the distribution for Y instead of X.

Independence-Metropolis-Hastings. This is an importance-sampling version of MCMC. We draw the proposal from a fixed distribution g. Generally, g is chosen to be an approximation to f. The acceptance probability becomes

Gibbs Sampling. The two previous methods can be easily adapted, in principle, to work in higher dimensions. In practice, tuning the chains to make them mix well is hard. Gibbs sampling is a way to turn a high-dimensional problem into several one-dimensional problems.

Here’s how it works for a bivariate problem. Suppose that (X, Y) has density fX,Y(x, y). First, suppose that it is possible to simulate from the conditional distributions fX|Y(x|y) and fY|X(y|x). Let (X₀, Y₀) be starting values. Assume we have drawn (X₀, Y₀),..., (Xn, Yn). Then the Gibbs sampling algorithm for getting (Xn+1, Yn+1) is:

Gibbs Sampling

X n+1 ∼ fX|Y(x|Yn)
Y n+1 ∼ fY|X (y|Xn+1)
repeat

This generalizes in the obvious way to higher dimensions.

24.11 Example (Normal Hierarchical Model). Gibbs sampling is very useful for a class of models called hierarchical models. Here is a simple case. Suppose we draw a sample of k cities. From each city we draw ni people and observe how many people Yi have a disease. Thus, Yi ∼ Binomial(ni, pi). We are allowing for different disease rates in different cities. We can also think of the as random draws from some distribution F. We can write this model in the following way:

We are interested in estimating the and the overall disease rate ∫ pdF(p).

To proceed, it will simplify matters if we make some transformations that allow us to use some Normal approximations. Let Recall that where Let ψi = log(pi/(1 − pi)) and define By the delta method,

where Experience shows that the Normal approximation for ψ is more accurate than the Normal approximation for p so we shall work with ψ. We shall treat σi as known. Furthermore, we shall take the distribution of the to be Normal. The hierarchical model is now

As yet another simplification we take τ = 1. The unknown parameter are θ = (μ, ψ₁,..., ψk). The likelihood function is

If we use the prior f(μ) ∝ 1 then the posterior is proportional to the likelihood. To use Gibbs sampling, we need to find the conditional distribution of each parameter conditional on all the others. Let us begin by finding f(μ|rest) where “rest” refers to all the other variables. We can throw away any terms that don’t involve μ. Thus,

where

Hence we see that μ|rest ∼ N(b, 1/k). Next we will find f(ψ|rest). Again, we can throw away any terms not involving ψi leaving us with

where

and so The Gibbs sampling algorithm then involves iterating the following steps N times:

It is understood that at each step, the most recently drawn version of each variable is used.

We generated a numerical example with k = 20 cities and n = 20 people from each city. After running the chain, we can convert each ψi back into pi by way of pi = eψi/(1 + eψi). The raw proportions are shown in Figure 24.4. Figure 24.3 shows “trace plots” of the Markov chain for p₁ and μ. Figure 24.4 shows the posterior for μ based on the simulated values. The second panel of Figure 24.4 shows the raw proportions and the Bayes estimates. Note that the Bayes estimates are “shrunk” together. The parameter τ controls the amount of shrinkage. We set τ = 1 but, in practice, we should treat τ as another unknown parameter and let the data determine how much shrinkage is needed. ■

FIGURE 24.4.

Example 24.11. Top panel: posterior histogram of μ. Lower panel: raw proportions and the Bayes posterior estimates. The Bayes estimates have been shrunk closer together than the raw proportions.

FIGURE 24.3.

Posterior simulation for Example 24.11. The top panel shows simulated values of p₁. The top panel shows simulated values of μ.

So far we assumed that we know how to draw samples from the conditionals fX∣Y(x|y) and fY∣X(y|x). If we don’t know how, we can still use the Gibbs sampling algorithm by drawing each observation using a Metropolis-Hastings step. Let q be a proposal distribution for x and let be a proposal distribution for y. When we do a Metropolis step for X, we treat Y as fixed. Similarly, when we do a Metropolis step for Y, we treat X as fixed. Here are the steps:

Metropolis within Gibbs

(1a)

Draw a proposal Z ∼ q(z|Xn).

(1b)

Evaluate

(1c)

Set

(2a)

Draw a proposal

(2b)

Evaluate

(2c)

Set

Again, this generalizes to more than two dimensions.

24.6 Bibliographic Remarks

MCMC methods go back to the effort to build the atomic bomb in World War II. They were used in various places after that, especially in spatial statistics. There was a new surge of interest in the 1990s that still continues. My main reference for this chapter was Robert and Casella (1999). See also Gelman et al. (1995) and Gilks et al. (1998).

24.7 Exercises

1.

Let

(a)

Estimate I using the basic Monte Carlo method. Use N =100, 000. Also, find the estimated standard error.

(b)

Find an (analytical) expression for the standard error of your estimate in (a). Compare to the estimated standard error.

(c)

Estimate I using importance sampling. Take g to be N(1.5, υ²) with υ = .1, υ = 1 and υ = 10. Compute the (true) standard errors in each case. Also, plot a histogram of the values you are averaging to see if there are any extreme values.

(d)

Find the optimal importance sampling function g*. What is the standard error using g*?

2.

Here is a way to use importance sampling to estimate a marginal density. Let fX,Y(x, y) be a bivariate density and let (X₁, X₂),..., (XN, YN) ∼ fX,Y.

(a)

Let w(x) be an arbitrary probability density function. Let

Show that, for each x,

Find an expression for the variance of this estimator.

(b)

Let Y ∼ N(0, 1) and X|Y = y ∼ N(y,1 + y²). Use the method in (a) to estimate fX(x).

3.

Here is a method called accept-reject sampling for drawing observations from a distribution.

(a)

Suppose that f is some probability density function. Let g be any other density and suppose that f(x) ≤ Mg(x) for all x, where M is a known constant. Consider the following algorithm:

(step 1):

Draw X ∼ g and U ∼ Unif(0, 1);

(step 2):

If U ≤ f(X)/(Mg(X)) set Y = X, otherwise go back to step 1. (Keep repeating until you finally get an observation.)

Show that the distribution of Y is f.

(b)

Let f be a standard Normal density and let g(x) = 1/(1 + x²) be the Cauchy density. Apply the method in (a) to draw 1,000 observations from the Normal distribution. Draw a histogram of the sample to verify that the sample appears to be Normal.

4.

A random variable Z has a inverse Gaussian distribution if it has density

where θ₁ > 0 and θ₂ > 0 are parameters. It can be shown that

(a)

Let θ₁ = 1 . 5 and θ₂ = 2. Draw a sample of size 1,000 using the independence-Metropolis-Hastings method. Use a Gamma distribution as the proposal density. To assess the accuracy, compare the mean of Z and 1/Z from the sample to the theoretical means Try different Gamma distributions to see if you can get an accurate sample.

(b)

Draw a sample of size 1,000 using the random-walk-Metropolis-Hastings method. Since z > 0 we cannot just use a Normal density. One strategy is this. Let W = log Z. Find the density of W. Use the random-walk-Metropolis-Hastings method to get a sample W₁,..., WN and let Zi = eWi. Assess the accuracy of the simulation as in part (a).

5.

Get the heart disease data from the book web site. Consider a Bayesian analysis of the logistic regression model

Use the flat prior f(β₀,..., βk) ∝ 1. Use the Gibbs-Metropolis algorithm to draw a sample of size 10,000 from the posterior f(β₀, β₁|data). Plot histograms of the posteriors for the βj’s. Get the posterior mean and a 95 percent posterior interval for each βj.
(b) Compare your analysis to a frequentist approach using maximum likelihood.

Bibliography

Agresti, A. (1990). Categorical Data Analysis. Wiley.

Akaike, H. (1973). Information theory and an extension of the maximum likelihood principle. Second International Symposium on Information Theory 267–281.

Anderson, T. W. (1984). An Introduction to Multivariate Statistical Analysis (Second Edition). Wiley.

Barron, A., Schervish, M. J. and Wasserman, L. (1999). The consistency of posterior distributions in nonparametric problems. The Annals of Statistics 27 536–561.

Beecher, H. (1959). Measurement of Subjective Responses. Oxford University Press.

Benjamini, Y. and Hochberg, Y. (1995). Controlling the false discovery rate: A practical and powerful approach to multiple testing. Journal of the Royal Statistical Society, Series B, Methodological 57 289–300.

Beran, R. (2000). REACT scatterplot smoothers: Superefficiency through basis economy. Journal of the American Statistical Association 95 155–171.

Beran, R. and Dümbgen, L. (1998). Modulation of estimators and confidence sets. The Annals of Statistics 26 1826–1856.

Berger, J. and Wolpert, R. (1984). The Likelihood Principle. Institute of Mathematical Statistics.

Berger, J. O. (1985). Statistical Decision Theory and Bayesian Analysis (Second Edition). Springer-Verlag.

Berger, J. O. and Delampady, M. (1987). Testing precise hypotheses (c/r: P335–352). Statistical Science 2 317–335.

Berliner, L. M. (1983). Improving on inadmissible estimators in the control problem. The Annals of Statistics 11 814–826.

Bickel, P. J. and Doksum, K. A. (2000). Mathematical Statistics: Basic Ideas and Selected Topics, Vol. I (Second Edition). Prentice Hall.

Billingsley, P. (1979). Probability and Measure. Wiley.

Bishop, Y. M. M., Fienberg, S. E. and Holland, P. W. (1975). Discrete Multivariate Analyses: Theory and Practice. MIT Press.

Breiman, L. (1992). Probability. Society for Industrial and Applied Mathematics.

Brinegar, C. S. (1963). Mark Twain and the Quintus Curtius Snodgrass letters: A statistical test of authorship. Journal of the American Statistical Association 58 85–96.

Carlin, B. P. and Louis, T. A. (1996). Bayes and Empirical Bayes Methods for Data Analysis. Chapman & Hall.

Casella, G. and Berger, R. L. (2002). Statistical Inference. Duxbury Press.

Chaudhuri, P. and Marron, J. S. (1999). Sizer for exploration of structures in curves. Journal of the American Statistical Association 94 807–823.

Cox, D. and Lewis, P. (1966). The Statistical Analysis of Series of Events. Chapman & Hall.

Cox, D. D. (1993). An analysis of Bayesian inference for nonparametric regression. The Annals of Statistics 21 903–923.

Cox, D. R. and Hinkley, D. V. (2000). Theoretical statistics. Chapman & Hall.

Davison, A. C. and Hinkley, D. V. (1997). Bootstrap Methods and Their Application. Cambridge University Press.

De Groot, M. and Schervish, M. (2002). Probability and Statistics (Third Edition). Addison-Wesley.

Devroye, L., Györfi, L. and Lugosi, G. (1996). A Probabilistic Theory of Pattern Recognition. Springer-Verlag.

Diaconis, P. and Freedman, D. (1986). On inconsistent Bayes estimates of location. The Annals of Statistics 14 68–87.

Dobson, A. J. (2001). An introduction to generalized linear models. Chapman & Hall.

Donoho, D. L. and Johnstone, I. M. (1994). Ideal spatial adaptation by wavelet shrinkage. Biometrika 81 425–455.

Donoho, D. L. and Johnstone, I. M. (1995). Adapting to unknown smoothness via wavelet shrinkage. Journal of the American Statistical Association 90 1200–1224.

Donoho, D. L. and Johnstone, I. M. (1998). Minimax estimation via wavelet shrinkage. The Annals of Statistics 26 879–921.

Donoho, D. L., Johnstone, I. M., Kerkyacharian, G. and Picard, D. (1995). Wavelet shrinkage: Asymptopia? (Disc: p 337–369). Journal of the Royal Statistical Society, Series B, Methodological 57 301–337.

Dunsmore, I., Daly, F. et al. (1987). M345 Statistical Methods, Unit 9: Categorical Data. The Open University.

Edwards, D. (1995). Introduction to graphical modelling. Springer-Verlag.

Efromovich, S. (1999). Nonparametric Curve Estimation: Methods, Theory and Applications. Springer-Verlag.

Efron, B. (1979). Bootstrap methods: Another look at the jackknife. The Annals of Statistics 7 1–26.

Efron, B., Tibshirani, R., Storey, J. D. and Tusher, V. (2001). Empirical Bayes analysis of a microarray experiment. Journal of the American Statistical Association 96 1151–1160.

Efron, B. and Tibshirani, R. J. (1993). An Introduction to the Bootstrap. Chapman & Hall.

Ferguson, T. (1967). Mathematical Statistics: a Decision Theoretic Approach. Academic Press.

Fisher, R. (1921). On the probable error of a coefficient of correlation deduced from a small sample. Metron 1 1–32.

Freedman, D. (1999). Wald lecture: On the Bernstein-von Mises theorem with infinite-dimensional parameters. The Annals of Statistics 27 1119–1141.

Friedman, J. H. (1997). On bias, variance, 0/1-loss, and the curse-of-dimensionality. Data Mining and Knowledge Discovery 1 55–77.

Gelman, A., Carlin, J. B., Stern, H. S. and Rubin, D. B. (1995). Bayesian Data Analysis. Chapman & Hall.

Ghosal, S., Ghosh, J. K. and Van Der Vaart, A. W. (2000). Convergence rates of posterior distributions. The Annals of Statistics 28 500–531.

Gilks, W. R., Richardson, S. and Spiegelhalter, D. J. (1998). Markov Chain Monte Carlo in Practice. Chapman & Hall.

Grimmett, G. and Stirzaker, D. (1982). Probability and Random Processes. Oxford University Press.

Guttorp, P. (1995). Stochastic Modeling of Scientific Data. Chapman & Hall.

Hall, P. (1992). The Bootstrap and Edgeworth Expansion. Springer-Verlag.

Halverson, N., Leitch, E., Pryke, C., Kovac, J., Carlstrom, J., Holzapfel, W., Dragovan, M., Cartwright, J., Mason, B., Padin, S., Pearson, T., Shepherd, M. and Readhead, A. (2002). DASI first results: A measurement of the cosmic microwave background angular power spectrum. Astrophysics Journal 568 38–45.

Hardle, W. (1990). Applied nonparametric regression. Cambridge University Press.

Härdle, W., Kerkyacharian, G., Picard, D. and Tsybakov, A. (1998). Wavelets, Approximation, and Statistical Applications. Springer-Verlag.

Hastie, T., Tibshirani, R. and Friedman, J. H. (2001). The Elements of Statistical Learning: Data Mining, Inference, and Prediction. Springer-Verlag.

Herbich, R. (2002). Learning Kernel Classifiers: Theory and Algorithms. MIT Press.

Johnson, R. A. and Wichern, D. W. (1982). Applied Multivariate Statistical Analysis. Prentice-Hall.

Johnson, S. and Johnson, R. (1972). New England Journal of Medicine 287 1122–1125.

Jordan, M. (2004). Graphical models. In Preparation.

Karr, A. (1993). Probability. Springer-Verlag.

Kass, R. E. and Raftery, A. E. (1995). Bayes factors. Journal of the American Statistical Association 90 773–795.

Kass, R. E. and Wasserman, L. (1996). The selection of prior distributions by formal rules (corr: 1998 v93 p 412). Journal of the American Statistical Association 91 1343–1370.

Larsen, R. J. and Marx, M. L. (1986). An Introduction to Mathematical Statistics and Its Applications (Second Edition). Prentice Hall.

Lauritzen, S. L. (1996). Graphical Models. Oxford University Press.

Lee, A. T. et al. (2001). A high spatial resolution analysis of the maxima-1 cosmic microwave background anisotropy data. Astrophys. J. 561 L1–L6.

Lee, P. M. (1997). Bayesian Statistics: An Introduction. Edward Arnold.

Lehmann, E. L. (1986). Testing Statistical Hypotheses (Second Edition). Wiley.

Lehmann, E. L. and Casella, G. (1998). Theory of Point Estimation. Springer-Verlag.

Loader, C. (1999). Local regression and likelihood. Springer-Verlag.

Marron, J. S. and Wand, M. P. (1992). Exact mean integrated squared error. The Annals of Statistics 20 712–736.

Morrison, A., Black, M., Lowe, C., Macmahon, B. and Yusa, S. (1973). Some international differences in histology and survival in breast cancer. International Journal of Cancer 11 261–267.

Netterfield, C. B. et al. (2002). A measurement by boomerang of multiple peaks in the angular power spectrum of the cosmic microwave background. Astrophys. J. 571 604–614.

Ogden, R. T. (1997). Essential Wavelets for Statistical Applications and Data Analysis. Birkhäuser.

Pearl, J. (2000). Casuality: models, reasoning, and inference. Cambridge University Press.

Phillips, D. and King, E. (1988). Death takes a holiday: Mortality surrounding major social occasions. Lancet 2 728–732.

Phillips, D. and Smith, D. (1990). Postponement of death until symbolically meaningful occasions. Journal of the American Medical Association 263 1947–1961.

Quenouille, M. (1949). Approximate tests of correlation in time series. Journal of the Royal Statistical Society B 11 18–84.

Rice, J. A. (1995). Mathematical Statistics and Data Analysis (Second Edition). Duxbury Press.

Robert, C. P. (1994). The Bayesian Choice: A Decision-theoretic Motivation. Springer-Verlag.

Robert, C. P. and Casella, G. (1999). Monte Carlo Statistical Methods. Springer-Verlag.

Robins, J., Scheines, R., Spirtes, P. and Wasserman, L. (2003). Uniform convergence in causal inference. Biometrika (to appear).

Robins, J. M. and Ritov, Y. (1997). Toward a curse of dimensionality appropriate (CODA) asymptotic theory for semi-parametric models. Statistics in Medicine 16 285–319.

Rosenbaum, P. (2002). Observational Studies. Springer-Verlag.

Ross, S. (2002). Probability Models for Computer Science. Academic Press.

Rousseauw, J., du Plessis, J., Benade, A., Jordaan, P., Kotze, J., Jooste, P. and Ferreira, J. (1983). Coronary risk factor screening in three rural communities. South African Medical Journal 64 430–436.

Schervish, M. J. (1995). Theory of Statistics. Springer-Verlag.

Scholkopf, B. and Smola, A. (2002). Learning with Kernels: Support Vector Machines, Regularization, Optimization, and Beyond. MIT Press.

Schwarz, G. (1978). Estimating the dimension of a model. The Annals of Statistics 6 461–464.

Scott, D., Gotto, A., Cole, J. and Gorry, G. (1978). Plasma lipids as collateral risk factors in coronary artery disease: a study of 371 males with chest pain. Journal of Chronic Diseases 31 337–345.

Scott, D. W. (1992). Multivariate Density Estimation: Theory, Practice, and Visualization. Wiley.

Shao, J. and Tu, D. (1995). The Jackknife and Bootstrap (German). Springer-Verlag.

Shen, X. and Wasserman, L. (2001). Rates of convergence of posterior distributions. The Annals of Statistics 29 687–714.

Shorack, G. R. and Wellner, J. A. (1986). Empirical Processes With Applications to Statistics. Wiley.

Silverman, B. W. (1986). Density Estimation for Statistics and Data Analysis. Chapman & Hall.

Spirtes, P., Glymour, C. N. and Scheines, R. (2000). Causation, prediction, and search. MIT Press.

Taylor, H. M. and Karlin, S. (1994). An Introduction to Stochastic Modeling. Academic Press.

van der Laan, M. and Robins, J. (2003). Unified Methods for Censored Longitudinal Data and Causality. Springer Verlag.

van der Vaart, A. W. (1998). Asymptotic Statistics. Cambridge University Press.

van der Vaart, A. W. and Wellner, J. A. (1996). Weak Convergence and Empirical Processes: With Applications to Statistics. Springer-Verlag.

Vapnik, V. N. (1998). Statistical Learning Theory. Wiley.

Weisberg, S. (1985). Applied Linear Regression. Wiley.

Whittaker, J. (1990). Graphical Models in Applied Multivariate Statistics. Wiley.

Wright, S. (1934). The method of path coefficients. The Annals of Mathematical Statistics 5 161–215.

Zhao, L. H. (2000). Bayesian aspects of some nonparametric problems. The Annals of Statistics 28 532–552.

Zheng, X. and Loh, W.-Y. (1995). Consistent variable selection in linear models. Journal of the American Statistical Association 90 151–156.

List of Symbols

General Symbols

ℝ

real numbers

infx∈A f(x)

infimum: the largest number y such that y ≤ f(x) for all x ∈ A

think of this as the minimum of f

supx∈A f(x)

supremum: the smallest number y such that y ≥ f(x) for all x ∈ A

think of this as the maximum of f

n!

n × (n − 1) × (n − 2) × ⋯ × 3 × 2 × 1

Γ(α)

Gamma function

Ω

sample space (set of outcomes)

ω

outcome, element, point

A

event (subset of Ω)

IA(ω)

indicator function; 1 if ω ∈ A and 0 otherwise

|A|

number of points in set A

Probability Symbols

ℙ(A)

probability of event A

A ∐ B

A and B are independent

A and B are dependent

FX

cumulative distribution function FX(x) = ℙ(X ≤ x)

fX

probability density (or mass) function

X ∼ F

X has distribution F

X ∼ f

X has density f

X and Y have the same distribution

iid

independent and identically distributed

X₁,..., Xn ∼ F

iid sample of size n from F

ϕ

standard Normal probability density

Φ

standard Normal distribution function

zα

upper α quantile of N(0, 1): zα = Φ⁻¹ (1 − α)

expected value (mean) of random variable X

expected value (mean) of r(X)

variance of random variable X

Cov(X, Y)

covariance between X and Y

X₁,..., Xn

data

n

sample size

Convergence Symbols

convergence in probability

convergence in distribution

convergence in quadratic mean

xn = o(an)

xn/an → 0

xn = O(an)

|xn/an| is bounded for large n

Xn = oP(an)

Xn/an 0

Xn = OP(an)

|Xn/an| is bounded in probability for large n

Statistical Models

statistical model; a set of distribution functions, density functions or regression functions

θ

parameter

estimate of parameter

T(F)

statistical functional (the mean, for example)

likelihood function

Useful Math Facts

Stirling’s approximation:

The Gamma function. The Gamma function is defined by

for α ≥ 0. If α > 1 then Γ(α) = (α − 1)Γ(α − 1). If n is a positive integer then Γ(n) = (n − 1)!. Some special values are: Γ(1) = 1 and .

Table of Distributions