97
Hierarchical Bayes Peter Lenk Stephen M Ross School of Business at the University of Michigan September 2004

Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

Hierarchical Bayes

Peter LenkStephen M Ross School of Business at the

University of MichiganSeptember 2004

Page 2: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

2

Outline

• Bayesian Decision Theory• Simple Bayes and Shrinkage Estimates• Hierarchical Bayes• Numerical Methods• Batting Averages• HB Interaction Model

Page 3: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

3

Bayesian Decision Model

Actions States ConsequencesDecisionModel

PosteriorUpdating

Result Optimal Decision: Marketing Action & Inference

Integration

Prior Likelihood

LossFunction

InferenceModelSeparable Parts:Don’t mix them Bayes

Theorem

Page 4: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

4

Bayes Theorem

• Model for the data given parameters– f(y |θ) were θ = unknown parameters– E.g. Yi = µ + εi and θ = (µ,σ)– Likelihood l(θ) = f(y1 |θ) f(y2 |θ)… f(yn |θ)

• Prior distribution of parameters p(θ)• Update prior

– p(θ|Data ) = l(θ)p(θ)/f(y)– f(y) = marginal distribution of data

Page 5: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

5

Easy Example:

• Estimate mean from a normal distribution.• Yi = µ + εi

• Error terms {εi} are iid normal– Mean is zero– Standard deviation of error terms is σ.– Assume that σ is known

Page 6: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

6

Conjugate Prior for Mean

• Prior distribution for µ is normal– Prior mean is m0

– Prior variance is v02

– Precision is 1/ v02

Page 7: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

7

Posterior Distribution

20

2

2

20

2

2

0

11

