bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_bf.pdf · 2011. 8....

42
Bayes factors, marginal likelihoods, and how to choose a population model Peter Beerli Department of Scientific Computing Florida State University, Tallahassee

Upload: others

Post on 27-Feb-2021

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what

Bayes factors, marginal likelihoods,and how to choose a population model

Peter BeerliDepartment of Scientific ComputingFlorida State University, Tallahassee

Page 2: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what

Overview

c©2009 Peter Beerli

1. Location versus Population

2. Bayes factors, what are they and how to calculate them

3. Marginal likelihoods, what are they and how to calculate them

4. Examples: simulated and real data

5. Resources: replicated runs, cluster computing

Page 3: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what
Page 4: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what

Location versus Population

c©2009 Peter Beerli

Page 5: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what

Location versus Population

c©2009 Peter Beerli

Page 6: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what

Location ≈ Population

c©2009 Peter Beerli

Page 7: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what

Location versus Population

c©2009 Peter Beerli

Page 8: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what

Location ?= Population

c©2009 Peter Beerli

Page 9: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what

Model comparison

c©2009 Peter Beerli

Several tests that establish whether two locations belong to the samepopulation exist. The test by Hudson and Kaplan (1995) seemed particularlypowerful even with a single locus.

These days researchers mostly use the program STRUCTURE to establish thenumber of populations.

A procedure that not only can handle panmixia versus all other gene flowmodels would help.

Page 10: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what

Model comparison

c©2009 Peter Beerli

4-parameters

3-parameters 2-parameters 1-parameter

For example we want to compare some of these models

Page 11: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what

Model comparison

c©2009 Peter Beerli

With a criterium such as likelihood we can compare nested models. Commonlywe use a likelihood ratio test (LRT) or Akaike’s information criterion (AIC) toestablish whether phylogenetic trees are statistically different or mutation modelshave an effect on the outcome, etc.

Kass and Raftery (1995) popularized the Bayes Factor as a Bayesian alternativeto the LRT.

Page 12: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what

Bayes factor

c©2009 Peter Beerli

In a Bayesian context we could look at the posterior odds ratio or equivalently theBayes factors.

p(M1|X) =p(M1)p(X|M1)

p(X)

p(M1|X)

p(M2|X)=

p(M1)

p(M2)× p(X|M1)

p(X|M2)

BF =p(X|M1)

p(X|M2)LBF = 2 ln BF = 2 ln

(p(X|M1)

p(X|M2)

)

The magnitude of BF gives us evidence against hypothesis M2

LBF = 2 ln BF = z

0 < |z| < 2 No real difference2 < |z| < 6 Positive6 < |z| < 10 Strong|z| > 10 Very strong

Page 13: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what

Marginal likelihood

c©2009 Peter Beerli

So why are we not all running BF analyses instead of the AIC, BIC, LRT?

Typically, it is rather difficult to calculate the marginal likelihoods with goodaccuracy, because most often we only approximate the posterior distribution usingMarkov chain Monte Carlo (MCMC).In MCMC we need to know only differences and therefore we typically do not needto calculate the denominator to calculate the Posterior distribution p(Θ|X):

p(Θ|X,M) =p(Θ)p(X|Θ)

p(X|M)=

p(Θ)p(X|Θ)∫Θ

p(Θ)p(X|Θ)dΘ

where p(X|M) is the marginal likelihood.

Page 14: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what

Harmonic mean estimatorMarginallikelihood

c©2009 Peter Beerli

[Common approximation, used in programs such a MrBayes and Beast]The harmonic mean estimator applied to our specific problem can be describedusing an importance sampling approach

p(X|M) =

∫G

p(X|G,Mi)p(G)dG∫G

p(G)dG

which is approximated after some shuffling wth expectations by

p(X|M) ' 11n

∑nj

1p(X|G,M)

, Gj ∼ p(G|X,M).

