29
Bayesian Inference, Review 4/25/12 • Frequentist inference • Bayesian inference • Review The Bayesian Heresy (pdf ) Professor Kari Lock Morgan Duke University

Bayesian Inference, Review 4/25/12 Frequentist inference Bayesian inference Review The Bayesian Heresy (pdf)pdf Professor Kari Lock Morgan Duke University

Embed Size (px)

Citation preview

Page 1: Bayesian Inference, Review 4/25/12 Frequentist inference Bayesian inference Review The Bayesian Heresy (pdf)pdf Professor Kari Lock Morgan Duke University

Bayesian Inference,Review4/25/12

• Frequentist inference• Bayesian inference• Review

The Bayesian Heresy (pdf) Professor Kari Lock MorganDuke University

Page 2: Bayesian Inference, Review 4/25/12 Frequentist inference Bayesian inference Review The Bayesian Heresy (pdf)pdf Professor Kari Lock Morgan Duke University

• Project 2 Paper (Today, 5pm)

• Project 2 peer evaluations (Friday, 5pm)

• FINAL: Monday, 4/30, 9 – 12

To Do

Page 3: Bayesian Inference, Review 4/25/12 Frequentist inference Bayesian inference Review The Bayesian Heresy (pdf)pdf Professor Kari Lock Morgan Duke University

Breast Cancer Screening(positive if cancer) (cancer)

(cancer if positive)(positive)

P PP

P

• 1% of women at age 40 who participate in routine screening have breast cancer.

• 80% of women with breast cancer get positive mammographies.

• 9.6% of women without breast cancer get positive mammographies.

0.8(cancer if positive) 0.078

0.1

0.0

08

1P

Page 4: Bayesian Inference, Review 4/25/12 Frequentist inference Bayesian inference Review The Bayesian Heresy (pdf)pdf Professor Kari Lock Morgan Duke University

4

Cancer

Cancer-free

Positive ResultNegative Result

If we randomly pick a ball from the Cancer bin, it’s more likely to be red/positive.

If we randomly pick a ball the Cancer-free bin, it’s more likely to be green/negative.

EveryoneWe randomly pick a ball from the Everyone bin.

C

C

C

C

C

F F F F F F F F F F F FF F F F F F F F F F FF F F F F F F F F FF F F F F F F F FF F F F F F F FF F F F F F FF F F F F FF F F F F

If the ball is red/positive, is it more likely to be from the Cancer or Cancer-free bin?

Page 5: Bayesian Inference, Review 4/25/12 Frequentist inference Bayesian inference Review The Bayesian Heresy (pdf)pdf Professor Kari Lock Morgan Duke University

5

100,000 women in the population

1%

Thus, 800/(800+9,504) = 7.8% of positive results have cancer

1000 have cancer 99,000 cancer-free

99%

80% 20%

800 testpositive

200 testnegative

9.6% 90.4%

9,504 testpositive

89,496 testnegative

Page 6: Bayesian Inference, Review 4/25/12 Frequentist inference Bayesian inference Review The Bayesian Heresy (pdf)pdf Professor Kari Lock Morgan Duke University

HypothesesH0 : no cancerHa : cancer

Data: positive mammography

p-value = P(statistic as extreme as observed if H0 true) = P(positive mammography if no cancer) = 0.096

The probability of getting a positive mammography just by random chance, if the woman does not have cancer, is 0.096.

Page 7: Bayesian Inference, Review 4/25/12 Frequentist inference Bayesian inference Review The Bayesian Heresy (pdf)pdf Professor Kari Lock Morgan Duke University

HypothesesH0 : no cancerHa : cancer

Data: positive mammography

You don’t really want the p-value, you want the probability that the woman has cancer!

You want P(H0 true if data), not P(data if H0 true)

Page 8: Bayesian Inference, Review 4/25/12 Frequentist inference Bayesian inference Review The Bayesian Heresy (pdf)pdf Professor Kari Lock Morgan Duke University

HypothesesH0 : no cancerHa : cancer

Data: positive mammography

Using Bayes Rule:P(Ha true if data) = P(cancer if data) = 0.078P(H0 true if data) = P(no cancer | data) = 0.922

This tells a very different story than a p-value of 0.096!

Page 9: Bayesian Inference, Review 4/25/12 Frequentist inference Bayesian inference Review The Bayesian Heresy (pdf)pdf Professor Kari Lock Morgan Duke University

Frequentist Inference• Frequentist Inference considers what would happen if the data collection process (sampling or experiment) was repeated many times

