MerQuR+Statistics Glossary

Statistics Glossary → Bayesian Correlation

Bayesian Correlationanalysis

An analysis that uses a Bayes factor to assess whether the relationship between two variables differs from zero, and the posterior distribution of the correlation coefficient to show how strong it is.

Concept

The classical correlation test says whether we can reject the 'no relationship' hypothesis; a non-significant correlation does not prove that there is no relationship. Bayesian correlation compares 'ρ = 0' (H₀) and 'ρ ≠ 0' (H₁) directly and shows with a Bayes factor (BF₁₀) how strongly the data support each. Evidence can therefore be measured both for a relationship and for its absence.

Under H₁ the correlation coefficient ρ is given a prior distribution between -1 and 1; the common choice is a 'stretched beta' prior whose width is set by κ (κ = 1 gives all values equal probability). Combining the data with this prior gives the posterior distribution of ρ; its median and credible interval give direct probability statements about how strong the relationship is. The posterior median is usually slightly closer to zero than the sample r, because the prior pulls the estimate gently towards zero.

Pearson correlation measures linear association and assumes bivariate normality; the rank-based Spearman and Kendall coefficients measure monotonic association and are less sensitive to outliers. Correlation does not show causation and does not remove the influence of a third variable. Because the Bayes factor is sensitive to the width of the prior, sensitivity results for different κ values should be reported alongside.

When to use it

  • When the strength of evidence for an association between two continuous or ordinal variables is asked for, especially when support for 'no relationship' is also needed.
  • If the relationship is linear and the data roughly normal, choose Pearson; if it is monotonic but not linear, the data are ordinal or there are outliers, choose Spearman or Kendall.
  • To study a relationship while holding one or more other variables fixed, use partial correlation or regression; to predict from several variables at once, use Bayesian linear regression.

An everyday example

A high-school guidance office wonders whether 30 students' average nightly sleep during exam week is related to their mock-exam score. The correlation is r = 0.45. If Bayesian correlation gives BF₁₀ = 6, the data support the relationship hypothesis 6 times more than 'no relationship'; if the 95% credible interval for ρ is, say, [0.10, 0.67], the relationship is very probably positive but its strength is still uncertain.

Parameters in MerQur

Variable 1 (X), Variable 2 (Y)

Concept: Correlation is symmetric: which variable is X and which is Y does not change the coefficient. An observation with a missing value is dropped only from the calculation for that pair.

Everyday example: Whether sleep is X and the mock-exam score Y or the other way round, r = 0.45. A student whose score is missing is left out for this pair.

What it does: Variable selection; missing values are dropped pairwise. An error is raised if the same variable is selected.

Effect on the result: All outputs depend on the selected pair.

On the validation data: iris Sepal_Length ~ Sepal_Width (n = 150, r = -0.118; weak, evidence in favor of H0) and attitude rating ~ complaints (n = 30, r = 0.825; strong association).

Correlation type (Pearson / Spearman / Kendall)

Concept: The Pearson coefficient measures the strength of linear association; Spearman and Kendall use the ranks instead of the values themselves and answer 'does one go up as the other does?' even when the relationship is not linear.

Everyday example: If scores rise quickly as sleep goes from 5 to 7 hours and then level off, the relationship is not linear; Spearman reflects this monotonic pattern better than Pearson. A single student reporting 12 hours of sleep also affects Spearman and Kendall less than Pearson.

What it does: Pearson linear, Spearman rank, Kendall τ-b correlation. The Pearson BF uses the exact likelihood of Ly, Verhagen and Wagenmakers (2016) and the stretched beta prior; for Kendall, van Doorn et al. (2018); for Spearman the Pearson formula is applied to the ranks.

Effect on the result: The coefficient, the frequentist p and CI (Pearson Fisher-z, Spearman Bonett-Wright, Kendall Fieller), the BF and the posterior model change.

On the validation data: iris BF10: Pearson 0.2823, Spearman 0.8016 (r_s = -0.167, p = 0.041), Kendall 0.2817 (τ = -0.077). attitude BF10: 720 317, 1 151 162 and 54 129.

→ Pearson correlation coefficient

Prior width κ (stretched beta)

Concept: κ is the width of the prior for ρ under H₁. κ = 1 treats every correlation value as equally likely; as κ gets smaller, the prior puts more weight on small correlations near zero.

Everyday example: If the guidance teacher expects at most a moderate link between sleep and score, a narrower prior (e.g. κ = 1/3) can be chosen. Because the Bayes factor changes with κ, showing the result for several κ values reveals how much the evidence depends on the prior.

What it does: A beta(1/κ, 1/κ) prior stretched to the interval ρ ~ (-1, 1). κ = 1 is the uniform prior; as κ decreases, the prior concentrates at zero. The named scales correspond to medium 1/3, wide 1/√3, ultrawide 1.

