← 2. Comparing groups
Bayesian Analysis
Try this analysis →

Bayesian Analysis

A method that updates existing information each time new data are observed and expresses uncertainty as probability.

Prior distributionPosterior distributionCredible intervalBayes factor

0%10%20%30%40%Observed 15/100Posterior Beta(17, 103)Mean 14.2%Prior Beta(2, 18)Mean 10%Purchase conversion rate

How likely is it that a new training program is more effective than the existing one? Can we calculate the probability that a new product's purchase conversion rate is higher than that of an existing product? When study results come in, can we also take into account the information we already had?

A statistical approach that can be used for questions like these is Bayesian analysis. Bayesian analysis updates existing information or beliefs each time new data are observed, and expresses uncertainty about the parameters or hypotheses of interest as probability.

It differs from traditional frequentist statistics in how it interprets probability and in the process of statistical inference. It is used especially to express uncertainty about study results directly as probability, or to bring information from earlier studies into a new analysis.

In this article, we look at Bayesian analysis from its basic concepts to Bayes' theorem, prior and posterior distributions, a worked example, the Bayesian t-test and Bayesian ANOVA, and how it differs from conventional statistical analysis.

SECTION 1

What is Bayesian analysis?

Bayesian analysis is a statistical method that updates probabilities based on the information you already had when new data are observed.

For example, suppose you want to find out whether a new study program raises students' test scores. Before starting the study, you may already have information from earlier research that teaching methods similar to this program can be somewhat effective.

Then, once you collect actual experimental data, Bayesian analysis combines the existing information with the newly observed data to update the estimate of the program's effect and its uncertainty.

In this process, the existing information is called the prior distribution, and the result updated after observing the data is called the posterior distribution.

The defining feature of Bayesian analysis is that it expresses uncertainty about parameters as a probability distribution. For example, if you have set up an appropriate model and prior distribution, you can answer questions like these.

However, you should understand that these probabilities are calculated on the premise of the chosen statistical model, the prior distribution, and the observed data.

SECTION 2

How does Bayesian analysis work?

At the core of Bayesian analysis is Bayes' theorem.

Bayes' theorem describes how to update probabilities by combining existing information with new evidence. In Bayesian statistics, the following relationship is generally used.

Posterior ∝ Likelihood × Prior

Prior distributionLikelihood×Posterior distribution=
Prior, likelihood, and posterior

Each concept means the following.

ComponentMeaning
Prior distribution (prior)A distribution expressing uncertainty about a parameter before observing the data
LikelihoodA function showing how plausible the observed data are at a given parameter value
Posterior distribution (posterior)The probability distribution of the parameter, updated to reflect the observed data
Posterior predictive distributionThe predictive distribution of new observations that accounts for the uncertainty of the estimated parameters

prior distribution

The prior distribution expresses, as a probability distribution, the information you have about the parameter of interest before observing the current data. For example, if earlier studies found that the effect of a certain training program was generally small, you can reflect this by setting a prior distribution that gives relatively high probability to small effects.

You do not necessarily need earlier study results. When prior information is lacking, you can use something like a weakly informative prior that allows a wide range of values. However, no prior distribution can be declared completely neutral, so it is important to check the grounds for the choice.

Likelihood

The likelihood shows how plausible the actually observed data are, assuming a particular parameter value. For example, if you want to estimate a product's purchase conversion rate, you calculate how plausibly the actual numbers of visitors and buyers could arise at that conversion rate.

The likelihood plays the key role of bringing the information that new data provide about the parameter.

posterior distribution

The posterior distribution is the result of combining the prior distribution and the likelihood. It shows which parameter values are relatively plausible after observing the data and how much uncertainty there is about the parameter. In Bayesian analysis, this posterior distribution is used to calculate parameter estimates, credible intervals, the probability of meeting a particular condition, and so on.

SECTION 3

Worked example: analyzing a new product's purchase conversion rate

Suppose an online store wants to check the purchase conversion rate of a new product page.

The purchase conversion rate is the proportion of product page visitors who actually make a purchase. Before launching the new page, the store expected the conversion rate to be around 10%. It then collected data on 100 visitors and found that 15 bought the product.

ItemValue
Visitors100
Buyers15
Observed conversion rate15%
Conversion rate expected beforehandAbout 10%

Let's analyze these data with a Bayesian method.

Setting the prior distribution

Since the purchase conversion rate is a value between 0 and 1, we can use a beta distribution. For illustration, we set the prior distribution to Beta(2, 18). The mean of this prior is 0.10, which matches the prior expectation that the conversion rate will be about 10%.