`H = ln p(X|M)

Page 15: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what

Harmonic mean estimatorMarginallikelihood

c©2009 Peter Beerli

[Common approximation, used in programs such a MrBayes and Beast]The harmonic mean estimator applied to our specific problem can be describedusing an importance sampling approach

p(X|M) =

∫G

p(X|G,Mi)p(G)dG∫G

p(G)dG

which is approximated after some shuffling wth expectations by

p(X|M) ' 11n

∑nj

1p(X|G,M)

, Gj ∼ p(G|X,M).

`H = ln p(X|M)

TheHar

monic

Mean

ofth

eLike

lihood:

Worst Monte

Carlo

Method

Ever

Radfor

d Neal 2

008

Page 16: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what

Thermodynamic integrationMarginallikelihood

c©2009 Peter Beerli

`T = ln p(X|Mi) =

∫ 1

0

E(ln pt(X|Mi))dt

which we approximate using the trapezoidal rule for t0 = 0 < t1 < ... < tn = 1using

E(ln pt(X|Mi)) ≈1

m

m∑j=1

ln ptz(X|Gj,Mi)

Path sampling: Gelman and Meng (1998), Friel and Pettitt (2007,2009)Phylogeny: Lartillot and Phillipe (2006),Wu et al (2011), Xie et al (2011) [Paul Lewis]Population genetics: Beerli and Palczewski 2010

Page 17: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what

Thermodynamic integrationMarginallikelihood

c©2009 Peter Beerli

0.0 0.2 0.4 0.6 0.8 1.0-2800

-2600

-2400

-2200

-2000

-1800ln L

Inverse temperature

Page 18: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what

Thermodynamic integrationMarginallikelihood

c©2009 Peter Beerli

0.0 0.2 0.4 0.6 0.8 1.0-2800

-2600

-2400

-2200

-2000

-1800ln L

Inverse temperature

Page 19: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what

Thermodynamic integrationMarginallikelihood

c©2009 Peter Beerli

0.0 0.2 0.4 0.6 0.8 1.0-2800

-2600

-2400

-2200

-2000

-1800ln L

Inverse temperature

Page 20: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what

Thermodynamic integrationMarginallikelihood

c©2009 Peter Beerli

0.0 0.2 0.4 0.6 0.8 1.0-2800

-2600

-2400

-2200

-2000

-1800ln L

Inverse temperature

Page 21: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what

Thermodynamic integrationMarginallikelihood

c©2009 Peter Beerli

0.0 0.2 0.4 0.6 0.8 1.0-2800

-2600

-2400

-2200

-2000

-1800ln L

Inverse temperature

Page 22: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what

Thermodynamic integrationMarginallikelihood

c©2009 Peter Beerli

0.0 0.2 0.4 0.6 0.8 1.0� 2800

� 2600

� 2400

� 2200

� 2000

� 1800ln L

Inverse temperature

Page 23: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what

Thermodynamic integrationMarginallikelihood

c©2009 Peter Beerli

0.0 0.2 0.4 0.6 0.8 1.0� 2800

� 2600

� 2400

� 2200

� 2000

� 1800ln L

Inverse temperature

Page 24: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what
Page 25: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what

Bayes factorSimulationresults

c©2009 Peter Beerli

- 80

- 60

- 40

-- 20

20

40

- 80

- 60

- 40

- 20

20 100

200

300

400

500

600

2000

4000

6000

8000

10000

12000

LBF

(2ln

BF

)

LBF= 2 ln p(X|M1)p(X|M2) = 2 ln

p

(X|

)

p

X|

Page 26: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what

Bayes factorSimulationresults

c©2009 Peter Beerli

- 80

- 60

- 40

-- 20

20

40

- 80

- 60

- 40

- 20

20 100

200

300

400

500

600

2000

4000

6000

8000

10000

12000

LBF

(2ln

BF

)

LBF= 2 ln p(X|M1)p(X|M2) = 2 ln

p

(X|

)

p

X|

Page 27: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what

Bayes factorSimulationresults

c©2009 Peter Beerli

- 80

- 60

- 40

-- 20

20

40

- 80

- 60

- 40

- 20

20 100

200

300

400

500

600

2000

4000

6000

8000

10000

12000

LBF

(2ln

BF

)

LBF= 2 ln p(X|M1)p(X|M2) = 2 ln

p

(X|

)

p

X|

Page 28: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what

Bayes factorSimulationresults

c©2009 Peter Beerli

- 80

- 60

- 40

-- 20

20

40

- 80

- 60

- 40

- 20

20 100

200

300

400

500

600

2000

4000

6000

8000

10000

12000

LBF

(2ln

BF

)

LBF= 2 ln p(X|M1)p(X|M2) = 2 ln

p

(X|

)

p

X|

Page 29: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what

Bayes factorSimulationresults

c©2009 Peter Beerli

Percent of Models

LBF = 2 ln p(X|M1)

p

(X|

)

Param. 4 3 3 2 1 3 2 2

Modelxxxx xmmx mxxm mmmm x x0xx m0xm mx0m

Rejected 100 100 100 100 97 71 46 29Accepted 0 0 0 0 3 29 54 71

Total 20 sequences with length of 1000 bpParameters used to generate data:Θi = 4N

(i)e µ; Mji =

mji

µ ;Nm = ΘM/4

Θ1 = 0.005 Θ1 = 0.01

M1→2 = 100

M2→1 = 0

Page 30: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what

Bayes factor: influence of runlength Harmonic

c©2009 Peter Beerli

-50-40-3020

-100

1020304050

LBF

1 2 4 8 16 32 64 128 256Relative run length

Run length [ρ× 2x]

41632

Heated chains

LBF = 2 ln p(X|M1)p(X|M2) = 2 ln

p

X|

p

(X|

) ρ = (104 + 2× 104)

Time: 17 to 350 sec

Page 31: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what

Bayes factor: influence of runlength Harmonic

c©2009 Peter Beerli

-50-40-3020

-100

1020304050

LBF

1 2 4 8 16 32 64 128 256Relative run length

Run length [ρ× 2x]

41632

Heated chains

LBF = 2 ln p(X|M1)p(X|M2) = 2 ln

p

X|

p

(X|

) ρ = (104 + 2× 104)

Time: 17 to 350 sec

Page 32: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what

Bayes factor: influence of runlength Harmonic

c©2009 Peter Beerli

-50-40-3020

-100

1020304050

LBF

1 2 4 8 16 32 64 128 256Relative run length

Run length [ρ× 2x]

41632

Heated chains

LBF = 2 ln p(X|M1)p(X|M2) = 2 ln

p

X|

p

(X|

) ρ = (104 + 2× 104)

Time: 17 to 350 sec

Page 33: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what

Bayes factor: influence of runlength Thermodynamic

c©2009 Peter Beerli

16 heated chains32 heated chains

-5-4-3-2-1012345

LBF

1 2 4 8 16 32 64 128 256Relative run length

Run length [ρ× 2x]

LBF = 2 ln p(X|M1)p(X|M2) = 2 ln

p

X|

p

(X|

) ρ = (104 + 2× 104)

Page 34: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what

Bayes factor: influence of runlength Thermodynamic

c©2009 Peter Beerli

4 heated chains4 heated chains + Bézier

-5-4-3-2-1012345

LBF

1 2 4 8 16 32 64 128 256Relative run length

Run length [ρ× 2x]

LBF = 2 ln p(X|M1)p(X|M2) = 2 ln

p

X|

p

(X|

) ρ = (104 + 2× 104)

Page 35: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what

Bayes factor: influence of runlength Thermodynamic

c©2009 Peter Beerli

4 heated chains4 heated chains + Bézier16 heated chains32 heated chains

-5-4-3-2-1012345

LBF

1 2 4 8 16 32 64 128 256Relative run length

Run length [ρ× 2x]

LBF = 2 ln p(X|M1)p(X|M2) = 2 ln

p

X|

p

(X|

) ρ = (104 + 2× 104)

Page 36: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what

Bayes factor: influence of runlength Comparison

c©2009 Peter Beerli

Harmonic mean estimator Thermodynamic integration

1 2 4 8 16 32 64 128 256-50-40-3020

-100

1020304050

-5-4-3-2-1012345

LBF

(B)(A) 4 heated chains4 heated chains + Bézier16 heated chains32 heated chains

1 2 4 8 16 32 64 128 256LB

F

Relative run length Relative run length

Page 37: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what

Humpback whales in the South Atlantic Real data

c©2009 Peter Beerli

Page 38: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what

Using Marginal Likelihoods to rank Whale example

c©2009 Peter Beerli

Replica1 ˆ̀Mi

of models MiC B

A2 A1

C B

A2 A1

C B

A

C B, A C, A B

C B

A2 A1

C B

A2 A1

C B

A2 A1

C B

A2 A1

1 (10) -1988 -1958 -1984 -2009 -2054 -1935 -2070 -1793 -2015

1’ (10)2 -1988 -1958 -1984 -2009 -2054 -1936 -2070 -1793 -2002

2 (10) -2034 -2005 -2030 -2056 -2099 -1985 -2134 -1856 -2071

3 (30) -3669 -3519 -3630 -3735 -3983 -3454 -3689 -2725 -3028

Rank 5 3 4 6 8 2 9 1 71 Number of samples per population in parentheses.2 Same data as in replicate 1, but different start values of MCMC run.

Page 39: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what

Using Marginal Likelihoods to rank Whale example

c©2009 Peter Beerli

Replica1 ˆ̀Mi

of models MiC B

A2 A1

C B

A2 A1

C B

A

C B, A C, A B

C B

A2 A1

C B

A2 A1

C B

A2 A1

C B

A2 A1

1 (10) -1988 -1958 -1984 -2009 -2054 -1935 -2070 -1793 -2015

1’ (10)2 -1988 -1958 -1984 -2009 -2054 -1936 -2070 -1793 -2002

2 (10) -2034 -2005 -2030 -2056 -2099 -1985 -2134 -1856 -2071

3 (30) -3669 -3519 -3630 -3735 -3983 -3454 -3689 -2725 -3028

Rank 5 3 4 6 8 2 9 1 71 Number of samples per population in parentheses.2 Same data as in replicate 1, but different start values of MCMC run.

Page 40: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what

Using Marginal Likelihoods to rank Whale example

c©2009 Peter Beerli

Replica1 ˆ̀Mi

of models MiC B

A2 A1

C B

A2 A1

C B

A

C B, A C, A B

C B

A2 A1

C B

A2 A1

C B

A2 A1

C B

A2 A1

1 (10) -1988 -1958 -1984 -2009 -2054 -1935 -2070 -1793 -2015

1’ (10)2 -1988 -1958 -1984 -2009 -2054 -1936 -2070 -1793 -2002

2 (10) -2034 -2005 -2030 -2056 -2099 -1985 -2134 -1856 -2071

3 (30) -3669 -3519 -3630 -3735 -3983 -3454 -3689 -2725 -3028

Rank 5 3 4 6 8 2 9 1 71 Number of samples per population in parentheses.2 Same data as in replicate 1, but different start values of MCMC run.

Page 41: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what

Using Marginal Likelihoods to rank Whale example

c©2009 Peter Beerli

Replica1 ˆ̀Mi

of models MiC B

A2 A1

C B

A2 A1

C B

A

C B, A C, A B

C B

A2 A1

C B

A2 A1

C B

A2 A1

C B

A2 A1

1 (10) -1988 -1958 -1984 -2009 -2054 -1935 -2070 -1793 -2015

1’ (10)2 -1988 -1958 -1984 -2009 -2054 -1936 -2070 -1793 -2002

2 (10) -2034 -2005 -2030 -2056 -2099 -1985 -2134 -1856 -2071

3 (30) -3669 -3519 -3630 -3735 -3983 -3454 -3689 -2725 -3028

Rank 7 5 6 8 9 3 4 1 21 Number of samples per population in parentheses.2 Same data as in replicate 1, but different start values of MCMC run.

Page 42: Bayes factors, marginal likelihoods, and how to choose a …pbeerli/mbl2011_BF.pdf · 2011. 8. 1. · Overview c 2009 Peter Beerli 1.Location versus Population 2.Bayes factors, what