Effect on the result: BF10 and the posterior change; the frequentist output does not change.

On the validation data: iris BF10: 0.5093 for κ = 0.333, 0.4152 for 0.5, 0.2823 for 1, 0.1816 for 2. attitude: 199 888.9 for κ = 1/3, 476 369.5 for 1/√3, 720 316.9 for 1.

→ Prior distribution

Alt. hypothesis (Two-sided / positive / negative)

Concept: Sets the direction of H₁: two-sided ρ ≠ 0, while the directional options test only a positive or only a negative relationship. The direction should be chosen from theory, before looking at the data.

Everyday example: If there is no plausible reason for more sleep to lower scores, 'positive' can be chosen. If the data really show a positive relationship, BF₊₀ comes out larger than the two-sided BF₁₀.

What it does: BF+0 (ρ > 0) or BF-0 (ρ < 0) for a directional H1; the posterior is truncated.

Effect on the result: Directional BFs, their truncated posterior summaries and the one-sided p.

On the validation data: iris (r < 0): BF-0 = 0.521, BF+0 = 0.0437. attitude: BF+0 = 1.441e6, BF-0 = 0.0417. The one-sided p is also reported.

→ One-sided and two-sided tests (hypothesis direction)

Confidence Level (%90 / %95 / %99 / Other, custom value)

Concept: Sets the level of the frequentist confidence interval and of the credible interval for ρ (and of the HDI, the narrowest credible interval). A credible interval says that, given the data, ρ lies in the interval with the stated probability.

Everyday example: If the 95% credible interval is [0.10, 0.67], the true correlation between sleep and score lies in this range with 95% probability. With 300 students instead of 30, the interval would be much narrower.

What it does: The level of the frequentist confidence interval, the credible interval and the HDI.

Effect on the result: Interval limits only; the BF does not change. While the custom box is off, a value entered has no effect.

On the validation data: iris Pearson CI: 90% [-0.2485, 0.0175], 95% [-0.2727, 0.0435], 99% [-0.3190, 0.0941]; 95% credible interval [-0.2695, 0.0439].

→ Confidence level and confidence interval

Additional output: Scatter plot; Correlation matrix (extra variables)

Concept: The scatter plot lets you see the form of the relationship and any outliers; the correlation matrix gives the coefficient and Bayes factor for every pair of chosen variables together.

Everyday example: If the points form a straight band, Pearson is appropriate; if one student sits far from everyone else, consider how much the result depends on that student. Adding screen time and breakfast habits to the matrix lets the evidence for all six pairs be compared in one table.

What it does: The scatter plot adds only graph data. The matrix gives n, r, p, BF10, the BF for the selected H1, the posterior median and the credible interval for all pairs with the selected extra variables.

Effect on the result: The scatter plot does not change the numerical result. The matrix does not affect the main pair; it produces additional rows.

On the validation data: iris 4 variables (6 pairs) and attitude 4 variables (6 pairs): BF10, the coefficient and the intervals are given for every pair; the one-sided with Kendall and the 90% with κ = 0.5 combinations are also computed.

→ Scatter plot

Example on real data

Data: Chatterjee and Price 1977 attitude, R datasets

Variables: variable 1 rating (overall rating), variable 2 complaints (handling of complaints)

  • Question: In 30 organizational units, is there a linear relationship between employees' overall rating of the supervisor (rating) and the supervisor's handling of complaints (complaints), and how strong is it?
  • Assumption: The Pearson correlation assumes bivariate normality and linearity; since n = 30 is small, this should be checked with a scatter plot.
  • Result: r = 0.825, frequentist 95% CI [0.662, 0.914], p < .001. BF₁₀ = 720 316.9: the data support the association hypothesis about 720 thousand times more than the null hypothesis (very strong / decisive evidence).
  • Posterior (effect size): ρ posterior median = 0.80, 95% credible interval [0.62, 0.90]; the association is large and positive. The posterior median is smaller than the sample r because the uniform prior pulls ρ slightly toward 0.
  • Sensitivity: The BF decreases as the prior narrows (κ = 1/3: 199 888.9; κ = 1/√3: 476 369.5), but the evidence is decisive under all options; for the directional H₊, BF₊₀ = 1.44e+06.
  • APA: Bayesian Pearson correlation (uniform prior, κ = 1): r = .83, BF₁₀ = 7.20e+05, ρ median = .80, 95% CrI [.62, .90], n = 30.

Related concepts

Scatter plotBayes factor (BF₁₀)Posterior distribution and posterior predictive checkPrior distributionPearson correlation coefficientSpearman rank correlationOne-sided and two-sided tests (hypothesis direction)Credible interval and highest density interval (HDI)

The numbers in the examples are MerQur's output on independent, publicly available validation data; see the MerQur Technical Note for details.