Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA...

70
Tests Jean-Yves Le Boudec

Transcript of Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA...

Page 1: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

Tests

Jean-Yves Le Boudec

Page 2: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

Contents

1. The Neyman Pearson framework

2. Likelihood Ratio Tests

3. ANOVA

4. Asymptotic Results

5. Other Tests

2

Page 3: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

Tests

Tests are used to give a binary answer to hypotheses of a statistical natureEx: is A better than B?

Ex: does this data come from a normal distribution ?

Ex: does factor n influence the result ?

3

Page 4: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

Example: Non Paired Data

Is red better than blue ?

For data set (a) answer is clear (by inspection of confidence interval) no test required

4

Page 5: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

Is this data normal ?

5

Page 6: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

5.1 The Neyman-Pearson Framework

6

Page 7: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

Example: Non Paired Data

7

Is red better than blue ?

Page 8: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

Critical Region, Size and Power

8

Page 9: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

Example : Paired Data

9

Page 10: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

Power

10

Page 11: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

11

Grey Zone

Page 12: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

12

Page 13: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

p-value of a test

13

Page 14: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

14

Page 15: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

Tests are just tests

15

Page 16: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

Test versus Confidence Intervals

If you can have a confidence interval, use it instead of a test

16

Page 17: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

2. Likelihood Ratio Test

A special case of Neyman-Pearson

A Systematic Method to define tests, of general applicability

17

Page 18: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

18

Page 19: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

19

Page 20: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

A Classical Test: Student Test

The model :

The hypotheses :

20

Page 21: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

21

Page 22: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

22

Page 23: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

Here it is the same as a Conf. Interval

23

Page 24: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

The “Simple Goodness of Fit” Test

Model

Hypotheses

24

Page 25: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

1. compute likelihood ratio statistic

25

Page 26: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

2. compute p-value

26

Page 27: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

Mendel’s Peas

P= 0.92 ± 0.05 => Accept H0

27

Page 28: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

3 ANOVA

Often used as “Magic Tool”

Important to understand the underlying assumptions

ModelData comes from iid normal sample with unknown means and same variance

Hypotheses

28

Page 29: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

29

Page 30: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

30

Page 31: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

The ANOVA Theorem

We build a likelihood ratio statistic test

The assumption that data is normal and variance is the same allows an explicit computation

it becomes a least square problem = a geometrical problem

we need to compute orthogonal projections on M and M0

31

Page 32: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

The ANOVA Theorem

32

Page 33: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

Geometrical InterpretationAccept H0 if SS2 is small

The theorem tells us what “small” means in a statistical sense

33

Page 34: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

34

Page 35: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

ANOVA Output: Network Monitoring

35

Page 36: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

The Fisher-F distribution

36

Page 37: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

37

Page 38: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

Compare Test to Confidence Intervals

For non paired data, we cannot simply compute the differenceHowever CI is sufficient for parameter set 1

Tests disambiguate parameter sets 2 and 3

38

Page 39: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

Test the assumptions of the test…Need to test the assumptions

Normal In each group: qqplot…

Same variance

39

Page 40: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

40

Page 41: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

4 Asymptotic Results

41

2 x Likelihood ratio statistic

Page 42: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

42

Page 43: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

The chi-square distribution

43

Page 44: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

Asymptotic Result

Applicable when central limit theorem holds

If applicable, radically simpleCompute likelihood ratio statistic

Inspect and find the order p (nb of dimensions that H1 adds to H0)

This is equivalent to 2 optimization subproblems

lrs = = max likelihood under H1 - max likelihood under H0

The p-value is

44

Page 45: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

Composite Goodness of Fit Test

We want to test the hypothesis that an iid sample has a distribution that comes from a given parametric family

45

Page 46: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

Apply the Generic Method

Compute likelihood ratio statistic

Compute p-value

Either use MC or the large n asymptotic

46

Page 47: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

47

Page 48: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

Is it normal ?

48

Page 49: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

49

Page 50: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

50

Page 51: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

Mendel’s Peas

P= 0.92 ± 0.05 => Accept H0

51

Page 52: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

Test of Independence

Model

Hypotheses

52

Page 53: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

Apply the generic method

53

Page 54: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

54

Page 55: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

5 Other TestsSimple Goodness of Fit

Model: iid data

Hypotheses: H0 common distrib has cdf F()H1 common distrib is anything

Kolmogorov-Smirnov: under H0, the distribution of

is independent of F()

55

Page 56: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

56

Page 57: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

Anderson-Darling

An alternative to K-S, less sensitive to “outliers”

57

Page 58: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

58

Page 59: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

59

Page 60: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

Jarque Bera test of normality (Chapter 4)

Based on Kurtosis and SkewnessShould be 0 for normal distribution

60

Page 61: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

61

Page 62: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

Robust TestsMedian Test

Model : iid sample

Hypotheses

62

Page 63: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

Median Test

63

Page 64: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

Wilcoxon Signed Rank Test

64

Page 65: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

Wilcoxon Rank Sum Test

Model: Xi and Yj independent samples, each is iid

Hypotheses: H0 both have same distributionH1 the distributions differ by a location shift

65

Page 66: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

Wilcoxon Rank Sum Test

66

Page 67: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

Turning Point

67

Page 68: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

Questions

What is the critical region of a test ?

What is a type 1 error ? Type 2 ? The size of a test ?

What is the p-value of a test ?

68

Page 69: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

Questions

What are the hypotheses for ANOVA ?

How do you compute a p-value by Monte Carlo simulation ?

A Monte Carlo simulation returns p = 0; what can we conclude ?

What is a likelihood ratio statistic test ? What can we say about its p-value ?

69

Page 70: Tests Jean-Yves Le Boudec. Contents 1.The Neyman Pearson framework 2.Likelihood Ratio Tests 3.ANOVA 4.Asymptotic Results 5.Other Tests 1.

We have data X_1,…,X_m and Y_1, …,Y_m. Explain how we can compute the p-value of a test that compares the variance of the two samples ?

We have a collection of random variables X[i,j] that corresponds to the result of the ith simulation when the machine uses configuration j. How can you test whether the configuration plays a role or not ?

70