Note that this distribution was chosen as an example; in a real study, the prior distribution should be chosen based on existing data and the purpose of the study.

Incorporating the new data

We observed that 15 of 100 people made a purchase. If we assume each purchase decision is an independent Bernoulli trial, the number of buyers can be modeled as following a binomial distribution. Combining the beta prior with the binomial likelihood gives the posterior distribution as follows.

Beta(2 + 15, 18 + 85) = Beta(17, 103)

The mean of the posterior distribution is 17 ÷ (17 + 103) ≈ 0.142.

In other words, the purchase conversion rate estimated by the posterior mean is about 14.2%.

ItemConversion rate
Prior mean10.0%
Observed proportion15.0%
Posterior meanAbout 14.2%
0%10%20%30%40%Observed 15/100Prior Beta(2, 18)mean 10%Posterior Beta(17, 103)Mean 14.2%Purchase conversion rate
Prior and posterior distributions

How do we interpret the results?

We originally expected a purchase conversion rate of about 10%, but the actual data showed a conversion rate of 15%. Bayesian analysis updated the estimate of the conversion rate by combining the prior distribution with the observed data. As a result, the posterior mean came out to about 14.2%.

It is slightly lower than the observed 15% because the prior information that the conversion rate would be around 10% was also reflected in the estimate. This result alone does not let us conclude that the new product page is more effective than the existing page. Separate information about the existing page's conversion rate and its uncertainty is needed.

Also, the posterior mean is just one summary value. In real Bayesian analysis, it is important to use the whole posterior distribution to examine the uncertainty of the estimate as well.

SECTION 4

What is a credible interval in Bayesian analysis?

One of the measures often used in Bayesian analysis is the credible interval.

A credible interval uses the posterior distribution to express the probability that a parameter lies within a certain interval. For example, suppose the 95% credible interval for the average effect of a training program is [2.1, 7.8].

2.17.895%0−204681012Average effect
95% credible interval

This means that, given the chosen model, the prior distribution, and the observed data, the posterior probability that the training program's average effect lies between 2.1 and 7.8 is 95%. This should be distinguished from the confidence interval used in frequentist statistics.

ItemBayesian credible intervalFrequentist confidence interval
English termCredible IntervalConfidence Interval
Basis of calculationPosterior distributionSampling distribution and estimation procedure
Meaning of 95%95% posterior probability that the parameter is in the intervalIf the same procedure is repeated, about 95% of the intervals produced contain the true parameter
Prior distributionGenerally incorporatedNot used in typical confidence interval calculations

The two intervals may be expressed as similar-looking numbers, but their statistical meanings differ. In particular, calculating a frequentist 95% confidence interval and then saying there is a 95% probability that the true parameter lies in that interval is not a strict frequentist interpretation.

SECTION 5

How does Bayesian analysis differ from conventional statistical analysis?

Bayesian and frequentist statistics have in common that both make inferences from data, but they handle probability and parameters differently.

ItemFrequentist statisticsBayesian statistics
View of parametersA fixed but unknown valueUncertainty expressed as a probability distribution
Existing informationTypical tests do not use an explicit prior distributionCan be incorporated as a prior distribution
Main resultsEstimates, p-values, confidence intervalsPosterior distribution, posterior probabilities, credible intervals
Comparing hypothesesNull hypothesis tests, etc.Bayes factors, posterior model probabilities, etc.
Interpreting resultsInterpreted in terms of sampling and the test procedureProbabilities interpreted conditional on the model and data

For example, suppose you analyze whether a new training program is more effective than the existing one. A frequentist t-test usually sets up the null hypothesis that the two population means are equal and assesses how extreme the observed difference is under the null hypothesis.

A Bayesian analysis, on the other hand, can set up an appropriate model and prior distribution and calculate, for example, the posterior probability that the new program's average effect is greater than 0. However, the two approaches cannot be distinguished simply by which one is more accurate.

The appropriate approach depends on the purpose of the study, the characteristics of the data, the reliability of the prior information, and how you want to interpret the results.

SECTION 6

How do p-values and Bayes factors differ?

A measure often used in Bayesian hypothesis testing is the Bayes factor.

The Bayes factor compares the relative evidence the observed data provide for two different hypotheses or models. For example, suppose we set up the following hypotheses about the difference in means between two groups.

The Bayes factor BF₁₀ is the ratio comparing how plausible the data are under H₁ with how plausible they are under H₀. It uses the marginal likelihood of each hypothesis and is affected by the prior distribution set for H₁.