• Probability is considered to be the proportion of times an event would happen if repeated many times

• In frequentist inference, we condition on some unknown truth, and find the probability of our data given this unknown truth

Page 10: Bayesian Inference, Review 4/25/12 Frequentist inference Bayesian inference Review The Bayesian Heresy (pdf)pdf Professor Kari Lock Morgan Duke University

Frequentist Inference• Everything we have done so far in class is based on frequentist inference

• A confidence interval is created to capture the truth for a specified proportion of all samples

• A p-value is the proportion of times you would get results as extreme as those observed, if the null hypothesis were true

Page 11: Bayesian Inference, Review 4/25/12 Frequentist inference Bayesian inference Review The Bayesian Heresy (pdf)pdf Professor Kari Lock Morgan Duke University

Bayesian Inference• Bayesian inference does not think about repeated sampling or repeating the experiment, but only what you can tell from your single observed data set

• Probability is considered to be the subjective degree of belief in some statement

• In Bayesian inference we condition on the data, and find the probability of some unknown parameter, given the data

Page 12: Bayesian Inference, Review 4/25/12 Frequentist inference Bayesian inference Review The Bayesian Heresy (pdf)pdf Professor Kari Lock Morgan Duke University

Fixed and Random• In frequentist inference, the parameter is considered fixed and the sample statistic is random

• In Bayesian inference, the statistic is considered fixed, and the parameter is considered random

Page 13: Bayesian Inference, Review 4/25/12 Frequentist inference Bayesian inference Review The Bayesian Heresy (pdf)pdf Professor Kari Lock Morgan Duke University

( if ) ( )( if )

( )

P data truth P truthP truth data

P data

Bayesian Inference

Frequentist: P(data if truth)

Bayesian: P(truth if data)

• How are they connected?

Page 14: Bayesian Inference, Review 4/25/12 Frequentist inference Bayesian inference Review The Bayesian Heresy (pdf)pdf Professor Kari Lock Morgan Duke University

( if ( ))

( )( if )P truth dat

P truthP data truth

Pa

data

Bayesian Inference

PRIOR ProbabilityPOSTERIOR

Probability

• Prior probability: probability of a statement being true, before looking at the data

• Posterior probability: probability of the statement being true, after updating the prior probability based on the data

Page 15: Bayesian Inference, Review 4/25/12 Frequentist inference Bayesian inference Review The Bayesian Heresy (pdf)pdf Professor Kari Lock Morgan Duke University

Breast Cancer

• Before getting the positive result from her mammography, the prior probability that the woman has breast cancer is 1%

• Given data (the positive mammography), update this probability using Bayes rule:

• The posterior probability of her having breast cancer is 0.078.

( if ) 0.8

( )

( ) 0.0

0.0.078

1

103

P data truth

P data

P truth

Page 16: Bayesian Inference, Review 4/25/12 Frequentist inference Bayesian inference Review The Bayesian Heresy (pdf)pdf Professor Kari Lock Morgan Duke University

Paternity• A woman is pregnant. However, she slept with two different guys (call them Al and Bob) close to the time of conception, and does not know who the father is.

• What is the prior probability that Al is the father?

• The baby is born with blue eyes. Al has brown eyes and Bob has blue eyes. Update based on this information to find the posterior probability that Al is the father.

Page 17: Bayesian Inference, Review 4/25/12 Frequentist inference Bayesian inference Review The Bayesian Heresy (pdf)pdf Professor Kari Lock Morgan Duke University

Eye Color• In reality eye color comes from several genes, and there are several possibilities but let’s simplify here:

• Brown is dominant, blue is recessive• One gene comes from each parent• BB, bB, Bb would all result in brown eyes• Only bb results in blue eyes

• To make it a bit easier: You know that Al’s mother and the mother of the child both have blue eyes.

Page 18: Bayesian Inference, Review 4/25/12 Frequentist inference Bayesian inference Review The Bayesian Heresy (pdf)pdf Professor Kari Lock Morgan Duke University

PaternityWhat is the probability that Al is the father?

a) 1/2b) 1/3c) 1/4d) 1/5e) No idea

Page 19: Bayesian Inference, Review 4/25/12 Frequentist inference Bayesian inference Review The Bayesian Heresy (pdf)pdf Professor Kari Lock Morgan Duke University

Paternity

(blue eyes if (Al if blue e

(Al =

(blue eyes)

)s)

Al)ye

P

PP

P

1/2Al must be Bb, so 1/2

