Chapter 3 Fundamentals of Bayesian Inference - Bayesian Hierarchical Models in Ecology
Chapter 3 Fundamentals of Bayesian Inference - Bayesian Hierarchical Models in Ecology
“All models are wrong, but some are useful” -George Box
“There has never been a straight line nor a Normal distribution in history, and yet,
using assumptions of linearity and normality allows, to a good approximation, to
understand and predict a huge number of observations.” -W.J. Youden
“Nothing is gained if you replace a world that you don’t understand with a model
that you don’t understand.” -John Maynard Smith
https://bookdown.org/steve_midway/BHME/Ch2.html 1/14
4/5/24, 6:39 PM Chapter 3 Fundamentals of Bayesian Inference | Bayesian Hierarchical Models in Ecology
Explanation (understanding)
Prediction
Focus on fitting y
https://bookdown.org/steve_midway/BHME/Ch2.html 2/14
4/5/24, 6:39 PM Chapter 3 Fundamentals of Bayesian Inference | Bayesian Hierarchical Models in Ecology
Figure 3.1: Table of best-fitting models as determined by AIC (Midway et al. 2013).
AIC was able to determine a best-fitting model; however, there were several
competing models all of which tended to have a large number of predictors.
Upon closer evaluation, it appeared that a large number of models all performed
relatively well, when compared with each other. This cloud of model points
warranted further investigation.
https://bookdown.org/steve_midway/BHME/Ch2.html 3/14
4/5/24, 6:39 PM Chapter 3 Fundamentals of Bayesian Inference | Bayesian Hierarchical Models in Ecology
https://bookdown.org/steve_midway/BHME/Ch2.html 4/14
4/5/24, 6:39 PM Chapter 3 Fundamentals of Bayesian Inference | Bayesian Hierarchical Models in Ecology
“Our answer is that 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.” Link and Barker (2009)
Thomas Bayes was a Presbyterian Minister who is thought to have been born in
1701 and died 1761. He posthumously published An Essay towards solving a
Problem in the Doctrine of Chances in 1763, in which he introduced his approach
https://bookdown.org/steve_midway/BHME/Ch2.html 5/14
4/5/24, 6:39 PM Chapter 3 Fundamentals of Bayesian Inference | Bayesian Hierarchical Models in Ecology
Given the number of times in which an unknown event has happened and failed:
Required the chance that the probability of its happening in a single trial lies
somewhere between any two degrees of probability that can be named.
Consider an example where 10 chicks hatch and 4 survive. Bayes attempts to draw
a conclusion, such as “The probability that p (survival) is between 0.23 and 0.59 is
0.80.” The two degrees of probability are an interval; P r(a ≤ p ≤ b) . The overall
idea is similar to a confidence interval in trying to account for and reduce
uncertainty—but confidence intervals are not probabilistic, so they are are not the
same.
But for a Bayesian, probability is the belief that a parameter takes a specific value.
“Probability is the sole measure of uncertainty about all unknown quantities:
parameters, unobservables, missing or mis-measured values, future or unobserved
predictions” (Kéry and Schaub 2011). When everything is a probability, we can use
mathematical laws of probability. One way to get started is to think of parameters
as random variables (but technically they are not.)
https://bookdown.org/steve_midway/BHME/Ch2.html 6/14
4/5/24, 6:39 PM Chapter 3 Fundamentals of Bayesian Inference | Bayesian Hierarchical Models in Ecology
P (B|A) × P (A)
P (A|B) =
P (B)
Example of Bayes’ Rule Bird watching (B) or watching football (F), depending on
good weather (g) or bad weather (b) on given day.
We know:
1. g + B = 0.5 (joint)
2. g = 0.6 (marginal)
3. B = 0.7 (marginal)
If you are watching football, what is the best guess as to the weather?
https://bookdown.org/steve_midway/BHME/Ch2.html 7/14
4/5/24, 6:39 PM Chapter 3 Fundamentals of Bayesian Inference | Bayesian Hierarchical Models in Ecology
We know:
1. p(b, F ) = 0.2
2. p(F ) = 0.3
p(b,F ) 0.2
3. p(b|F ) = =
0.3
= 0.66
p(F )
The probability of bad weather is 0.4, but knowing football is more likely with bad
weather, football increased our guess to 0.66.
P (y|θ) × P (θ)
P (θ|y) =
P (y)
where
https://bookdown.org/steve_midway/BHME/Ch2.html 8/14
4/5/24, 6:39 PM Chapter 3 Fundamentals of Bayesian Inference | Bayesian Hierarchical Models in Ecology
y <- c(-0.5, 0.1, 1.2, 1.2, 1.2, 1.85, 2.45, 3.0, -1.8, -1.8, -0.4, 0, 0, 0.5
g <- c(rep('g1', 8), rep('g2', 8))
We might want to consider a t-test to compare the groups (means). In this case,
we are estimating 5 parameters from 16 data points.
t.test(y ~ g)
##
Our t-test results in a p-value of 0.0406, which is less than the traditional cutoff of
0.05 and allowing us to conclude that the group means are significantly different. At
this point in our study, we would write up our model results and likely conclude the
analysis. The frequentist t-test is simple, but limited.
https://bookdown.org/steve_midway/BHME/Ch2.html 9/14
4/5/24, 6:39 PM Chapter 3 Fundamentals of Bayesian Inference | Bayesian Hierarchical Models in Ecology
Here we see a posterior distribution of our results. The mean difference between
groups was estimated to be 1.37, and the 95% credible interval around that
difference is reported as -0.248 to 3.01. A credible interval represents the
percentage (95% in this case) of symmetric area under the distribution that
represents the uncertainty in our point estimate. The percentage can also be used
to interpret the chance that the interval has captured the true parameter. So in this
example, we can say that we are 95% certain that the true difference in means lies
between -0.248 and 3.01, with our best guess being 1.37. Another thing we can
use credible intervals for is “significance” interpretation. If a credible interval
overlaps 0, it can be interpreted that 0 is within the range of possible estimates and
therefore there is no significant interpretation. (If 0 were to be outside our 59% CI,
we would have evidence that 0 is not a very likely estimate and therefore the group
means are “statistically significant.”) It’s worth noting that the concept of statistical
significance may be alive and well in Bayesian esimation; however, you need to
define how the term is used because there is no a priori significance level as there
is in frequentist routines.
Consider also that the frequentist t-test found a significant difference and the
Bayesian t-test did not find a difference. In reality, with simple (and even more
complex) datasets, both types of estimation will often arrive at the same answer.
This example was generated to show that there is the possibility to reach different
significance conclusions using the same data. Perhaps what is more important in
this example is to ask yourself if two types of estimation reach different conclusions
about the data, which are you more likely to trust—the procedure that provides little
information and spits out a yes or no, or the procedure that is full tractable and
provides results and estimation for all parts of the model?
https://bookdown.org/steve_midway/BHME/Ch2.html 10/14
4/5/24, 6:39 PM Chapter 3 Fundamentals of Bayesian Inference | Bayesian Hierarchical Models in Ecology
Despite the benefits illustrated in this example, it’s important to know that the
Bayesian approach is not inherently the correct way to appraoch estimation. In
fact, we cannot know which method is correct. All we can know is that we are
presented with a choice as to which method provides richer information from which
we can base a decision.
Frequentists: p(data|θ)
Bayesians: p(θ|data)
Frequentists asks: The world is fixed and unchanging; therefore, given a certain
parameter value, how likely am I to observe data that supports that parameter
value?
Bayesian asks: The only thing I can know about the changing world is what I can
observe; therefore, based on my data, what are the most likely parameter values I
could infer?
https://bookdown.org/steve_midway/BHME/Ch2.html 11/14
4/5/24, 6:39 PM Chapter 3 Fundamentals of Bayesian Inference | Bayesian Hierarchical Models in Ecology
Given the strengths and weaknesses for both types of estimation, why did the
Frequentist approach dominate for so long, even to the present? The best
explanation includes several reasons. Frequentist routines are computationally
simple compared to Bayesian appraoches, which has permitted them to be
formalized into point-and-click routines that are available to armchair statisticians.
Additionally, the create and popularization of ANOVA ran parallel to the rise in
popularity of Frequentist appraoches, and ANOVA provided an excellent model for
many data sets. Finally, although the limitations and issues with p-values are well-
publicized, there has been historic appeal for statistical complexity being reduced
to a significant or non-significant outcome.
Consider the point estimate of 5:12 and the associated uncertainty of 4:12–6:12
https://bookdown.org/steve_midway/BHME/Ch2.html 12/14
4/5/24, 6:39 PM Chapter 3 Fundamentals of Bayesian Inference | Bayesian Hierarchical Models in Ecology
Bayesian interpretation: Based on the data, we are 95% certain that the interval
4.12–6.12 contains the parameter value, with the most likely value being 5.12 (the
mean/mode of the distribution).
Pros
Cons
https://bookdown.org/steve_midway/BHME/Ch2.html 13/14
4/5/24, 6:39 PM Chapter 3 Fundamentals of Bayesian Inference | Bayesian Hierarchical Models in Ecology
References
Kéry, Marc, and Michael Schaub. 2011. Bayesian Population Analysis Using
Winbugs: A Hierarchical Perspective. Academic Press.
Link, William A, and Richard J Barker. 2009. Bayesian Inference: With Ecological
Applications. Academic Press.
https://bookdown.org/steve_midway/BHME/Ch2.html 14/14