BF₁₀Interpretation
1Evidence for the two hypotheses is equal
3Data are 3 times more plausible under H₁ than under H₀
10Data are 10 times more plausible under H₁ than under H₀
0.2Data are 5 times more plausible under H₀ than under H₁
1← H₀H₁ →BF₁₀ = 0.25× toward H₀BF₁₀ = 33× toward H₁BF₁₀ = 1010× toward H₁
Bayes factor scale

A Bayes factor of 10 does not mean the probability that H₁ is true is 90.9%. To calculate the posterior probability of a hypothesis, you need not only the Bayes factor but also the prior probability of each hypothesis.

How is it different from a p-value?

The p-value is the probability, given that the null hypothesis is true, of getting a result as extreme as or more extreme than the observed test statistic. The Bayes factor, on the other hand, compares how well two hypotheses explain the data relative to each other.

In particular, depending on the situation, the Bayes factor can show not only evidence supporting the alternative hypothesis but also evidence that relatively supports the null hypothesis. However, the Bayes factor is also affected by the chosen model and prior distribution, so you should not draw conclusions from a single number alone.

SECTION 7

What is the Bayesian t-test?

The Bayesian t-test analyzes the difference between two means, or the difference from a specific reference value, in a Bayesian way.

Like the ordinary t-test, it comes in several types depending on the study design.

MethodMain purpose
Bayesian one-sample t-testComparing one group's mean with a reference value
Bayesian independent-samples t-testAnalyzing the difference in means between two independent groups
Bayesian paired-samples t-testAnalyzing the difference between two paired measurements

For example, suppose we compare the test scores of 50 students taught with the existing study method and 50 students taught with a new study method. An ordinary t-test uses the t-value and p-value to judge whether the difference in means is statistically significant.

A Bayesian t-test can estimate the posterior distribution of the mean difference or the standardized effect size, or express the relative evidence for two hypotheses as a Bayes factor.

Example Bayesian t-test results

MeasureResult
Posterior mean of the mean difference5.8 points
95% credible interval[1.4, 10.2]
Posterior probability that the mean difference is greater than 099.5%
BF₁₀8.4

Actual results depend on the data and the prior distribution.

This result can be interpreted as follows: given the chosen model, the posterior probability that the group taught with the new study method has a higher mean score is 99.5%. Also, BF₁₀ = 8.4 means the data are about 8.4 times more plausible under the specified alternative hypothesis than under the hypothesis of no mean difference.

However, the posterior probability that the mean difference is positive and the Bayes factor answer different questions, so they should be interpreted separately.

SECTION 8

What is Bayesian ANOVA?

Bayesian ANOVA analyzes the effects of several groups or experimental factors in a Bayesian way.

Whereas ordinary analysis of variance (ANOVA) tests differences in group means using the F statistic and p-value, Bayesian ANOVA can compare several models or estimate posterior distributions for factor effects. For example, suppose we analyze the effect of three study methods on test scores.

Bayesian ANOVA can compare a model with no group effect and a model that includes a group effect.

Example model comparison

ModelDescriptionBF₁₀
H₀The three groups have equal population means1.0
H₁A group effect exists depending on study method12.5

If BF₁₀ is 12.5, the observed data are 12.5 times more plausible under the model that includes the group effect than under the model without it. However, this result alone does not tell you which group's mean is highest or which groups differ.

To identify specific differences between groups, you need to run post hoc comparisons or analyze the posterior distributions of the differences in group means.

What if there are several factors?

Bayesian ANOVA can also be used in studies with several factors, as in two-way ANOVA. For example, when analyzing how study method and class format affect test scores, you can consider the following effects.

You can then compare the relative evidence for several models or estimate the posterior distribution of each effect.

SECTION 9

What are the advantages of Bayesian analysis?

Depending on the purpose of the study, Bayesian analysis can offer several advantages.

It can incorporate existing information into the analysis.

Information from previous studies or past data can be expressed as a prior distribution. For example, if earlier studies have repeatedly found a similar effect, that information can be reflected in the analysis of a new study. However, if the existing information is inaccurate or does not fit the current study, it can adversely affect the results.

It can express results as probabilities.

You can calculate the posterior probability that the parameter of interest meets a particular condition. For example, you can calculate the probability that the new program's average effect is greater than 0, or the probability that it exceeds the smallest effect that matters in practice. These results can be used not only for statistical inference but also for decision-making.

It can express uncertainty as a distribution.

In Bayesian analysis, you can look at the posterior distribution rather than just a single estimate. This lets you see which values are relatively plausible and how much uncertainty there is in the estimate.

