Introduction à ABC

41
Introduction aux m´ ethodes ABC (Approximate Bayesian Computation) Robin Ryder CEREMADE, Universit´ e Paris-Dauphine 26 f´ evrier 2013 GT Statistiques de Jussieu Robin Ryder (Dauphine) Introduction ` a ABC Jussieu 26/02/13 1 / 36

Transcript of Introduction à ABC

Page 1: Introduction à ABC

Introduction aux methodes ABC (Approximate BayesianComputation)

Robin Ryder

CEREMADE, Universite Paris-Dauphine

26 fevrier 2013GT Statistiques de Jussieu

Robin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 1 / 36

Page 2: Introduction à ABC

Cadre bayesien

Contexte : inference bayesienne

Donnees observees y ; on cherche a estimer un parametre θ.

Distribution a posteriori π(θ|y) ∝ π(θ)f (y|θ).

En general, on a une fonction integrable h et on cherche a estimer

Ih =

∫h(θ)π(θ|y)dθ

Estimation par Monte-Carlo : on simule θ1, . . . , θn selon π(θ|y) et onutilise

Ih =1

n

∑h(θi )

Robin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 2 / 36

Page 3: Introduction à ABC

Simulation selon la distribution a posteriori

On a donc besoin de simuler selon la distribution a posteriori π(θ|y)

Pour utiliser les methodes classiques (MCMC...), il faut etre enmesure de calculer π(θ|y) a une constante pres en tout point θ.

Probleme : que faire quand ce calcul est impossible ou trop couteux ?

Robin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 3 / 36

Page 4: Introduction à ABC

Solution : Approximate Bayesian Computation

Robin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 4 / 36

Page 5: Introduction à ABC

Contexte

Cible : π(θ|y) ∝ π(θ)f (y|θ)

Vraisemblance f (y|θ) difficile ou impossible a calculer.

Mais facile de simuler un nouveau jeu de donnees d’apres le modele :z ∼ f (z|θ)

Robin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 5 / 36

Page 6: Introduction à ABC

Approximate Bayesian Computation

Algorithm 1 Acceptation-rejet bayesien sans vraisemblance

1: for t = 1 to T do2: Tirer θt ∼ π(·)3: Simuler des donnees z ∼ f (·|θt)4: if z = y then5: accepter θt6: else7: rejeter θt .8: end if9: end for

(Tavare et al., 1997)On obtient un echantillon (de taille � T ) suivant exactement π(θ|y).

Robin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 6 / 36

Page 7: Introduction à ABC

Approximate Bayesian Computation

Algorithm 1 Acceptation-rejet bayesien sans vraisemblance

1: for t = 1 to T do2: Tirer θt ∼ π(·)3: Simuler des donnees z ∼ f (·|θt)4: if z = y then5: accepter θt6: else7: rejeter θt .8: end if9: end for

(Tavare et al., 1997)On obtient un echantillon (de taille � T ) suivant exactement π(θ|y).

Robin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 6 / 36

Page 8: Introduction à ABC

Algorithme exact

La preuve est evidente :

f (θi ) ∝∑z∈D

π(θi )f (z|θi )Iz=y

∝ π(θi )f (y|θi )= π(θi |y)

Robin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 7 / 36

Page 9: Introduction à ABC

Approximate Bayesian Computation

L’evenement z = y est de probabilite tres faible, et de probabilite 0 lorsquela v.a. est continue. On remplace donc l’egalite stricte par une zone detolerance :

Algorithm 2 Approximate Bayesian Computation

1: Definir un seuil de tolerance ε > 0 et une distance ρ.2: for t = 1 to T do3: Tirer θt ∼ π(·)4: Simuler des donnees z ∼ f (·|θt)5: if ρ(z, y) < ε then6: accepter θt7: else8: rejeter θt9: end if

10: end for

(Pritchard et al., 1999)

Robin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 8 / 36

Page 10: Introduction à ABC

Distribution approchee

On obtient ainsi un echantillon depuis la distribution

πABCε = π(θ)Pθ[ρ(z, y) < ε] = π(θ|ρ(z, y) < ε)

Lorsque ε→ 0, cela correspond a la distribution a posteriori.Lorsque ε→∞, cela correspond a la distribution a priori.Petites valeurs de ε⇒ bonne approximation, faible taux d’acceptation.Grandes valeurs de ε⇒ moins bonne approximation, taux d’acceptationplus eleve.En pratique, on ne choisit pas ε a l’avance : on prend pour ε un petitquantile du vecteur des distances.

Questions :

1 Choix de ε

2 Choix de ρ

Robin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 9 / 36

Page 11: Introduction à ABC

Distribution approchee

On obtient ainsi un echantillon depuis la distribution

πABCε = π(θ)Pθ[ρ(z, y) < ε] = π(θ|ρ(z, y) < ε)

Lorsque ε→ 0, cela correspond a la distribution a posteriori.Lorsque ε→∞, cela correspond a la distribution a priori.Petites valeurs de ε⇒ bonne approximation, faible taux d’acceptation.Grandes valeurs de ε⇒ moins bonne approximation, taux d’acceptationplus eleve.En pratique, on ne choisit pas ε a l’avance : on prend pour ε un petitquantile du vecteur des distances.Questions :

1 Choix de ε

2 Choix de ρ

Robin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 9 / 36

Page 12: Introduction à ABC

Exemple : MA(2)

Un processus MA(q) est une serie temporelle (yk)k∈N∗ definie par

yk = uk +

q∑i=1

θiuk−i uk ∼iid N (0, 1)

On considere un processus MA(2) et on cherche a simuler selon ladistribution a posteriori de θ = (θ1, θ2).Comme distribution a priori, on prend la loi uniforme sur l’ensemble desvaleurs identifiables de θ, qui est le triangle

−2 < θ1 < 2 θ1 + θ2 > −1 θ1 − θ2 < 1.

(Marin, Pudlo, Robert & RR 2012)

Robin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 10 / 36

Page 13: Introduction à ABC

Exemple : MA(2)

n = 50 observations d’un processus MA(2).

On tire T = 106 valeurs de θ.

ε : quantile a 1%, 0.1%, 0.01%.

ρ(z, y) =√∑n

k=1(yk − zk)2

Robin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 11 / 36

Page 14: Introduction à ABC

Exemple : MA(2)

−2 −1 0 1 2

−1.

0−

0.5

0.0

0.5

1.0

θ1

θ 2

−2 −1 0 1 2

−1.

0−

0.5

0.0

0.5

1.0

θ1

θ 2

−2 −1 0 1 2

−1.

0−

0.5

0.0

0.5

1.0

θ1

θ 2Figure: De gauche a droite, ε = quantile a 1%, 0.1%, 0.01%. Noir : niveaux dela densite cible.

Robin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 12 / 36

Page 15: Introduction à ABC

Estimation de la densite

−2 −1 0 1 2

0.0

1.0

2.0

3.0

θ1

−1.0 0.0 0.5 1.0

0.0

1.0

2.0

3.0

θ2

Figure: Gauche : θ1, droite : θ2 ; ε : quantile a 1% (bleu), 0.1% (rouge), 0.01%(vert). En noir, la densite cible π(·|y).

Robin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 13 / 36

Page 16: Introduction à ABC

Approximation supplementaire

En general, on ne considere pas ρ(z, y), mais on se restreint a unestatistique resumee S de nos donnees :

Algorithm 3 Approximate Bayesian Computation

1: Definir un seuil de tolerance ε > 0, une statistique resumee S et unedistance ρ.

2: for t = 1 to T do3: Tirer θt ∼ π(·)4: Simuler des donnees z ∼ f (·|θt)5: if ρ(S(z),S(y)) < ε then6: accepter θt7: else8: rejeter θt .9: end if

10: end for

Robin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 14 / 36

Page 17: Introduction à ABC

Resultat

On obtient un echantillon suivant la loi marginale en θ de

πABCε,S (θ, z|y) =π(θ)f (z|θ)IAε,y(z)∫

Aε,y×Θ π(θ)f (z|θ) dzdθ

ou Aε,S = {z ∈ D : ρ(S(z),S(y) < ε}.On espere que

πABCε,S (θ|y) ' π(θ|y)

Robin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 15 / 36

Page 18: Introduction à ABC

Approximations

On a 3 niveaux d’approximation :

1 Utilisation d’une statistique resumee S potentiellement non-exhaustive :π(θ|S(y)) 6= π(θ|y)

2 Utilisation d’un seuil de tolerance ε > 0 : πABCS ,ε (θ|S(y)) 6= π(θ|S(y))

3 Erreur Monte-Carlo : echantillon de taille finie (faible tauxd’acceptation)

Quand on diminue l’erreur 2, on augmente soit l’erreur 3, soit le temps decalcul.

Robin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 16 / 36

Page 19: Introduction à ABC

Approximations

On a 3 niveaux d’approximation :

1 Utilisation d’une statistique resumee S potentiellement non-exhaustive :π(θ|S(y)) 6= π(θ|y)

2 Utilisation d’un seuil de tolerance ε > 0 : πABCS ,ε (θ|S(y)) 6= π(θ|S(y))

3 Erreur Monte-Carlo : echantillon de taille finie (faible tauxd’acceptation)

Quand on diminue l’erreur 2, on augmente soit l’erreur 3, soit le temps decalcul.

Robin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 16 / 36

Page 20: Introduction à ABC

Exemple : MA(2)

50 observations d’un processus MA(2).

On tire T = 106 valeurs de θ.

Statistique resumee : autocorrelations d’ordres 1 et 2 ;τj =

∑nk=j+1 ykyk−j

ε : quantile a 1%, 0.1%, 0.01%.

Robin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 17 / 36

Page 21: Introduction à ABC

Exemple : MA(2)

−2 −1 0 1 2

−1.

0−

0.5

0.0

0.5

1.0

θ1

θ 2

−2 −1 0 1 2

−1.

0−

0.5

0.0

0.5

1.0

θ1

θ 2

−2 −1 0 1 2

−1.

0−

0.5

0.0

0.5

1.0

θ1

θ 2Figure: Statistique resumee : autocorrelations. De gauche a droite, ε = quantilea 1%, 0.1%, 0.01%.

Robin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 18 / 36

Page 22: Introduction à ABC

Estimation de la densite

−2 −1 0 1 2

0.0

1.0

2.0

3.0

θ1

−1.0 0.0 0.5 1.0

0.0

1.0

2.0

3.0

θ2

Figure: Gauche : θ1, droite : θ2 ; ε : quantile a 1% (bleu), 0.1% (rouge), 0.01%(vert). En noir, la densite cible π.

Robin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 19 / 36

Page 23: Introduction à ABC

La statistique resumee est essentielle

Du point de vue ABC, les donnees completes sont assez peu informativessur les parametres. On peut perdre de l’information ( !) en utilisant lesdonnees completes plutot qu’une statistique resumee meme nonexhaustive.A partir de maintenant, on ignorera parfois la dependance en la statistiqueresumee S dans les notations : ρ′(z, y) = ρ(S(z), S(y)). Dans les exemples,on utilisera la distance entre autocorrelations et non la distance brute.

Robin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 20 / 36

Page 24: Introduction à ABC

Choix des statistiques resumees

En general, il n’y a pas de statistique exhaustive disponible. La question sepose donc de la construction des statistiques, et du choix des statistiques ainclure.Joyce & Marjoram (2008), a partir d’un large ensemble de statistiques :inclusion sequentielle, et ”rapport de vraisemblances” pour deciderd’inclure ou non chaque statistique.Plusieurs problemes. Principalement : d’ou vient le large ensemble destatistiques ?

Robin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 21 / 36

Page 25: Introduction à ABC

Semi-automatic ABC

Fernhead & Prangle (2012 + commentaires JRSSB) : le ”meilleur” resumeest l’esperance a posteriori des parametres.

a ABC pilote pour determiner la region d’interet

b Simulation de couples (θ, z) dans cette region

c Creation de statistiques resumees (par regression lineaire) a l’aide de cescouples

d ABC avec ces statistiques

ABC ”calibre”.Probabilite d’acceptation :

p(z) =

∫p(θ|z)π(θ)dλ = π(z)εd + o(εd)

avec d la dimension de la statistique resumee

Robin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 22 / 36

Page 26: Introduction à ABC

Statistiques en pratique

En pratique, les statistiques resumees sont souvent choisies demaniere intuitive

Ce choix est ensuite valide par ex. par verification sur des donneessimulees (DIY ABC, Cornuet et al. 2008)

Robin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 23 / 36

Page 27: Introduction à ABC

ABC-MCMC

Plus efficace : ne pas simuler directement depuis la prior π(·)

Algorithm 4 ABC-MCMC

1: Generer par ABC standard une realisation (θ(0), z(0)) de la cibleπABC (θ, z|y)

2: for t = 1 to T do3: Tirer θ′ selon le noyau markovien q(·|θ(t−1))4: Simuler des donnees z′ ∼ f (·|θ′)5: Tirer u selon U([0, 1])

6: if u ≤ π(θ′)q(θ(t−1)|θ′)π(θ(t−1))q(θ′|θ(t−1))

et ρ(z′, y) ≤ ε then

7: poser (θ(t), z(t)) = (θ′, z′)8: else9: (θ(t), z(t)) = (θ(t−1), z(t−1)),

10: end if11: end for

Robin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 24 / 36

Page 28: Introduction à ABC

ABC-MCMC : preuve

Si on considere le couple (θ, z), on a construit un MCMC de noyau detransition (θ′, z′) ∼ q(θ′|θ(t−1))× f (z|θ′) et

πABC (θ′, z′|y)

πABC (θ(t−1), z(t−1)|y)× q(θ[t−1)|θ′)f (z(t−1)|θ(t−1))

q(θ′|θ(t−1))f (z′|θ′)

=π(θ′)f (z′|θ′)IAε,y(z′)

π(θ(t−1))f (z(t−1)|θ(t−1))IAε,y(z(t−1))

×q(θ(t−1)|θ′)f (z(t−1)|θ(t−1))

q(θ′|θ(t−1))f (z′|θ′)

=π(θ′)q(θ(t−1)|θ′)

π(θ(t−1))q(θ′|θ(t−1))IAε,y(z′)

Robin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 25 / 36

Page 29: Introduction à ABC

ABC-MCMC : preuve

Si on considere le couple (θ, z), on a construit un MCMC de noyau detransition (θ′, z′) ∼ q(θ′|θ(t−1))× f (z|θ′) et

πABC (θ′, z′|y)

πABC (θ(t−1), z(t−1)|y)× q(θ[t−1)|θ′)f (z(t−1)|θ(t−1))

q(θ′|θ(t−1))f (z′|θ′)

=π(θ′)���

�f (z′|θ′)IAε,y(z′)

π(θ(t−1))((((((((f (z(t−1)|θ(t−1))���

���IAε,y(z(t−1))

×q(θ(t−1)|θ′)((((((((

f (z(t−1)|θ(t−1))

q(θ′|θ(t−1))����f (z′|θ′)

=π(θ′)q(θ(t−1)|θ′)

π(θ(t−1))q(θ′|θ(t−1))IAε,y(z′)

Robin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 25 / 36

Page 30: Introduction à ABC

ABC-MCMC : preuve

Si on considere le couple (θ, z), on a construit un MCMC de noyau detransition (θ′, z′) ∼ q(θ′|θ(t−1))× f (z|θ′) et

πABC (θ′, z′|y)

πABC (θ(t−1), z(t−1)|y)× q(θ[t−1)|θ′)f (z(t−1)|θ(t−1))

q(θ′|θ(t−1))f (z′|θ′)

=π(θ′)���

�f (z′|θ′)IAε,y(z′)

π(θ(t−1))((((((((f (z(t−1)|θ(t−1))���

���IAε,y(z(t−1))

×q(θ(t−1)|θ′)((((((((

f (z(t−1)|θ(t−1))

q(θ′|θ(t−1))����f (z′|θ′)

=π(θ′)q(θ(t−1)|θ′)

π(θ(t−1))q(θ′|θ(t−1))IAε,y(z′)

Robin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 25 / 36

Page 31: Introduction à ABC

ABC-PMC

Algorithm 5 PMCMC sans vraisemblance

1: A l’iteration t = 1,2: for i = 1 to N do3: repeat4: Simuler θ

(1)i ∼ π(θ) et z ∼ f (z | θ(1)

i )5: until ρ(S(z),S(y)) ≤ ε1

6: Poser ω(1)i = 1/N

7: end for8: Prendre pour Σ1 deux fois la variance empirique des θ

(1)i

9: for t = 2 to T do10: for i = 1 to N do11: repeat12: Tirer θ?i parmi les θ

(t−1)j avec probabilites ω

(t−1)j

13: Simuler θ(t)i ∼ N (θ?i ,Σt−1) et z ∼ f (z | θ(t)

i )14: until ρ(S(z),S(y)) ≤ εt15: Poser ω

(t)i ∝ π(θ

(t)i )/

∑Nj=1 ω

(t−1)j ϕ

−1/2t−1

(t)i − θ

(t−1)j

)}16: end for17: Prendre pour Σt deux fois la variance empirique des θ

(t)i

18: end forRobin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 26 / 36

Page 32: Introduction à ABC

Post-processing d’ABC

Beaumont et al. (2002) : on garde l’algorithme inchange, mais on modifiela sortie. On remplace θ par

θ∗ = θ − (S(z)− S(y))T β

ou β provient d’une regression ponderee de θ sur S(z)− S(y), avec despoids de la forme

Kδ(S(z)− S(y))

ou Kδ est un noyau de largeur δ.

Robin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 27 / 36

Page 33: Introduction à ABC

Exemple : MA(2)

Memes sorties que precedemment

ε = quantile a 0.1% puis a 20%

Robin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 28 / 36

Page 34: Introduction à ABC

MA(2) avec post-processing (1)

−2 −1 0 1 2

0.0

0.5

1.0

1.5

2.0

θ1

−2 −1 0 1 2

0.0

0.5

1.0

1.5

2.0

θ2

Figure: Estimation de la densite de θ1 (droite) et θ2 (gauche) ; ε =quantile a0.1%. Bleu : sans post-processing ; rouge : avec post-processing ; noir : cible.

Robin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 29 / 36

Page 35: Introduction à ABC

MA(2) avec post-processing (2)

−2 −1 0 1 2

0.0

0.5

1.0

1.5

2.0

θ1

−2 −1 0 1 2

0.0

0.5

1.0

1.5

2.0

θ2

Figure: Estimation de la densite de θ1 (droite) et θ2 (gauche) ; ε =quantile a20%. Bleu : sans post-processing ; rouge : avec post-processing ; noir : cible.

Robin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 30 / 36

Page 36: Introduction à ABC

Choix de modele

Pour k modeles, on considere eventuellement S(z) = (S1(z), . . . ,Sk(z)).

Algorithm 6 ABC pour choix de modele

1: for t = 1 to T do2: Tirer un modele mt ∈ {1, . . . , k} de l’a priori π(M = mt)3: Tirer θt ∼ πm(·)4: Simuler des donnees z ∼ fm(·|θt)5: if ρ(S(z),S(y)) < ε then6: accepter (mt , θt)7: else8: rejeter (mt , θt).9: end if

10: end for

L’estimation ABC de la probabilite a posteriori du modele m est :

π(M = m|y) ≈ 1

n

n∑t=1

Imt=m

Robin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 31 / 36

Page 37: Introduction à ABC

Exemple : MA(2)

Choix entre MA(1) et MA(2)

Donnees provenant d’un MA(2)

Facteur de Bayes B21 = 17.71 ; P[M = 2|y] = 95% ;P[M = 1|y] = 5%

Robin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 32 / 36

Page 38: Introduction à ABC

Facteur de Bayes

1 2

0.0

0.2

0.4

0.6

0.8

1.0

1 2

0.0

0.2

0.4

0.6

0.8

1.0

1 2

0.0

0.2

0.4

0.6

0.8

1.0

1 2

0.0

0.2

0.4

0.6

0.8

1.0

Figure: Probabilite a posteriori des modeles MA(1) et MA(2) pour ε = quantilesa 10, 1, 0.1, 0.01%. La vraie valeur des probabilites est 5%/95%.

Robin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 33 / 36

Page 39: Introduction à ABC

Choix de modele : problemes

Meme si Sm est une statistique exhaustive pour θ dans le modele mpour tout m, la concatenation des statistiques (S1, . . . ,Sk) n’est pasforcement une statistique exhaustive pour le couple (m, θ).

En general, on n’a pas d’estimateur convergent du facteur de Bayes.

Cas particulier : famille exponentielle.

(ABC in London 2012)

Robin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 34 / 36

Page 40: Introduction à ABC

Conclusions

Tres peu de resultats theoriques utiles sur la convergence

Controle de l’erreur seulement de facon empirique

Pragmatisme : ABC ou rien !

Robin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 35 / 36

Page 41: Introduction à ABC

Questions ?

Robin Ryder (Dauphine) Introduction a ABC Jussieu 26/02/13 36 / 36