{ "cells": [ { "cell_type": "markdown", "metadata": { "toc": true }, "source": [ "

Table of Contents

\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## An Introduction to Bayesian Statistical Analysis" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Before we jump in to model-building and using MCMC to do wonderful things, it is useful to understand a few of the theoretical underpinnings of the Bayesian statistical paradigm. A little theory (and I do mean a *little*) goes a long way towards being able to apply the methods correctly and effectively.\n", "\n", "There are several introductory references to Bayesian statistics that go well beyond what we will cover here. Some suggestions:\n", "\n", "[Chapter 11 of Schaum's Outline of Probability and Statistics](https://www.kobo.com/us/en/ebook/schaum-s-outline-of-probability-and-statistics-4th-edition)\n", "\n", "[Introduction to Bayesian Statistics](https://www.stat.auckland.ac.nz/~brewer/stats331.pdf)\n", "\n", "[Bayesian Statistics](https://www.york.ac.uk/depts/maths/histstat/pml1/bayes/book.htm)\n", "\n", "\n", "## What *is* Bayesian Statistical Analysis?\n", "\n", "Though many of you will have taken a statistics course or two during your undergraduate (or graduate) education, most of those who have will likely not have had a course in *Bayesian* statistics. Most introductory courses, particularly for non-statisticians, still do not cover Bayesian methods at all, except perhaps to derive Bayes' formula as a trivial rearrangement of the definition of conditional probability. Even today, Bayesian courses are typically tacked onto the curriculum, rather than being integrated into the program.\n", "\n", "In fact, Bayesian statistics is not just a particular method, or even a class of methods; it is an entirely different paradigm for doing statistical analysis.\n", "\n", "> Practical methods for making inferences from data using probability models for quantities we observe and about which we wish to learn.\n", "*-- Gelman et al. 2013*\n", "\n", "A Bayesian model is described by parameters, uncertainty in those parameters is described using probability distributions." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "All conclusions from Bayesian statistical procedures are stated in terms of *probability statements*\n", "\n", "![](images/prob_model.png)\n", "\n", "This confers several benefits to the analyst, including:\n", "\n", "- ease of interpretation, summarization of uncertainty\n", "- can incorporate uncertainty in parent parameters\n", "- easy to calculate summary statistics" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## What is Probability?\n", "\n", "> *Misunderstanding of probability may be the greatest of all impediments to scientific literacy.*\n", "> — Stephen Jay Gould\n", "\n", "It is useful to start with defining what probability is. There are three main categories:\n", "\n", "### 1. Classical probability\n", "\n", "
\n", "$Pr(X=x) = \\frac{\\text{# x outcomes}}{\\text{# possible outcomes}}$\n", "
\n", "\n", "Classical probability is an assessment of **possible** outcomes of elementary events. Elementary events are assumed to be equally likely.\n", "\n", "### 2. Frequentist probability\n", "\n", "
\n", "$Pr(X=x) = \\lim_{n \\rightarrow \\infty} \\frac{\\text{# times x has occurred}}{\\text{# independent and identical trials}}$\n", "
\n", "\n", "This interpretation considers probability to be the relative frequency \"in the long run\" of outcomes.\n", "\n", "### 3. Subjective probability\n", "\n", "
\n", "$Pr(X=x)$\n", "
\n", "\n", "Subjective probability is a measure of one's uncertainty in the value of \\\\(X\\\\). It characterizes the state of knowledge regarding some unknown quantity using probability.\n", "\n", "It is not associated with long-term frequencies nor with equal-probability events.\n", "\n", "For example:\n", "\n", "- X = the true prevalence of diabetes in Austin is < 15%\n", "- X = the blood type of the person sitting next to you is type A\n", "- X = the Nashville Predators will win next year's Stanley Cup\n", "- X = it is raining in Nashville\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Bayesian vs Frequentist Statistics: What's the difference?\n", "\n", "See the [VanderPlas paper and video](http://conference.scipy.org/proceedings/scipy2014/pdfs/vanderplas.pdf).\n", "\n", "![can of worms](images/can-of-worms.jpg)\n", "\n", "Any statistical paradigm, Bayesian or otherwise, involves at least the following: \n", "\n", "1. Some **unknown quantities** about which we are interested in learning or testing. We call these *parameters*.\n", "2. Some **data** which have been observed, and hopefully contain information about (1).\n", "3. One or more **models** that relate the data to the parameters, and is the instrument that is used to learn.\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### The Frequentist World View\n", "\n", "![Fisher](images/fisher.png)\n", "\n", "- The data that have been observed are considered **random**, because they are realizations of random processes, and hence will vary each time one goes to observe the system.\n", "- Model parameters are considered **fixed**. The parameters' values are unknown, but they are fixed, and so we *condition* on them.\n", "\n", "In mathematical notation, this implies a (very) general model of the following form:\n", "\n", "
\n", "$f(y | \\theta)$\n", "
\n", "\n", "Here, the model \\\\(f\\\\) accepts data values \\\\(y\\\\) as an argument, conditional on particular values of \\\\(\\theta\\\\).\n", "\n", "Frequentist inference typically involves deriving **estimators** for the unknown parameters. Estimators are formulae that return estimates for particular estimands, as a function of data. They are selected based on some chosen optimality criterion, such as *unbiasedness*, *variance minimization*, or *efficiency*.\n", "\n", "> For example, lets say that we have collected some data on the prevalence of autism spectrum disorder (ASD) in some defined population. Our sample includes \\\\(n\\\\) sampled children, \\\\(y\\\\) of them having been diagnosed with autism. A frequentist estimator of the prevalence \\\\(p\\\\) is:\n", "\n", ">
\n", "> $\\hat{p} = \\frac{y}{n}$\n", ">
\n", "\n", "> Why this particular function? Because it can be shown to be unbiased and minimum-variance.\n", "\n", "It is important to note that new estimators need to be derived for every estimand that is introduced.\n", "\n", "### The Bayesian World View\n", "\n", "![Bayes](images/bayes.png)\n", "\n", "- Data are considered **fixed**. They used to be random, but once they were written into your lab notebook/spreadsheet/IPython notebook they do not change.\n", "- Model parameters themselves may not be random, but Bayesians use probability distribtutions to describe their uncertainty in parameter values, and are therefore treated as **random**. In some cases, it is useful to consider parameters as having been sampled from probability distributions.\n", "\n", "This implies the following form:\n", "\n", "
\n", "$p(\\theta | y)$\n", "
\n", "\n", "This formulation used to be referred to as ***inverse probability***, because it infers from observations to parameters, or from effects to causes.\n", "\n", "Bayesians do not seek new estimators for every estimation problem they encounter. There is only one estimator for Bayesian inference: **Bayes' Formula**." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Bayes' Formula\n", "\n", "Given two events A and B, the conditional probability of A given that B is true is expressed as follows:\n", "\n", "$Pr(A|B) = \\frac{Pr(B|A)Pr(A)}{Pr(B)}$\n", "\n", "where P(B)>0. Although Bayes' theorem is a fundamental result of probability theory, it has a specific interpretation in Bayesian statistics. \n", "\n", "In the above equation, A usually represents a proposition (such as the statement that a coin lands on heads fifty percent of the time) and B represents the evidence, or new data that is to be taken into account (such as the result of a series of coin flips). P(A) is the **prior** probability of A which expresses one's beliefs about A before evidence is taken into account. The prior probability may also quantify prior knowledge or information about A. \n", "\n", "P(B|A) is the **likelihood**, which can be interpreted as the probability of the evidence B given that A is true. The likelihood quantifies the extent to which the evidence B supports the proposition A. \n", "\n", "P(A|B) is the **posterior** probability, the probability of the proposition A after taking the evidence B into account. Essentially, Bayes' theorem updates one's prior beliefs P(A) after considering the new evidence B.\n", "\n", "P(B) is the **marginal likelihood**, which can be interpreted as the sum of the conditional probability of B under all possible events $A_i$\n", "in the sample\n", "space \n", "\n", "- For two events $P(B) = P(B|A)P(A) + P(B|\\bar{A})P(\\bar{A})$\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Example: Genetic probabilities\n", "\n", "Let's put Bayesian inference into action using a very simple example. I've chosen this example because it is one of the rare occasions where the posterior can be calculated by hand. We will show how data can be used to update our belief in competing hypotheses.\n", "\n", "Hemophilia is a rare genetic disorder that impairs the ability for the body's clotting factors to coagualate the blood in response to broken blood vessels. The disease is an **x-linked recessive** trait, meaning that there is only one copy of the gene in males but two in females, and the trait can be masked by the dominant allele of the gene. \n", "\n", "This implies that males with 1 gene are *affected*, while females with 1 gene are unaffected, but *carriers* of the disease. Having 2 copies of the disease is fatal, so this genotype does not exist in the population.\n", "\n", "In this example, consider a woman whose mother is a carrier (because her brother is affected) and who marries an unaffected man. Let's now observe some data: the woman has two consecutive (non-twin) sons who are unaffected. We are interested in determining **if the woman is a carrier**.\n", "\n", "![hemophilia](images/hemophilia.png)\n", "\n", "To set up this problem, we need to set up our probability model. The unknown quantity of interest is simply an indicator variable \\\\(W\\\\) that equals 1 if the woman is affected, and zero if she is not. We are interested in the probability that the variable equals one, given what we have observed:\n", "\n", "\\\\[Pr(W=1 | s_1=0, s_2=0)\\\\]\n", "\n", "Our prior information is based on what we know about the woman's ancestry: her mother was a carrier. Hence, the prior is \\\\(Pr(W=1) = 0.5\\\\). Another way of expressing this is in terms of the **prior odds**, or:\n", "\n", "\\\\[O(W=1) = \\frac{Pr(W=1)}{Pr(W=0)} = 1\\\\]\n", "\n", "Now for the likelihood: The form of this function is:\n", "\n", "\\\\[L(W | s_1=0, s_2=0)\\\\]\n", "\n", "This can be calculated as the probability of observing the data for any passed value for the parameter. For this simple problem, the likelihood takes only two possible values:\n", "\n", "\\\\[\\begin{aligned}\n", "L(W=1 &| s_1=0, s_2=0) = (0.5)(0.5) = 0.25 \\cr\n", "L(W=0 &| s_1=0, s_2=0) = (1)(1) = 1\n", "\\end{aligned}\\\\]\n", "\n", "With all the pieces in place, we can now apply Bayes' formula to calculate the posterior probability that the woman is a carrier:\n", "\n", "\\\\[\\begin{aligned}\n", "Pr(W=1 | s_1=0, s_2=0) &= \\frac{L(W=1 | s_1=0, s_2=0) Pr(W=1)}{L(W=1 | s_1=0, s_2=0) Pr(W=1) + L(W=0 | s_1=0, s_2=0) Pr(W=0)} \\cr\n", " &= \\frac{(0.25)(0.5)}{(0.25)(0.5) + (1)(0.5)} \\cr\n", " &= 0.2\n", "\\end{aligned}\\\\]\n", "\n", "Hence, there is a 0.2 probability of the woman being a carrier.\n", "\n", "Its a bit trivial, but we can code this in Python:" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [], "source": [ "prior = 0.5\n", "p = 0.5\n", "\n", "L = lambda w, s: np.prod([(1-i, p**i * (1-p)**(1-i))[w] for i in s])" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.2" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "s = [0,0]\n", "\n", "post = L(1, s) * prior / (L(1, s) * prior + L(0, s) * (1 - prior))\n", "post" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now, what happens if the woman has a third unaffected child? What is our estimate of her probability of being a carrier then? \n", "\n", "Bayes' formula makes it easy to update analyses with new information, in a sequential fashion. We simply assign the posterior from the previous analysis to be the prior for the new analysis, and proceed as before:" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.5" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "L(1, [0])" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.11111111111111112" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "s = [0]\n", "prior = post\n", "\n", "L(1, s) * prior / (L(1, s) * prior + L(0, s) * (1 - prior))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Thus, observing a third unaffected child has further reduced our belief that the mother is a carrier." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## More on Bayesian Terminology\n", "\n", "Replacing Bayes' Formula with conventional Bayes terms:\n", "\n", "![bayes formula](images/bayes_formula.png)\n", "\n", "The equation expresses how our belief about the value of \\\\(\\theta\\\\), as expressed by the **prior distribution** \\\\(P(\\theta)\\\\) is reallocated following the observation of the data \\\\(y\\\\), as expressed by the posterior distribution the posterior distribution.\n", "\n", "### Marginal\n", "\n", "The denominator \\\\(P(y)\\\\) is the likelihood integrated over all \\\\(\\theta\\\\):\n", "\n", "
\n", "$Pr(\\theta|y) = \\frac{Pr(y|\\theta)Pr(\\theta)}{\\int Pr(y|\\theta)Pr(\\theta) d\\theta}$\n", "
\n", "\n", "This usually cannot be calculated directly. However it is just a normalization constant which doesn't depend on the parameter; the act of summation washes out whatever info we had about the parameter. Hence it can often be ignored;The normalising constant makes sure that the resulting posterior distribution is a true probability distribution by ensuring that the sum of the distribution is equal to 1.\n", "\n", "In some cases we don’t care about this property of the distribution. We only care about where the peak of the distribution occurs, regardless of whether the distribution is normalised or not\n", "\n", "Unfortunately sometimes we are obliged to calculate it. The intractability of this integral is one of the factors that has contributed to the under-utilization of Bayesian methods by statisticians.\n", "\n", "### Prior\n", "\n", "Once considered a controversial aspect of Bayesian analysis, the prior distribution characterizes what is known about an unknown quantity before observing the data from the present study. Thus, it represents the information state of that parameter. It can be used to reflect the information obtained in previous studies, to constrain the parameter to plausible values, or to represent the population of possible parameter values, of which the current study's parameter value can be considered a sample.\n", "\n", "### Likelihood\n", "\n", "The likelihood represents the information in the observed data, and is used to update prior distributions to posterior distributions. This updating of belief is justified becuase of the **likelihood principle**, which states:\n", "\n", "> Following observation of \\\\(y\\\\), the likelihood \\\\(L(\\theta|y)\\\\) contains all experimental information from \\\\(y\\\\) about the unknown \\\\(\\theta\\\\).\n", "\n", "Bayesian analysis satisfies the likelihood principle because the posterior distribution's dependence on the data is only through the likelihood. In comparison, most frequentist inference procedures violate the likelihood principle, because inference will depend on the design of the trial or experiment.\n", "\n", "What is a likelihood function? It is closely related to the probability density (or mass) function. Taking a common example, consider some data that are binomially distributed (that is, they describe the outcomes of \\\\(n\\\\) binary events). Here is the binomial sampling distribution:\n", "\n", "$p(Y|\\theta) = {n \\choose y} \\theta^{y} (1-\\theta)^{n-y}$\n", "\n", "We can code this easily in Python:" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "from scipy.special import comb\n", "\n", "pbinom = lambda y, n, p: comb(n, y) * p**y * (1-p)**(n-y)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This function returns the probability of observing \\\\(y\\\\) events from \\\\(n\\\\) trials, where events occur independently with probability \\\\(p\\\\)." ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.1171875" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pbinom(3, 10, 0.5)" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "7.450580596923828e-07" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pbinom(1, 25, 0.5)" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAA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TpCTZn+SpJL857VomIcm3JXk8yZ8Mn++/Oe2adluSfzZ8Xf9xkl8a/qjjTEnyaJIXkvzxSNvrkzyZ5AvD6a3jftyZCP2R6/i+C7gTeP/w+ryz7Arwz6vqjcAPAv+ogTG/4ieAZ6ddxAT9O+C3qup7gb/OjI89ye3APwEGVfVX6X7d9/h0q9oV/wk4uqntAeATVXUE+MRwfqxmIvTpdx3fmVJVX6qqzw5v/2+6IBj/pShvMkkOAj8M/Ny0a5mEJN8CvAX4jwBV9VJV/c/pVjURB4BvGl6UaY4tLr6011XV79P9FP2o0euNfwR497gfd1ZCfzLX4r1JJVmku5bBZ6ZbyUR8GPiXwMvTLmRC3gBcAn5+uEvr55J887SL2k1V9V+BfwNcAL4EfKWqfnu6VU3MX6qqL0G3YQf8xXE/wKyEfq9r8c6iJK8DfpXuAjX/a9r17KYkPwK8UFWnp13LBB0A/gbw76vqLuD/sAv/5b+ZDPdjHwMOA98BfHOSD0y3qtkxK6Hf61q8sybJX6AL/NWq+rVp1zMBbwbuSXKObhfe303yn6db0q7bADaq6pX/xT1O9yEwy94G/GlVXaqq/wv8GvC3plzTpPz3JH8ZYDh9YdwPMCuh3+c6vjMlSej28z5bVf922vVMQlX9ZFUdrKpFuuf4k1U101uAVfXfgOeTfM+w6a3AM1MsaRIuAD+YZG74On8rM37wesTo9cbvBX593A9wYNx3OA1VdSXJ/cAT/Pl1fJ+eclm77c3A3wf+KMnnhm3/qqo+NsWatDv+MbA63KA5C/yDKdezq6rqM0keBz5Ld5baU8zgt3OT/BLwd4DbkmwADwEfAj6a5D66D7/3jv1x/UauJLVjVnbvSJJ6MPQlqSGGviQ1xNCXpIYY+pLUEENfkhpi6EtSQwx9SWrI/wMPxnMEu8DVOAAAAABJRU5ErkJggg==\n", "text/plain": [ "
" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" } ], "source": [ "yvals = range(10+1)\n", "plt.plot(yvals, [pbinom(y, 10, 0.5) for y in yvals], 'ro');" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "What about the likelihood function? \n", "\n", "The likelihood function is the exact same form as the sampling distribution, except that we are now interested in varying the parameter for a given dataset." ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAD8CAYAAACb4nSYAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzt3Xl8lOW99/HPb2ayEJIQIIFAFhJ2wo4hLG4oLriBu4BrS8tRa9fz9Kk9PdXWnu7H03Nal4rVU21VtFoV2dQqi1VZwhYICCQBsgIhgQDZZ+Z6/sjgE2MgEzIz9yy/9+uVF5OZe2a+N0m+uXPdyyXGGJRSSkUGm9UBlFJKBY6WvlJKRRAtfaWUiiBa+kopFUG09JVSKoJo6SulVATR0ldKqQiipa+UUhFES18ppSKIw+oAHSUnJ5usrCyrYyilVEjZsmXLMWNMSlfLBV3pZ2VlkZ+fb3UMpZQKKSJyyJvldHhHKaUiiJa+UkpFEC19pZSKIFr6SikVQbT0lVIqgnhV+iIyR0T2ikiRiDzcyePfE5HdIlIgIh+IyJB2j7lEZLvnY5kvwyullOqeLg/ZFBE78CRwJVAObBaRZcaY3e0W2wbkGmMaROQB4DfAHZ7HGo0xk3ycWyml1Hnw5jj9PKDIGFMCICJLgXnA56VvjFnTbvkNwF2+DKki29GTTVTVNXG62cmpplZONTk53ezkdJOTsWmJXDZqACJidUylQoI3pZ8GlLX7vByYdo7lFwGr2n0eKyL5gBP4lTHmrW6nVBHpVFMrj7+3jxc/PYj7HFM5jxmUyDcvH86csanYbFr+Sp2LN6Xf2U9Rpz+CInIXkAtc2u7uTGNMpYgMBT4UkZ3GmOIOz1sMLAbIzMz0KrgKX8YYVuys4rF3dlN9upkFeZnMHj2A+BgHCb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t1/glwl4iUAyuBbwYmmmW6+/PeLaE4G3hPJmoPVV6vj4jcBeQCl/o1kf+dc51FxAb8DrgvUIECwJuvs4O2IZ5ZtP0195GIjDPGnPBzNn/xZp0XAH82xjwuIjNom6VvnDHG7f94lvBrf4Xiln53Jmqnw0TtocqrCeZF5ArgR8BcY0xzgLL5S1frnACMA9aKyEHaxj6XhfjOXG+/t982xrQaYw4Ae2n7JRCqvFnnRcBrAMaYT4FY2q5RE668+nk/X6FY+j2ZqD1UdbnOnqGOZ2gr/FAf54Uu1tkYU2eMSTbGZBljsmjbjzHXGBPKc2168739Fm077RGRZNqGe0oCmtK3vFnnUmA2gIiMoa30qwOaMrCWAfd4juKZDtQZY6p89eIhN7xjejBRe6jycp1/C8QDf/Pssy41xsy1LHQPebnOYcXLdX4XuEpEdgMu4PvGmBrrUveMl+v8r8CzIvJd2oY57gvljTgReYW24blkz36KR4EoAGPMH2nbb3EtUAQ0AF/x6fuH8P+dUkqpbgrF4R2llFLnSUtfKaUiiJa+UkpFEC19pZSKIFr6SikVQbT0lVIqgmjpK6VUBNHSV0qpCPL/AKHVemphw/VLAAAAAElFTkSuQmCC\n", "text/plain": [ "
" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" } ], "source": [ "pvals = np.linspace(0, 1)\n", "y = 4\n", "plt.plot(pvals, [pbinom(y, 10, p) for p in pvals]);" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "So, though we are dealing with the same equation, these are entirely different functions; the distribution is discrete, while the likelihood is continuous; the distribtion's range is from 0 to 10, while the likelihood's is 0 to 1; the distribution integrates (sums) to one, while the likelhood does not." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Posterior\n", "\n", "The mathematical form \\\\(p(\\theta | y)\\\\) that we associated with the Bayesian approach is referred to as a **posterior distribution**.\n", "\n", "> posterior /pos·ter·i·or/ (pos-tēr´e-er) later in time; subsequent.\n", "\n", "Why posterior? Because it tells us what we know about the unknown \\\\(\\theta\\\\) *after* having observed \\\\(y\\\\)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Why be Bayesian?\n", "\n", "At this point, it is worth addressing the question of why one might consider an alternative statistical paradigm to the classical/frequentist statistical approach. After all, it is not always easy to specify a full probabilistic model, nor to obtain output from the model once it is specified. So, why bother?\n", "\n", "> ... the Bayesian approach is attractive because it is useful. Its usefulness derives in large measure from its simplicity. Its simplicity allows the investigation of far more complex models than can be handled by the tools in the classical toolbox. \n", "*-- Link and Barker 2010*\n", "\n", "We already noted that there is just one estimator in Bayesian inference, which lends to its ***simplicity***. Moreover, Bayes affords a conceptually simple way of coping with multiple parameters; the use of probabilistic models allows very complex models to be assembled in a modular fashion, by factoring a large joint model into the product of several conditional probabilities.\n", "\n", "Bayesian statistics is also attractive for its ***coherence***. All unknown quantities for a particular problem are treated as random variables, to be estimated in the same way. Existing knowledge is given precise mathematical expression, allowing it to be integrated with information from the study dataset, and there is formal mechanism for incorporating new information into an existing analysis.\n", "\n", "Finally, Bayesian statistics confers an advantage in the ***interpretability*** of analytic outputs. Because models are expressed probabilistically, results can be interpreted probabilistically. Probabilities are easy for users (particularly non-technical users) to understand and apply." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Example: confidence vs. credible intervals\n", "\n", "A commonly-used measure of uncertainty for a statistical point estimate in classical statistics is the ***confidence interval***. Most scientists were introduced to the confidence interval during their introductory statistics course(s) in college. Yet, a large number of users mis-interpret the confidence interval.\n", "\n", "Here is the mathematical definition of a 95% confidence interval for some unknown scalar quantity that we will here call \\\\(\\theta\\\\):\n", "\n", "
\n", "$Pr(a(Y) < \\theta < b(Y) | \\theta) = 0.95$\n", "
\n", "\n", "how the endpoints of this interval are calculated varies according to the sampling distribution of \\\\(Y\\\\), but for as an example, the confidence interval for the population mean when \\\\(Y\\\\) is normally distributed is calculated by:\n", "\n", "$Pr(\\bar{Y} - 1.96\\frac{\\sigma}{\\sqrt{n}}< \\theta < \\bar{Y} + 1.96\\frac{\\sigma}{\\sqrt{n}}) = 0.95$\n", "\n", "It would be tempting to use this definition to conclude that there is a 95% chance \\\\(\\theta\\\\) is between \\\\(a(Y)\\\\) and \\\\(b(Y)\\\\), but that would be a mistake. \n", "\n", "Recall that for frequentists, unknown parameters are **fixed**, which means there is no probability associated with them being any value except what they are fixed to. Here, the interval itself, and not \\\\(\\theta\\\\) is the random variable. The actual interval calculated from the data is just one possible realization of a random process, and it must be strictly interpreted only in relation to an infinite sequence of identical trials that might be (but never are) conducted in practice.\n", "\n", "A valid interpretation of the above would be:\n", "\n", "> If the experiment were repeated an infinite number of times, 95% of the calculated intervals would contain \\\\(\\theta\\\\).\n", "\n", "This is what the statistical notion of \"confidence\" entails, and this sets it apart from probability intervals.\n", "\n", "Since they regard unknown parameters as random variables, Bayesians can and do use probability intervals to describe what is known about the value of an unknown quantity. These intervals are commonly known as ***credible intervals***.\n", "\n", "The definition of a 95% credible interval is:\n", "\n", "
\n", "$Pr(a(y) < \\theta < b(y) | Y=y) = 0.95$\n", "
\n", "\n", "Notice that we condition here on the data \\\\(y\\\\) instead of the unknown \\\\(\\theta\\\\). Thus, the endpoints are fixed and the variable is random. \n", "\n", "We are allowed to interpret this interval as:\n", "\n", "> There is a 95% chance \\\\(\\theta\\\\) is between \\\\(a\\\\) and \\\\(b\\\\).\n", "\n", "Hence, the credible interval is a statement of what we know about the value of \\\\(\\theta\\\\) based on the observed data." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Bayesian Inference, in 3 Easy Steps\n", "\n", "We are now ready (and willing!) to apply Bayesian methods to our problem. Gelman et al. (2013) describe the process of conducting Bayesian statistical analysis in 3 steps:\n", "\n", "![123](images/123.png)\n", "\n", "\n", "\n", "### Step 1: Specify a probability model\n", "\n", "As was noted above, Bayesian statistics involves using probability models to solve problems. So, the first task is to *completely specify* the model in terms of probability distributions. This includes everything: unknown parameters, data, covariates, missing data, predictions. All must be assigned some probability density.\n", "\n", "This step involves making choices.\n", "\n", "- what is the form of the sampling distribution of the data?\n", "- what form best describes our uncertainty in the unknown parameters?\n", "\n", "### Step 2: Calculate a posterior distribution\n", "\n", "The posterior distribution is formulated as a function of the probability model that was specified in Step 1. Usually, we can write it down but we cannot calculate it analytically. In fact, the difficulty inherent in calculating the posterior distribution for most models of interest is perhaps the major contributing factor for the lack of widespread adoption of Bayesian methods for data analysis.\n", "\n", "**But**, once the posterior distribution is calculated, you get a lot for free:\n", "\n", "- point estimates\n", "- credible intervals\n", "- quantiles\n", "- predictions\n", "\n", "### Step 3: Check your model\n", "\n", "Though frequently ignored in practice, it is critical that the model and its outputs be assessed before using the outputs for inference. Models are specified based on assumptions that are largely unverifiable, so the least we can do is examine the output in detail, relative to the specified model and the data that were used to fit the model.\n", "\n", "Specifically, we must ask:\n", "\n", "- does the model fit data?\n", "- are the conclusions reasonable?\n", "- are the outputs sensitive to changes in model structure?\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "---" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## References\n", "\n", "Gelman A, Carlin JB, Stern HS, Dunson DB, Vehtari A, Rubin DB. Bayesian Data Analysis, Third Edition. CRC Press; 2013." ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n" ], "text/plain": [ "" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from IPython.core.display import HTML\n", "def css_styling():\n", " styles = open(\"styles/custom.css\", \"r\").read()\n", " return HTML(styles)\n", "css_styling()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.2" }, "toc": { "base_numbering": 1, "nav_menu": { "height": "12px", "width": "325px" }, "number_sections": true, "sideBar": true, "skip_h1_title": false, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": true, "toc_position": {}, "toc_section_display": true, "toc_window_display": true } }, "nbformat": 4, "nbformat_minor": 1 }