It can be extended to complex models.

The Bayesian approach can be applied to many kinds of statistical models, such as hierarchical models, repeated measures, handling of missing data, and time series analysis. In particular, when information for each group is limited, you can build a model that uses a hierarchical structure to partially share information.

SECTION 10

Limitations and cautions of Bayesian analysis

Bayesian analysis is a useful method, but it is not more appropriate than conventional statistical analysis in every situation.

Results can depend on the prior distribution.

The prior distribution plays an important role in Bayesian analysis. Especially when there are few data, the prior can have a substantial influence on the posterior. So it is good to explain clearly why you chose the prior and, if needed, to run a sensitivity analysis with different priors.

Computation can be complex.

For simple models, the posterior distribution can be calculated directly by mathematics. But complex models may require computational methods such as Markov chain Monte Carlo (MCMC). These methods can take a long time to compute, and you need to check whether the estimates have converged stably enough.

You need to check whether the model is appropriate.

In Bayesian analysis, too, using the wrong statistical model can lead to wrong conclusions. For example, if the assumptions about the distribution of the data or the independence of observations are not appropriate, the posterior distribution may not be trustworthy either.

So it is important to check how well the model explains the actual data, for example through posterior predictive checks.

Do not automatically interpret posterior probabilities as objective facts.

The probabilities calculated in Bayesian analysis are premised on the chosen model, the prior distribution, and the observed data. So a high posterior probability that a certain effect exists does not establish that the effect definitely exists in reality. The data collection process, study design, and appropriateness of the model must be considered together.

Do not draw conclusions from the size of the Bayes factor alone.

A large Bayes factor does not mean the hypothesis is absolutely true. The result can vary with how the compared hypotheses were set up and with the prior distribution, so you need to understand accurately what the relative evidence means.

SECTION 11

Where can Bayesian analysis be used?

Bayesian analysis is used in many fields to estimate uncertainty and incorporate new information.

Education research

You can estimate the effect of an educational program or bring earlier study results into a new analysis of learning effects.

Marketing and business

In A/B tests, you can calculate the probability that one product or ad has the higher conversion rate, or update information about customer behavior.

Health and medical research

You can estimate uncertainty about treatment effects or risks, and bring information from earlier studies into a new clinical study.

Social science research

You can analyze differences between groups, relationships between variables, hierarchical data structures, and more with Bayesian models.

Finance and economics

You can analyze uncertainty in parameters related to risk estimation, forecasting economic indicators, and investment returns.

Quality control and manufacturing

You can estimate product defect rates or the performance of a production process, and update existing estimates as new inspection results come in. In this way, Bayesian analysis is useful when you want to use existing information together with newly collected data, or interpret results in terms of probability.

SECTION 12

How do you report Bayesian analysis results?

When reporting Bayesian results, it is better to explain the analysis model, the prior distribution, the posterior estimates, and so on together, rather than presenting only a probability or a Bayes factor.

For example, if you analyzed the difference in means between two study methods with a Bayesian t-test, you could report it as follows.

Example report

The difference in mean test scores between the two study methods was analyzed with a Bayesian t-test. The posterior mean of the difference in means between the group using the new study method and the group using the existing study method was 5.8 points, with a 95% credible interval of [1.4, 10.2]. Under the specified model and prior distribution, the posterior probability that the new study method had a higher mean score was 99.5%. The hypothesis comparison gave a BF₁₀ of 8.4.

In a real study, you should also report which prior distribution was used, how the posterior distribution was calculated, and whether the model diagnostics were satisfactory. In particular, if you used MCMC, it is good to present information that shows the reliability of the computation, such as convergence diagnostics and effective sample sizes.

✓Wrap-up

Bayesian analysis is a way to update estimates with new information.

Bayesian analysis is a statistical method that combines existing information with newly observed data to express uncertainty about the parameters or hypotheses of interest in terms of probability.


It works through the prior distribution, likelihood, and posterior distribution, and depending on the purpose of the study it can use posterior probabilities, credible intervals, Bayes factors, and more. Typical examples are the Bayesian t-test and Bayesian ANOVA, which can be used to analyze differences in means between groups or compare the effects of several factors.

However, Bayesian analysis is not a method that automatically replaces conventional statistical analysis. It should be chosen with the purpose of the study, the characteristics of the data, the reliability of the prior information, and the appropriateness of the statistical model in mind.

KEY TAKEAWAY

The key to Bayesian analysis is not to blindly trust existing information, but to update uncertainty with new data and understand the results in terms of probability.