10 and 1

)1(

vnv

w

vn

n

w

mwywm

n

n

+=

<<+

=

−+=

σ

σ

σ

• Observe n data points• Posterior distribution

is normal– Mean is mn

– Variance is vn2

Page 8: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

8

Shrinkage Estimators

• Bayes estimators combines prior guesses with sample estimates

• If the prior precision is larger than sample precision (prior has more information), then put more weight on prior mean.

• If the sample precision is larger the prior precision (sample has more information), then put more weight on sample average

Page 9: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

9

Example

• Y is normal with mean 10 and Variance 16• Normal prior for the population mean

– Mean = 5 & Variance = 2– Prior is informative and way off

• Data– n = 5, Average = 10.9, Variance = 14.7

• Posterior is normal– Mean = 7.4 and variance is 1.2

Page 10: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

10

Prior & Posterior n=5

00.10.20.30.40.5

0 5 10 15

Mean

Prior Posterior Likelihood

Prior MeanSample Mean

Posterior Mean

Page 11: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

11

Prior & Posterior n=50

00.20.40.60.8

1

0 5 10 15

Mean

Prior Posterior Likelihood

Page 12: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

12

Use Less Informative Prior

• Y is normal with mean 10 and Variance 16• Normal prior for the population mean

– Mean = 5 & Variance = 10 instead of 2– Prior is “flatter”

• Data– n = 5, Average = 10.9, Variance = 14.7

• Posterior is normal– Mean = 9.6 and variance is 2.3

Page 13: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

13

Prior & Posterior n=5

00.10.20.30.40.5

0 5 10 15

Mean

Prior Posterior Likelihood

Page 14: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

14

Prior & Posterior n=50

00.20.40.60.8

1

0 5 10 15

Mean

Prior Posterior Likelihood

Page 15: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

15

Summary

• Prior has less effect as sample size increases

• Very informative priors give good results with smaller samples if prior information is correct

• If you really don’t know, then use “flatter” or less informative priors

Page 16: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

16

What about Marketing?

• HB revolution in how we think about customers

Page 17: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

17

Henry FordAll Customers are the Same

Page 18: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

18

Alfred SloanSeveral Common Preferences

Page 19: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

19

Continuous Heterogeneity

Page 20: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

20

Profit Maximization

Page 21: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

21

It Can Get Wild!

Page 22: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

22

HB Model for Weekly Spending

• Within-subject model:Yi,j = µi + εi,j and var(εi,j) = σi

2

• Heterogeneity in mean weekly spending or between-subjects

µi = θ + δi and var(δi) = τ2

• Prior Distributionθ is N(u0,v0

2)• Variances are known

Page 23: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

23

Variances & Covariances

• Var(Yi,j| µi) = σi2 (known µi)

• Var(Yi,j|θ) = τ2 + σi2 (unknown µi)

• Cov(Yi,j, Yi,k) = τ2 for j not equal to k• Observations from different subjects are

independent

Page 24: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

24

Precisions = 1/Variance

( )

( )

( ) ( )

( ) ( )n

YnY

YY

v

ii

iii

iji

iiji

i

22

2

22,2,

2

20

1|Pr and|Pr

1|Pr and1|Pr

1|Pr

precisionprior is 1Pr

στθ

σµ

στθ

σµ

τθµ

θ

+==

+==

=

=

Page 25: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

25

Joint Distribution

( )

( ) ( ) ( )∏∏==

=in

jiiji

N

ii yfgvuh

YP

1

2,

1

2200 ,|,|,|

,,

σµτθµθ

θµ

Prior Between Subjects Within Subjects

Page 26: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

26

Bayes Theorem

( ) ( )( )

( ) ( )( )

( ) ( )θµθµ

θµθµ

θµθµθµθµ

,,|,

,,|,

,,,,|,

YPYPYP

YPYP

ddYPYPYP

=

=∫∫

Constant because Y is fixed & known

Page 27: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

27

Bayes Estimator

• Posterior means are optimal under squared error loss

E(µi|Y) and E(θ|Y)

• Measure of accuracy is posterior variancevar(µi|Y) and var(θ|Y)

Page 28: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

28

Posterior Distribution of θ

• Normal distribution• Posterior mean is uN

• Posterior variance is vN2

• Posterior precision is Pr(θ|Y) = 1/vN2

Page 29: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

29

Posterior Precision of θ “Pr” = Precision = 1/Variance

( ) ( )

( ) ( )

i

ii

N

ii

n

Yv

YY

22

20

1

1|Pr and 1Pr

|Pr)Pr(|Pr

στθθ

θθθ

+==

+= ∑=

Page 30: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

30

Posterior Mean of θ

( )( )( )YYw

Yw

Ywuwu

ii

N

iiiN

|Pr|Pr and

|Pr)Pr(

0

100

θθ

θθ

==

+= ∑=

Page 31: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

31

Updating of θ

• Prior Mean Posterior Meanu0 uN

• Prior Var Posterior Varv0

2 vN2

Page 32: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

32

Posterior Mean of µi

[ ] ( )

( )( ) ( )

22

2

1|Pr|Pr|Pr

1|

i

i

i

i

iii

iii

Niiii

n

n

YY

uYYE

στ

σµθµ

µα

ααµ

+=

+=

−+=

Page 33: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

33

Between-Subject Heterogeneity in Mean Household Spending

0.0

0.1

0.2

0.3

0.4

0 10 20 30 40 50 60

Spending

Dis

trib

utio

n

Heterogeneity

Page 34: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

34

Between & Within Subjects Distributions

0.0

0.1

0.2

0.3

0.4

0 10 20 30 40 50 60

Spending

Dis

trib

utio

nHeterogeneity Subject 1 Subject 2 Subject 3

Page 35: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

35

2 Observations per Subject

0.0

0.1

0.2

0.3

0.4

0 10 20 30 40 50 60

Spending

Dis

trib

utio

n

Heterogeneity Subject 1 Subject 2 Subject 3

Page 36: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

36

Subject Averages

0.0

0.1

0.2

0.3

0.4

0 10 20 30 40 50 60

Spending

Dis

trib

utio

n

Heterogeneity Subject 1 Subject 2 Subject 3

Page 37: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

37

Pooled Estimate of Mean

0.0

0.1

0.2

0.3

0.4

0 10 20 30 40 50 60

Spending

Dis

trib

utio

nHeterogeneity Subject 1 Subject 2 Subject 3

Pooled estimate of population average spending

Page 38: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

38

Sample Estimates

• Disaggregate estimate of µi only uses the observations for subject i.– Super if 30 or more observations per subject

• Pooled or aggregate estimator of θ– Smaller sampling error– Ignores individual difference

iY

Y

Page 39: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

39

HB Shrinkage Estimator• Take combination of individual average and pooled

average

• What are the correct weights?• HB automatically gives optimal weights based on

– Prior variance of µi

– Number of observations for subject i – Variance of past spending for subject i – Number of subjects– Amount of heterogeneity in household means

( )YwYw iii −+ 1

Page 40: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

40

Shrinkage Estimates

0.0

0.1

0.2

0.3

0.4

0 10 20 30 40 50 60

Spending

Dis

trib

utio

n

Heterogeneity Subject 1 Subject 2 Subject 3

Page 41: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

41

20 Observations per Subject

0.0

0.1

0.2

0.3

0.4

0 10 20 30 40 50 60

Spending

Dis

trib

utio

n

Heterogeneity Subject 1 Subject 2 Subject 3

Page 42: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

42

Bayes & Shrinkage Estimates

• Bayes estimators automatically determine the optimal amount of shrinkage to minimize MSE for true parameters and predictions

• Borrows strength from all subjects• Tradeoff some bias for variance reduction

Page 43: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

43

Good & Bad News

• Only simple models result in equations• Models we use in marketing require

numerical methods to compute posterior mean, posterior standard deviations, predictions and so on.

Page 44: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

44

Numerical Integration

• Compute posterior mean of function T(θ).

( )[ ] ( ) ( ) θθθθ dypTyTE ∫= ||

Page 45: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

45

T(x) and f(x)

0

1

2

3

4

5

0 0.25 0.5 0.75 1

X

T(x)f(x)

0123456789

10

0 0.2 0.4 0.6 0.8 1

X

Page 46: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

46

Trapezoid RuleT(x)f(x)

0123456789

10

0 0.2 0.4 0.6 0.8 1

X

Page 47: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

47

Grid Methods

• Very accurate with few functional evaluations

• Need to know where the action is• Does not scale well to higher dimensions• You need to be very smart to make it work

Page 48: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

48

Monte Carlo

• Generate random draws θ1, θ2, …, θm from posterior distribution using a random number generator.

• What happened to the density of θ?

( )[ ] ( )∑=

≈m

jjT

myTE

1

1| θθ

Page 49: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

49

Good & Bad News

• If your computer has a random number generator for the posterior distribution, Monte Carlo is a snap to do.

• Your computer almost never has the correct random number generator.

Page 50: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

50

Importance Sampling

• Would like to sample from density f• You have a good random number

generator for the density g• Importance sampling lets you generate

random deviates from g to evaluate expectations with respect to f.

• Generate φ1, …, φm from g

Page 51: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

51

Importance Sampling Approximation

( ) ( ) ( ) ( )( ) ( )

( ) ( )

( )( ) ( )

( ) ( )( ) ( ) ( )

( )∑

∑∑

∫∫

=

=

=

=

=∝

=≈

=

m

jj

ii

i

ii

m

iiim

ii

m

iii

r

rwgfr

wTr

rT

dggfTdfT

1

1

1

1

andϕ

ϕϕϕϕϕ

ϕϕϕ

ϕϕ

ϕϕϕϕϕθθθ

Page 52: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

52

Markov Chain Monte Carlo

• Extension of Monte Carlo• Random draws are not independent• Joint distribution f(β,φ) does not have a

convenient random number generator.• Conditional distributions g(φ|β) and h(β|φ)

are easy to generate from.

Page 53: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

53

Iterative Generation from Full Conditionals

• Start at φ0

• Generate β1 from h(β|φ0) .• Generate φ1 from g(φ|β1).• …• Generate βm+1 from h(β|φm)• Generate φm+1 from g(φ|βm+1)

Page 54: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

54

Baseball Example

• 90 MLB Players in 2000 season.• Observe at bats (AB) and hits (BA) in May• Infer distribution of batting averages

across players.• Predict batting averages in October using

data from May.

Page 55: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

55

Baseball Batting Averages

263.26227.148Pena

542.26049.204Vizquel

546.31745.400Belle

436.32343.442Murray

ABBAABBA

OctoberMay

The Cleveland Indians - 1995

Page 56: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

56

Estimating a Probability

• n at bats in May• X = number of hits • p = batting average for season• X has a binomial distribution

– mean np– variance np(1-p)

Page 57: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

57

Binomial Distribution

0

0.02

0.04

0.06

0.08

0.1

0.12

0.14

0 5 10 15 20 25 30 35 40 45 50

Sample Successes

Prob

abili

ty

mean = 15.00 STD = 3.24n = 50 p = 0.3

Page 58: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

58

Need Prior for Batting Average p

• 0 < p < 1• Beta distribution is popular choice• It has two parameters: α and β• Density is proportional to pα-1(1-p)β-1

• Prior Mean = α/(α+β)

Page 59: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

59

Beta Prior for p

[ ]

( )( ) ( ) ( ) 101

),|(,|

11 ≤≤−ΓΓ+Γ

=

=

−− pforpp

pBetapf

βα

βαβα

βαβα

( ) ∫∞

−−=Γ0

1 dxex xαα

Page 60: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

60

Mean and Variance

[ ]1

)(1)()(

)(

++−

=

+=

βα

βαα

pEpEpV

pE

Page 61: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

61

Beta Distribution

0

0

0

1

1

1

1

0.00 0.25 0.50 0.75 1.00

P

Den

sity

alpha = 1 beta = 1 mean = 0.50

Page 62: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

62

Beta Distribution

0

1

2

3

4

5

6

0.00 0.25 0.50 0.75 1.00

P

Den

sity

alpha = 5 beta = 1 mean = 0.83

Page 63: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

63

Beta Distribution

01122334

0.00 0.25 0.50 0.75 1.00

P

Den

sity

alpha = 5 beta = 10 mean = 0.33

Page 64: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

64

Beta Distribution

0

2

4

6

8

10

12

0.00 0.25 0.50 0.75 1.00

P

Den

sity

alpha = 0.5 beta = 2 mean = 0.20

Page 65: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

65

Beta Distribution

0

1

2

3

4

5

0.00 0.25 0.50 0.75 1.00

P

Den

sity

alpha = 0.5 beta = 0.5 mean = 0.50

Page 66: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

66

Bayes Theorem: Update prior for p after observing n and x

( )

),|(

1

],|[]|Pr[

],|[]|Pr[

],|[]|Pr[],,|[

11

1

0

xnxpBeta

pp

pfpx

dqqfqx

pfpxxpf

xnx

−++=

−∝

=

−−+−+

βα

βα

βα

βαβα

βα

Page 67: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

67

Inference About P:Posterior is also Beta

PriorParameters

PosteriorParameters

α α+x

β β+n-x

Page 68: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

68

Posterior Mean of p:Its another shrinkage estimator

( )

nnw

nxp

wpw

nn

nnn

++==

−+

βα and ˆ

MeanPrior )1(ˆ

Page 69: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

69

p=Beta & x=Binomial

0.00

2.00

4.00

6.00

8.00

0.00 0.25 0.50 0.75 1.00

P

Den

sity

alpha = 5 beta = 15

prior mean = 0.25

N=50 & X = 18

PosteriorPrior

Page 70: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

70

Hierarchical Bayes Model

• Variation within batter i:– Xi given pi has a binomial distribution

• Variation among batters:– pi is a beta distribution with parameters

α and β.• Prior distribution for α and β

– Gamma (chi-square) distribution

Page 71: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

71

Gamma Distribution

sYEYVand

srYE

yforeyrs

sryGyg

syrr

1)()()(

0)(

),|()(

1

==

=

=

−−

Page 72: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

72

Gamma Distribution

0

0.02

0.04

0.06

0.08

0.1

0.12

0 10 20 30 40 50

X

Dens

ityalpha = 1 beta = 0.1

mean = 10.00

STD = 10.00

Page 73: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

73

Gamma Distribution

0

0.01

0.02

0.03

0.04

0.05

0.06

0.07

0 10 20 30 40 50

X

Dens

ityalpha = 10 beta = 0.5

mean = 20.00

STD = 6.32

Page 74: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

74

Specify Prior Parameters:r, s, u & v

• Priors: α is G(r,s) & β is G(u,v).• E(α) = r/s and V(α) = E(α)/s.• s determines variance relative to mean.• I used s = 0.25 or the variance is four

times larger than the mean.• Same for v.

Page 75: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

75

[ ]

0

),|()(

pur

rpEEpE

=+

=

= βα [ ] ( )1

1),|( 00

++−

==urpp

pEVc βα

( )

( ) ( )

−−=

−=

11

1

11

000

000

cpp

pu

andcpp

pr

Page 76: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

76

Specify Prior Parameters

• Guess a mean of all batting averages: p0 = 0.25

• Measure of my uncertainty of that guess:c = 0.01

• Parameter r = 4.4• Parameter u = 13.3

Page 77: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

77

MCMC for Batting Averages

• Need full conditionals for pi give α and β– Beta distribution

• Need full conditionals for α and β given pi.

– Unknown distribution– Use Metropolis algorithm

Page 78: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

78

MCMC: Full Conditionals for Player i Batting Average pi

[ ] ( ) ( )

( )

( )iiii

xni

xai

iiiii

xnxpBeta

pp

pfpxxpf

iii

−++=

−∝

−−+−+

βα

βαβα

β

,|

1

,||Pr,,|

11

Page 79: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

79

MCMC: Full Conditional for α and β

( )

( ) ( ) ( )∏=

−− −∝n

iii

nn

vugsrgpp

ppxxg

1

11

11

,|,|1

,,,|,

βα

βα

βα

KK

Page 80: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

80

Metropolis Algorithm

• Want to generate θ from f• Instead, generate candidate value φ from

g(.|θ)– Density g can depend on θ– eg Random walk: φ = θ + δ

• With probability α(θ,φ) accept φ as the new value of θ

• With probability 1−α(θ,φ) keep θ

Page 81: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

81

Transition Probability

( ) ( ) ( )( ) ( )

= 1,||max,θϕθϕθϕϕθα

gfgf

• f is the full conditional density of θ• Ratios: do not need to know constants• Usually compute α on log scale.• Works if densities are not zero• Works better if g is close to f

Page 82: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

82

Alpha and Beta vs Iteration

0

20

40

60

80

100

120

0 500 1000 1500 2000

MCMC Iteration

Para

met

er

BETA

ALPHA

Page 83: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

83

Posterior of Alpha

0102030405060708090

15 17 18 20 22 24 25 27 29 31 32 34 36 38 40 41

Alpha

Freq

uenc

y

Page 84: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

84

Posterior of Beta

0102030405060708090

38 44 51 58 64 71 78 85 91 98 105

Beta

Freq

uenc

y

Page 85: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

85

Parameters Estimates

(11.7)(14.6)(std)

68.253.2β

(4.6)(8.4)(std)

26.217.8α

PosteriorPrior

Page 86: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

86

Distribution of Batting Averages

0

2

4

6

8

10

0 0.2 0.4 0.6 0.8 1

Batting Average

Den

sity

PriorPosterior after May

Page 87: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

87

Prediction of Season Averages

9.4%0.032Bayes

17.0%0.060MLE

MAPERMSE

Page 88: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

88

Batting AveragesBayes Shrinks MLE

0

0.1

0.2

0.3

0.4

0.5

0 0.1 0.2 0.3 0.4 0.5

May 2000

Seas

on 2

000

MLEBayes

Page 89: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

89

HB ConjointLenk, DeSarbo, Green, Young (1996)

• Evaluated computer profiles on a 0 to 10 scale for “likelihood to purchase”– 0 = Would not buy– 10 = Would definitely buy

• Design– 178 subjects– 13 attributes with two levels each– 20 profiles per subject

Page 90: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

90

Attributes: Effect Coding

1. Hotline support2. RAM3. Screen Size4. CPU5. Hard Disk6. Multimedia7. Cache

8. Color9. Retail Store10.Warrantee11.Software12.Guarantee13.Price

Page 91: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

91

Subject-Covariates

• Female: 1 if female and 0 if male• Years: # years of work experience• Own: 1 if has computer & 0 else• Nerd: 1 if technical background & 0 else• Apply: # of software applications• Expert: self-report expertise rating

Page 92: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

92

Summary Statistics for Covariates

Variable Mean Std Dev MIN MAXFEMALE 0.275 0.448 0 1YEARS 4.416 2.369 1 18OWN 0.876 0.330 0 1NERD 0.275 0.448 0 1APPLY 4.287 1.574 1 9EXPERT 7.618 1.902 3 10

Page 93: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

93

Interaction Model

• Within-Subjects

• Between-Subjects Heterogeneity

[ ] ( )mimi

iiii

IN

niXY2,0|

,,1for

σεε

εβ

=

=+= K

[ ] ( )∆=+Θ′=

,0|ipi

iii

Nz

δδδβ

Page 94: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

94

Average over Posterior Means and Std Dev of Partworths Across

Subjects

PostMean PostSTD PostMean PostSTDCNST 4.757 1.404 Cache 0.031 0.461HotLine 0.095 0.487 Color 0.026 0.371RAM 0.347 0.467 Dstrbtn 0.078 0.378ScrnSz 0.193 0.405 Wrrnty 0.124 0.392CPU 0.392 0.646 Sftwr 0.196 0.399HrdDsk 0.171 0.501 Grntee 0.112 0.427MultMd 0.494 0.574 Price -1.127 0.873

Page 95: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

95

Impact of Covariates on Partworths

CNST RAM CPU Dstrbtn Wrrnty Grntee PriceCNST 3.74 0.52 -0.15 0.05 -0.01 0.03 -1.55FEMALE -0.10 0.06 0.12 0.40YEARS -0.11OWN -0.10 0.17 0.17 0.20 -0.12 -0.20NERD -0.27 0.15 0.16 -0.14APPLY 0.10EXPERT 0.17

Page 96: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

96

Summary

• HB allows individual-level coefficients• Two level model

– With-in subjects– Between subjects (heterogeneity)

• HB shrinks unstable, subject-level estimators to population mean

Page 97: Hierarchical Bayeswebuser.bus.umich.edu/plenk/Bayes Overview 1.pdf · Baseball Example • 90 MLB Players in 2000 season. • Observe at bats (AB) and hits (BA) in May ... Baseball

97

Summary

• BDT provides integrated framework for making decisions and inference

• Good models consider all sources of uncertainty

• Good methods keep track of all sources of uncertainty

• Bayes does both