Tag Archives: Bayes

Will I ever be a bayesian statistician ? (part 2)

A few weeks ago, I started a series of posts on the magic of bayesian statistics from the eyes of a muggle (see http://freakonometrics.hypotheses.org/2191). It might be time to go a bit further…. And today, I wanted to discuss the choice of the a priori distribution of the parameter (which was mentioned in the commentary of the previous post). As far as I understood, there are several houses with different ideas on how to choose it.

  • The conjugate house

The first idea (used in the previous post, here) is to consider an exponential distribution. To be formal, those distributions can be written as

http://freakonometrics.blog.free.fr/public/perso2/bayes-prior-10.gif

(in a form as general as possible), i.e.

http://freakonometrics.blog.free.fr/public/perso2/bayes-prior-11.gif

Here http://freakonometrics.blog.free.fr/public/perso2/bayes-prior-13.gif is somehow the new parameter of the distribution. Then, a conjugate priorhttp://freakonometrics.blog.free.fr/public/perso2/bayes-prior-12.gif for the parameter http://freakonometrics.blog.free.fr/public/perso2/bayes-prior-13.gif of the exponential family is given by

http://freakonometrics.blog.free.fr/public/perso2/bayes-prior-15.gif

where http://freakonometrics.blog.free.fr/public/perso2/bayes-prior-16.gif (where http://freakonometrics.blog.free.fr/public/perso2/bayes-prior-17.gif is the dimension of http://freakonometrics.blog.free.fr/public/perso2/bayes-prior-13.gif).

The conjugate prior is interesting since, when combined with the likelihood (and normalized), produces a posterior distribution which is of the same type as the prior. And a lot of standard distributions have a conjugate prior. E.g.

  • For a Bernoulli distribution, i.e. http://freakonometrics.blog.free.fr/public/perso2/conj-00c.gif are i.i. with distribution http://freakonometrics.blog.free.fr/public/perso2/conju-01.gif, assume that the  a priori distribution of http://freakonometrics.blog.free.fr/public/perso2/conj-00b.gif is http://freakonometrics.blog.free.fr/public/perso2/conju-02.gif, , then the a posteriori distribution of http://freakonometrics.blog.free.fr/public/perso2/conj-00.gif is still Beta, with parameters
http://freakonometrics.blog.free.fr/public/perso2/conju-03.gif
  • For a binomial distribution,  http://freakonometrics.blog.free.fr/public/perso2/conju-05.gif, assume that the  a prioridistribution of http://freakonometrics.blog.free.fr/public/perso2/conj-00b.gif is http://freakonometrics.blog.free.fr/public/perso2/conju-02.gif, then the a posteriori distribution of http://freakonometrics.blog.free.fr/public/perso2/conj-00.gif is still Beta, with parameters
http://freakonometrics.blog.free.fr/public/perso2/conj-06.gif
  • For a Negative Binomial distribution, http://freakonometrics.blog.free.fr/public/perso2/bayes-prior-20.gif,  assume that the  a priori distribution of http://freakonometrics.blog.free.fr/public/perso2/conj-00b.gif is http://freakonometrics.blog.free.fr/public/perso2/conju-02.gif, then the a posterioridistribution of http://freakonometrics.blog.free.fr/public/perso2/conj-00.gif is still Beta, with parameters
http://freakonometrics.blog.free.fr/public/perso2/conj-08.gif
  • For a Poisson distribution, http://freakonometrics.blog.free.fr/public/perso2/conj-09.gif, assume that the  a priori distribution of http://freakonometrics.blog.free.fr/public/perso2/conj-00b.gif is http://freakonometrics.blog.free.fr/public/perso2/conj-10.gif, then the a posteriori distribution of http://freakonometrics.blog.free.fr/public/perso2/conj-00.gifis still gamma, with parameter
http://freakonometrics.blog.free.fr/public/perso2/conj-13.gif
  • For a Geometric distribution,http://freakonometrics.blog.free.fr/public/perso2/conj-15.gif, assume that the  a prioridistribution of http://freakonometrics.blog.free.fr/public/perso2/conj-00b.gif is http://freakonometrics.blog.free.fr/public/perso2/conju-02.gif, then the a posteriori distribution of http://freakonometrics.blog.free.fr/public/perso2/conj-00.gif is still Beta, with parameters
http://freakonometrics.blog.free.fr/public/perso2/bayes-prior-22.gif
  • For an Exponential distributionhttp://freakonometrics.blog.free.fr/public/perso2/conj-23.gif assume that the  a prioridistribution of http://freakonometrics.blog.free.fr/public/perso2/conj-00b.gif ishttp://freakonometrics.blog.free.fr/public/perso2/bayes-prior-21.gif , then the a posteriori distribution of http://freakonometrics.blog.free.fr/public/perso2/conj-00.gif is still Gamma, with parameters
http://freakonometrics.blog.free.fr/public/perso2/bayes-prior-22.gif
  • For a Gaussian distribution, http://freakonometrics.blog.free.fr/public/perso2/conj-28.gif assume that http://freakonometrics.blog.free.fr/public/perso2/conj-31.gif, then
http://freakonometrics.blog.free.fr/public/perso2/conj-35.gif

  • For a gamma distribution, http://freakonometrics.blog.free.fr/public/perso2/conj-43.gif, assume that the  a prioridistribution of http://freakonometrics.blog.free.fr/public/perso2/conj-00b.gif is  http://freakonometrics.blog.free.fr/public/perso2/bayes-000000.gif, then the a posteriori distribution of http://freakonometrics.blog.free.fr/public/perso2/conj-00.gif is still Gamma, with parameters
http://freakonometrics.blog.free.fr/public/perso2/bayes-prior-23.gif
  • For a Pareto distribution, , assume that the  a priori distribution of http://freakonometrics.blog.free.fr/public/perso2/conj-00b.gif is http://freakonometrics.blog.free.fr/public/perso2/bayes-prior-21.gif, then the a posteriori distribution of http://freakonometrics.blog.free.fr/public/perso2/conj-00.gif is still Gamma, with parameters

http://freakonometrics.blog.free.fr/public/perso2/bayes----ooooo.gif

  • The non-informative or vague house

So far, the choice of the prior was not neutral, in the sense that the a priori of the statistician will have an influence on a posteriori distributions (we’ll discuss that point further later on). We could be interested by the case where http://freakonometrics.blog.free.fr/public/perso2/bayes-prior-12.gif is somehow t neutral. A famous example is the case of  http://freakonometrics.blog.free.fr/public/perso2/conju-01.gifdistribution. Between 1745 and 1784, Pierre Simon Laplace observed 393,386 birth of boys versus 377,555 birth of girls (or 251,527 boys versus 241,945 girls if we consider the initial article, for birth before 1770). He wanted to quantify the probability that p, the provability to have a boy, exceed 1/2. He assume that a priorip was uniform on the unit interval claiming that it was being as neutral as possible. But it is not that correct.
The idea of noninformative prior is that we should get an equivalent result when considering a transformed parameter. So assume that the parameter is no longer http://freakonometrics.blog.free.fr/public/perso2/bayes-prior-03.gif, but http://freakonometrics.blog.free.fr/public/perso2/bayes-prior-05.gif, where http://freakonometrics.blog.free.fr/public/perso2/bayes-----0000.gif (for some bijective transformation). The distribution (density) of http://freakonometrics.blog.free.fr/public/perso2/bayes-prior-05.gif is then

http://freakonometrics.blog.free.fr/public/perso2/bayes-prior-01.gif

Let http://freakonometrics.blog.free.fr/public/perso2/bayes-prior-02.gif denote Fisher information of parameter http://freakonometrics.blog.free.fr/public/perso2/bayes-prior-03.gif,

http://freakonometrics.blog.free.fr/public/perso2/bayes-priori-04.gif

Then, Fisher information of parameter http://freakonometrics.blog.free.fr/public/perso2/bayes-prior-05.gif is

http://freakonometrics.blog.free.fr/public/perso2/bayes-prior-06.gif

which can be written

http://freakonometrics.blog.free.fr/public/perso2/bayes-prior-07.gif

So if we want a distribution invariant by transformation of the parameter (http://freakonometrics.blog.free.fr/public/perso2/bayes-prior-08.gif), it seems natural to consider

http://freakonometrics.blog.free.fr/public/perso2/bayes-prior-09.gif

or at least something proportional to that square root, since we want to get a density.
Thus, from Jeffrey’s principle, the prior distribution for a single parameter is noninformative if it is taken proportional to the square root of Fisher’s information measure. For those who want to go further, see Noninformative Priors Do Not Exist or  A Catalog of Noninformative Priors.

  • For the Poisson distribution, the Jeffreys prior for the rate parameter  is
http://freakonometrics.blog.free.fr/public/perso2/bayes-prior-poisson.gif
  • For the Bernoulli distribution, the Jeffreys prior for the probability parameter  is
http://freakonometrics.blog.free.fr/public/perso2/bayes-prior-binomial.gif

This is the arcsine distribution and is a beta distribution with parameters 1/2.

  • The expert house

The idea is quite simple. We need a prior distribution so that

http://freakonometrics.blog.free.fr/public/perso2/bayes-prior-32.gif

But assume that we have already seen a similar problem before. For instance, I remember Eric Parent mentioning the case of river flow models. If we have two similar rivers, then it might be interesting to use information on one river as an a prioriinformation for the second one, something like

http://freakonometrics.blog.free.fr/public/perso2/bayes-prior-33.gif

I guess it is also possible to use meta-regression to get an aggregation of experts opinion.

To go further on bayesian statistics, I suggest to go on Albus Dumbledore’s og,here, or the the blog of some PhD (and postdoc) students in Hogwarts, there. Or if you can wait, a dozen other posts will come soon (well, let’s hope so). The next one will probably be on a posteriori calculations (which is the natural step since we’ve seen a priori choice here).

Crédibilité et calcul bayésien

On a commencé en cours la tarification a posteriori, en commençant par la tarification bayésienne, et en présentant ensuite l’approche d’Hans Bühlmann comme un cas particulier en projetant dans un sous espace de combinaisons linéaires (un peu comme l’économétrie linéaire était présenté en cours comme un cas particulier de calcul d’espérance conditionnelle).La classification a priori sera poursuivie un TD, sur des bases de données, afin d’orienter davantage le cours sur la pratique des GLM.
L’utilisation des techniques bayésiennes en actuariat ne s’est pas faite sans peine. Pour ceux qui souhaitent s’en convaincre, il suffit de relire les comptes rendus de la conférence à Trieste en 1962. Dans le discours de Bruno de Finetti (publié dans l’ASTIN Bulletin), on retrouve un point historique, présentant les nouveaux travaux d’Hans Bühlmann,

Et Bruno de Finetti de conclure en rappelant les apports d’Arthur Bailey en 1950,

  • La formule de Bayes, ou apprendre par l’expérience

La formule de Bayes ne dit pas grand chose quand on le regarde sous la forme suivante

https://perso.univ-rennes1.fr/arthur.charpentier/latex/latex-bayes-01.png

A la rigueur on peut aussi la réécrire en utilisant deux fois cette formule

https://perso.univ-rennes1.fr/arthur.charpentier/latex/latex-bayes-02.png

Bon, là encore, on ne voit peut être toujours pas ce qu’on peut en faire…. L’idée géniale est de faire la lecture suivante

https://perso.univ-rennes1.fr/arthur.charpentier/latex/latex-bayes-03.gif

Autrement dit la loi a posteriori du paramètre, conditionnellement aux observations (en bleu) est proportionnelle au produit de  la loi a priori du paramètre (en vert) et de la vraisemblance des observations (en rouge, qui sera un simple produit de lois si on suppose l’indépendance conditionnelle au paramètre). Le paramètre en noir est juste un facteur de normalisation, histoire que la loi soit effectivement une mesure de probabilité. D’où parfois l’écriture

https://perso.univ-rennes1.fr/arthur.charpentier/latex/latex-bayes-4.gif

Bref, on a réussit à inverser les deux termes dans la probability (on retrouve le terme “inverse probability” dans la littérature anglo-saxonne).
En cours, on avait vu que si on supposait le nombre annuel de sinistres Poisson, conditionnellement au paramètre, avec une indépendance (toujours conditionnellement à ce paramètre), et que l’on suppose que la loi a priori du paramètre est une loi Gamma, alors la loi a posteriori se calcule facilement et c’est une loi Gamma.
Considérons la petite simulation suivante: on suppose que le nombre de sinistres suit une loi de Poisson, et on cherche à estimer le paramètre de cette loi. On commence par une loi a priori Gamma, centrée sur 5, et on regarde évoluer la loi a posteriori au fur et à mesure que l’on observe les sinistres arriver (ou les années passer en l’occurence).

On peut également considerer l’évolution de l’espérance a posteriori du paramètre, ainsi qu’un intervalle de confiance (puisqu’on connaît la loi)

La “magie” des méthodes bayésiennes est que peu importe la loi a priori, on va converger vers la vraie valeur. Par exemple sur l’animation ci-dessous, on part d’une loi a priori de moyenne 2,

avec là aussi l’évolution de la moyenne a posteriori avec un intervalle de confiance,

La morale de l’histoire est que comme la loi a priori n’influence pas (j’exagère un peu car elle va influencer la vitesse de la convergence, ce qui n’est pas rien en pratique), autant prendre quelque chose de simple pour les calculs: la loi conjuguée de la loi exponentielle. La loi conjuguée d’une loi de la famille exponentielle de la forme

s’écrit

où et sont des constantes, et où  est une constante de normalisation (afin que cette fonction soit effectivement une mesure de probabilité).

  • L’hérésie de la statistique bayésienne

La principale hérésie des statisticiens bayésien a été de proposer une lecture des probabilités d’un point de vue subjectif. En particulier Jimmie Savage et Bruno de Finetti partait de l’hypothèse que chacun avait à sa disposition son propre espace de probabilité.C’est ce qui lui permet de se construire un a priori. Et au fur et à mesure que le temps passe, on apprend, et on peut dériver une loi a posteriori. Par exemple  je pars d’un a priori comme quoi un enfant sur deux qui nait est un garçon, en France. Je peux ensuite récupérer des données, et affiner ma connaissance. C’est ce qu’avait fait Laplace il y a fort fort longtemps….
L’hérésie est ici un
problème philosophique lié au concept même de probabilité. Mais on peut noter qu’à l’époque dans les années 60, les débats étaient assez virulants. Et pour Jimmie Savage et Bruno de Finetti, il n’est pas nécessaire d’avoir le formalisme mathématique d’Andreï Kolmogorov pour appréhender la notion de probabilité (c’est à dire la mesure d’ensembles dans un espace abstrait d’évènements, voir ici ou ). On notera que pour John Keynes (qui avait écrit un “traité de probabilités“) il existait une probabilité subjective, mais davantage liée à une information donnée par l’éducation. C’est un problème culturel plus que personnel. Mais finalement, il a surtout fallu attendre les travaux de Daniel Kahneman et Amos Tversky dans les années 70 pour que des psychologues se penchent sur la construction individuelle des probabilités.

  • La crédibilité au sens de Bühlmann

L’idée d’Hans Bühlmann est de proposer une formule fermée qui approche l’espérance conditionnelle, tout simplement en utilisant celle qui avait été obtenue dans le cas bayésien. En tarification, on s’intéresse à des primes pures, et il est finalement assez naturel de chercher à calculer

Hans Bühlmann a suggéré d’approcher cette grandeur par

avec classiquement

est appelé facteur de crédibilité, avec , et où respectivement,


Bref, on a un facteur de crédibilité qui dépend de la variance intra et de la variance inter, pour reprendre des termes connus en statistique. L’énorme avantage est que cette formule peut très facilement s’utiliser sur des données. En particulier, considérons un tableau de la forme suivante

où on regarde si un contrat a – ou n’a pas – eu de sinistre chacune des années. Formellement, on dispose d’un tableau d’observations,

(on notera que le nombre d’années d’observations pour chacun des contrats peut être différent). On peut alors obtenir les estimateurs empiriques des moments nécéssaires, i.e. on pose

correspondant à la moyenne empirique pour un contrat,

et

Le facteur de crédibilité pour le contrat i est alors

où tout naturellement

Article (de vulgarisation) sur la crédibilité

Parution d’un court article sur la Théorie de la Crédibilité dans la revue Risques.

La théorie de la crédibilité est une jolie application de l’approche bayésienne de la statistique, puisque l’on cherche à déterminer la probabilité d’appartenir à une classe de risque conditionnellement à une expérience de sinistralité observée. La théorie développée par Hans Bühlmann propose d’ailleurs de jolies applications, en particulier sur les jeux de fléchettes, où l’on compare la moyenne sur un sous-groupe homogène (ou supposé l’être) avec la moyenne de la population totale. En faisant intervenir des variance intra et des variances inter, on arrive à un résultat relativement simple et élégant.