P(blue eyes) = P(blue eyes and Al) + P(blue eyes and Bob)= P(blue eyes if Al) × P(Al) + P(blue eyes if Bob) × P(Bob)= 1/2 × 1/2 + 1 × 1/2 = 3/4

(Al if blue eyes)1/

2

= 3 / 4

1/ 2P

1

3

Page 20: Bayesian Inference, Review 4/25/12 Frequentist inference Bayesian inference Review The Bayesian Heresy (pdf)pdf Professor Kari Lock Morgan Duke University

Bayesian Inference• Why isn’t everyone a Bayesian?

• Need some “prior belief” for the probability of the truth

• Also, until recently, it was hard to be a Bayesian (needed complicated math.) Now, we can let computers do the work for us!

( if ) ( )( if )

( )

P data truth P truthP truth data

P data

???

Page 21: Bayesian Inference, Review 4/25/12 Frequentist inference Bayesian inference Review The Bayesian Heresy (pdf)pdf Professor Kari Lock Morgan Duke University

InferenceBoth kinds of inference have the same goal, and it is a goal fundamental to statistics:

to use information from the data to gain information about the unknown truth

Page 22: Bayesian Inference, Review 4/25/12 Frequentist inference Bayesian inference Review The Bayesian Heresy (pdf)pdf Professor Kari Lock Morgan Duke University

REVIEW

Page 23: Bayesian Inference, Review 4/25/12 Frequentist inference Bayesian inference Review The Bayesian Heresy (pdf)pdf Professor Kari Lock Morgan Duke University

Data Collection• The way the data are/were collected determines the scope of inference

• For generalizing to the population: was it a random sample? Was there sampling bias?

• For assessing causality: was it a randomized experiment?

• Collecting good data is crucial to making good inferences based on the data

Page 24: Bayesian Inference, Review 4/25/12 Frequentist inference Bayesian inference Review The Bayesian Heresy (pdf)pdf Professor Kari Lock Morgan Duke University

Exploratory Data Analysis• Before doing inference, always explore your data with descriptive statistics

• Always visualize your data! Visualize your variables and relationships between variables

• Calculate summary statistics for variables and relationships between variables – these will be key for later inference

• The type of visualization and summary statistics depends on whether the variable(s) are categorical or quantitative

Page 25: Bayesian Inference, Review 4/25/12 Frequentist inference Bayesian inference Review The Bayesian Heresy (pdf)pdf Professor Kari Lock Morgan Duke University

Estimation• For good estimation, provide not just a point estimate, but an interval estimate which takes into account the uncertainty of the statistic

• Confidence intervals are designed to capture the true parameter for a specified proportion of all samples

• A P% confidence interval can be created by

• bootstrapping (sampling with replacement from the sample) and using the middle P% of bootstrap statistics

• *statisti z Sc E

Page 26: Bayesian Inference, Review 4/25/12 Frequentist inference Bayesian inference Review The Bayesian Heresy (pdf)pdf Professor Kari Lock Morgan Duke University

Hypothesis Testing• A p-value is the probability of getting a statistic as extreme as observed, if H0 is true

• The p-value measures the strength of the evidence the data provide against H0

• “If the p-value is low, the H0 must go”

• If the p-value is not low, then you can not reject H0 and have an inconclusive test

Page 27: Bayesian Inference, Review 4/25/12 Frequentist inference Bayesian inference Review The Bayesian Heresy (pdf)pdf Professor Kari Lock Morgan Duke University

p-value• A p-value can be calculated by

• A randomization test: simulate statistics assuming H0 is true, and see what proportion of simulated statistics are as extreme as that observed

• Calculating a test statistic and comparing that to a theoretical reference distribution (normal, t, 2, F)

Page 28: Bayesian Inference, Review 4/25/12 Frequentist inference Bayesian inference Review The Bayesian Heresy (pdf)pdf Professor Kari Lock Morgan Duke University

Regression• Regression is a way to predict one response variable with multiple explanatory variables

• Regression fits the coefficients of the model

• The model can be used to

• Analyze relationships between the explanatory variables and the response

• Predict Y based on the explanatory variables

0 1 2 21 ... k k ix xxy

Page 29: Bayesian Inference, Review 4/25/12 Frequentist inference Bayesian inference Review The Bayesian Heresy (pdf)pdf Professor Kari Lock Morgan Duke University

What Next?

• If you are interested in learning more about

• REGRESSION AND MODELING: STAT 210

• PROBABILITY: STAT 230

• the MATHEMATICAL THEORY behind what we’ve learned: STAT 230, 250