<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/choosing-priors-double-yolk-bayesian-egg/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://blog.revolutionanalytics.com/2018/03/bayesian-egg.html"> Revolutions</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<div>
<div><em>by Subhadeep (Deep) Mukhopadhyay and Douglas Fletcher, Department of Statistical Science, Temple University </em></div>
<p>Bayesians and Frequentists have long been ambivalent toward each other. The concept of “Prior” remains the center of this 250 years old tug-of-war: frequentists view prior as a weakness that can cloud the final inference, whereas Bayesians view it as a strength to incorporate expert knowledge into the data analysis. So, the question naturally arises, how can we develop a Bayes-frequentist consolidated data analysis workflow that enjoys the best of both worlds?</p>
<p>To develop a “defendable and defensible” Bayesian learning model, we have to go beyond blindly ‘turning the crank’ based on a “go-as-you-like” [approximate guess] prior. A lackluster attitude towards prior modeling could lead to disastrous inference, impacting various fields from clinical drug development to presidential election forecasts. The real questions are: How can we uncover the blind spots of the conventional wisdom-based prior? How can we develop the science of prior model-building that combines both data and science [DS-prior] in a <em>testable</em> manner – a double-yolk Bayesian egg? Unfortunately, these questions are outside the scope of business-as-usual Bayesian modus operandi and require new ideas, which is the goal of the paper, <a rel="nofollow" href="https://arxiv.org/pdf/1802.00474.pdf" target="_blank">“Bayesian Modeling via Goodness of Fit”</a>. In the following, we demonstrate how to prepare the “Bayesian omelet” — the operational part — using the R package <a rel="nofollow" href="https://cran.r-project.org/web/packages/BayesGOF/index.html" target="_blank"><code>BayesGOF</code></a>.</p>
<p>Our model-building approach proceeds sequentially as follows:</p>
<ol>
<li>it starts with a scientific (or empirical) parametric prior <span>\(g(\theta;\alpha,\beta)\)</span>, </li>
<li>inspects the adequacy and the remaining uncertainty of the elicited prior using a graphical exploratory tool,</li>
<li>estimates the necessary “correction” for assumed <span>\(g\)</span> by looking at the data,</li>
<li>generates the final statistical estimate <span>\(\hat \pi(\theta)\)</span>, and</li>
<li>executes macro and micro-level inference.</li>
</ol>
<p>Our algorithmic solution yields answers to all five of the phases using <em>one single</em> algorithm, which we will now demonstrate for rat tumor data. The <code>rat</code> tumor data consists of observations of endometrial stromal polyp incidence in <span>\(k=70\)</span> groups of rats. For each group, <span>\(y_i\)</span> is the number of rats with polyps and <span>\(n_i\)</span> is the total number of rats in the experiment. The dataset is available in the R package <code>BayesGOF</code>.</p>
<p>The Rat-data model: <span>\(y_i\,\overset{{\rm ind}}{\sim}\,\mbox{Binomial}( n_i, \theta_i)\)</span>, <span>\(i=1,\ldots,k\)</span>, where the unobserved parameters <span>\(\theta=(\theta_1,\ldots,\theta_k)\)</span> are independent realizations from the <em>unknown</em> <span>\(\pi(\theta)\)</span>.</p>
<p><strong>Step 1.</strong> We begin by finding the starting parameter values for parametric conjugate <span>\(g \sim Beta(\alpha, \beta)\)</span>:</p>
<pre><code>library(BayesGOF)
set.seed(8697)
data(rat)
###Use MLE to determine starting values
rat.start &lt;- gMLE.bb(rat$y, rat$n)$estimate</code></pre>
<p>We use our starting parameter values to run the main DS.prior function:</p>
<pre><code>rat.ds &lt;- DS.prior(rat, max.m = 6, rat.start, family = &quot;Binomial&quot;)</code></pre>
<p>Next we will discuss how to interpret and use this <code>rat.ds</code> object for exploratory Bayes modeling and prior uncertainty quantification.</p>
<p><strong>Step 2.</strong> We display the U-function to quantify and characterize the uncertainty of the a priori selected <span>\(g\)</span>:</p>
<pre><code>plot(rat.ds, plot.type = &quot;Ufunc&quot;)</code></pre>
<p><img border="0" alt="Img1" title="Img1" src="http://a7.typepad.com/6a0105360ba1c6970c01b7c954a0b7970b-800wi"></p>
<p>The deviations from the uniform distribution (the red dashed line) indicates that our initial selection for <span>\(g\)</span>, <span>\(\text{Beta}(\alpha = 2.3,\beta = 14.1)\)</span>, is incompatible with the observed data and requires repair; the data indicate that there are, in fact, two different groups of incidence in the rats.</p>
<p><strong>Step 3a.</strong> Extract the parameters for the nonparametrically <em>corrected</em> prior <span>\(\hat{\pi}\)</span>:</p>
<pre><code>rat.ds</code></pre>
<pre><code>## $g.par
##     alpha      beta 
##  2.304768 14.079707 
## 
## $LP.coef
##        LP1        LP2        LP3 
##  0.0000000  0.0000000 -0.5040361</code></pre>
<p>Therefore, our estimated DS(G.m) prior is given by: <span>\[\hat{\pi}(\theta) = g(\theta; \alpha,\beta)\Big[1 – 0.52T_3(\theta;G) \Big].\]</span></p>
<p>The DS-prior has a unique two-component structure that combines parametric <span>\(g\)</span>, and a nonparametric <span>\(d\)</span> (which we call the <em>U-function</em>). Here <span>\(T_j(\Theta;G)\)</span>, <span>\(j = 1,\ldots,m\)</span> are a specialized orthonormal basis given by <span>\(\text{Leg}_j[G(\Theta)]\)</span>, members of LP-class of rank-polynomials. Note that <span>\({\rm DS}(G,m=0) \equiv g(\theta;\alpha,\beta)\)</span>. The truncation point <span>\(m\)</span> reflects the <em>concentration</em> of true unknown <span>\(\pi\)</span> around the pre-selected <span>\(g\)</span>.</p>
<p><strong>Step 3b.</strong> Plot the estimated DS prior <span>\(\hat{\pi}\)</span> along with the original parametric <span>\(g\)</span>:</p>
<pre><code>plot(rat.ds, plot.type = &quot;DSg&quot;)</code></pre>
<p> </p>
<p><img border="0" alt="Img2" title="Img2" src="http://a6.typepad.com/6a0105360ba1c6970c01b8d2def38e970c-800wi"></p>
<div>
<h3>MacroInference</h3>
<p>The term “MacroInference” aims to answer the following question: How to combine <span>\(k\)</span> binomial parameters to come up with an overall, macro-level aggregated statistical behavior of <span>\(\theta_1,\ldots,\theta_k\)</span>? This is often important in applied analysis, as the limited sample size of a single study hardly provides adequate evidence for a definitive conclusion.</p>
<p><strong>Step 4.</strong> Here we are interested in the <em>overall</em> macro-level inference by combining the <span>\(k=70\)</span> parallel studies. The group-specific modes along with their SEs can be computed as follows:</p>
<pre><code>rat.macro.md &lt;- DS.macro.inf(rat.ds, num.modes = 2 , iters = 25, method = &quot;mode&quot;) </code></pre>
<pre><code>rat.macro.md</code></pre>
<pre><code>##      1SD Lower Limit   Mode 1SD Upper Limit
## [1,]          0.0161 0.0340          0.0520
## [2,]          0.1442 0.1562          0.1681</code></pre>
<pre><code>plot(rat.macro.md)</code></pre>
<p><a rel="nofollow" href="http://a6.typepad.com/6a0105360ba1c6970c01b8d2def3ae970c-pi" target="_blank"><img border="0" alt="Img3" title="Img3" src="http://a6.typepad.com/6a0105360ba1c6970c01b8d2def3ae970c-800wi"></a></p>
</div>
<div>
<h3>MicroInference</h3>
<p>“Microinference” refers to the process of using information from historical studies to improve the estimates of one or more studies of particular interest. This is known as “borrowing strength” in Bayesian inference literature. It is noteworthy to mention that the classical Stein’s shrinkage does not work for <code>rat</code> data due to the presence of multiple partially exchangeable studies. Our adaptive (or selective) shrinkage technology selectively borrows strength from ‘similar’ experiments in an automated manner, by answering the important question: <em>where to shrink?</em>.</p>
<p><strong>Step 5.</strong> In addition to the earlier <span>\(k=70\)</span> studies for the rat tumor data, we have a current experimental study that shows <span>\(y_{71}=4\)</span> out of <span>\(n_{71}=14\)</span> rats developed tumors. The following code performs the desired microinference for <span>\(\theta_{71}\)</span> (posterior distribution along with its mean and mode):</p>
<pre><code>rat.y71.micro &lt;- DS.micro.inf(rat.ds, y.0 = 4, n.0 = 14)
rat.y71.micro</code></pre>
<pre><code>## Posterior summary for y = 4, n = 14:
##  Posterior Mean = 0.1897
##  Posterior Mode = 0.1833
## Use plot(x) to generate posterior plot</code></pre>
<p><a rel="nofollow" href="http://a1.typepad.com/6a0105360ba1c6970c01b7c954a0f9970b-pi" target="_blank"><img alt="Rat_micro2" title="Rat_micro2" src="http://a1.typepad.com/6a0105360ba1c6970c01b7c954a0f9970b-250wi"> </a> <a rel="nofollow" href="http://a7.typepad.com/6a0105360ba1c6970c01b8d2def3cf970c-pi" target="_blank"><img alt="Rat_shrink" title="Rat_shrink" src="http://a7.typepad.com/6a0105360ba1c6970c01b8d2def3cf970c-250wi"></a><a rel="nofollow" href="http://a1.typepad.com/6a0105360ba1c6970c01b7c954a0f9970b-pi" target="_blank"><br></a></p>
<p>The left plot (a) compares the posterior distributions for the parametric <span>\(g\)</span> (blue) and the DS posterior (red). The right plot (b) compares our adaptive shrinkage with Stein’s estimates. The vertical red triangles indicate the modes of the DS prior, while the blue triangle is the mode of the parametric <span>\(g\)</span>. For additional real-data examples, please see the <a rel="nofollow" href="https://cran.r-project.org/web/packages/BayesGOF/vignettes/vignette_BayesGOF.html" target="_blank">package vignette</a>.</p>
</div>
<div>
<h3>Conclusion</h3>
<p>All most all modern scientific research utilizes domain-knowledge and data to come up with breakthrough results. But the fundamental problem of how to fuse these “approximate” scientific prior knowledge with the data at hand is not a settled issue even 250 years after the discovery of the Bayes law (for more details, see <a rel="nofollow" href="http://science.sciencemag.org/content/340/6137/1177" target="_blank">“Bayes’ Theorem in the 21st Century”</a> and <a rel="nofollow" href="http://advances.sciencemag.org/content/3/6/e1700768.full" target="_blank">“Statistical thinking for 21st century scientists”</a>). Bayesian modeling via goodness-of-fit technology, synthesized in the R package <a rel="nofollow" href="https://cran.r-project.org/web/packages/BayesGOF/index.html" target="_blank"><code>BayesGOF</code></a>, allows us to determine a <em>scientific</em> prior that is consistent with the <em>data</em> at hand, in a systematic and principled way.</p>
</div>
</div>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://blog.revolutionanalytics.com/2018/03/bayesian-egg.html"> Revolutions</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/0-Bfgf2ife8" height="1"></a></div>