BCompare groups · Guide test 312
Jeffreys Bayesian correlation test
Compares a zero correlation model with a prior distributed nonzero correlation model.
Do it in CodeSplash
In the app, set it up in Analyze with this method:
- Bayesian correlation (Jeffreys Bayes factor) — How much more likely are the data if two variables are correlated than if they are not?
In Bayesian correlation (Jeffreys Bayes factor), choose Prior width on ρ = Ultrawide (κ = 1, uniform).
Do it in CodeSplash Run this test on your own data, in Python or R.
Bench
Change the design, drag the data, move α. The statistic, its reference distribution and the verdict follow.
Bench · Jeffreys Bayesian correlation test
Stretched Beta(1/κ, 1/κ) on ρ: κ = 1 is uniform on (−1, 1) (ultrawide), 1/3 medium.
Your data
Simulated with a known ρIf H₀ were true
- The reference: how t varies across samples when H₀ is true.
- Your statistic, from the data above.
- The p-value: the area at least as extreme as yours (p = .546).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The evidence
BF₁₀ = 0.27: moderate evidence for H₀ (prior: stretched Beta(1, 1) on ρ). The ratio of the two dots at ρ = 0 is the Bayes factor (Savage–Dickey). Unlike p, the Bayes factor can favor H₀, and it moves with the prior's width.
The formula
With your numbers
- prior width: a stretched Beta(1/κ, 1/κ) on ρ; κ = 1 is uniform on (−1, 1)
- Gauss' hypergeometric function (Ly, Verhagen & Wagenmakers 2016)
The verdict
t(28) = 0.61, p = .546, BF₁₀ = 0.27
p > α = .050: compatible with H₀
Effect size: Bayes factor (H₁ over H₀) BF₁₀ = 0.270
The prior on ρ is part of the question: a wide prior spreads belief over large correlations and so favors H0 more readily for small ones.
- Statistic
- 0.611
- p-value
- 0.5463
Jeffreys Bayesian correlation test on 30 (x, y) pairs: t(28) = 0.61, p = .546, BF₁₀ = 0.27. The p-value is above α = .050, so the data are compatible with H₀.
Question and hypotheses
H0: population Pearson correlation ρ=0; H1: ρ follows a specified prior on (−1,1).
Assumptions
A specified likelihood and prior under each hypothesis; observations satisfy the chosen sampling model. Bayes factors measure relative predictive evidence and are not p values. Independent bivariate normal observations and compatible nuisance priors for means/scales.
Formula
Parameters and notation
m(D|ρ) is the bivariate-normal likelihood integrated over the stated common nuisance priors. a=1/rscale gives the shifted Beta(a,a) prior; rscale=1 is uniform, while BayesFactor’s medium setting is 1/3.
Structure of the method
Integrate the bivariate-normal likelihood over a specified prior on correlation and compatible nuisance means/scales, then compare with the marginal likelihood at zero correlation. The BayesFactor implementation uses a shifted symmetric beta prior parameterized by rscale, yielding a family of evidence calculations.
Estimated and nuisance parameters
Correlation and nuisance location/scale parameters are integrated model quantities. The sample Pearson correlation and n summarize relevant data information under the model. rscale controls the prior with shape a=1/rscale; rscale=1 gives a uniform correlation prior, whereas the package medium setting is narrower.
Settings and design choices
Prespecify prior width, zero or interval/directional hypothesis, model odds if posterior probabilities are desired and missing-data handling. A prior on correlation is not equivalent to placing an arbitrary normal prior on Fisher’s transformed correlation without the Jacobian and likelihood implications.
Fitting and adaptation
Fit/integrate the declared Bayesian model and inspect numerical accuracy. Compare a planned range of plausible prior widths to show robustness; choosing the most favorable width after analysis is not neutral tuning. For nonlinear, heavy-tailed or clustered relationships, specify a different model rather than claiming this test is distribution-free.
Sensitivity and robustness
Restricted range, influential points and nonnormality can strongly alter correlation evidence. A near-zero Pearson correlation does not imply independence, and support for zero under one prior is relative model evidence. Report sample size, scatterplot, posterior summaries where useful, Bayes-factor orientation and prior assumptions.
How to use and calibrate
Use the Jeffreys-based integrated correlation method, reporting prior width, direction restrictions and BF orientation.
Example application
Compare evidence for zero versus nonzero linear correlation.
Interpretation and pitfalls
Watch out
Uniform and narrower correlation priors give different evidence. Posterior probability of H0 additionally requires prior model odds.
What changed in edition 2
- New sections: structure of the method, estimated and nuisance parameters, settings and design choices, fitting and adaptation, sensitivity and robustness.
Python and R
Jeffreys correlation Bayes factor with rscale=1; state the prior and BF direction. Posterior probability requires prior model odds.
Not run — Executed end to end through Rscript · needs Python standard library + Rscript; R packages: BayesFactor
# Python launcher for the complete R implementation below.
# Requires Rscript on PATH and the listed R packages.
import shutil
import subprocess
rscript = shutil.which("Rscript")
if rscript is None:
raise RuntimeError("Install R and make Rscript available on PATH.")
r_code = r"""
x <- c(4.2,5.1,5.4,4.8,6.0,5.8,4.9,5.6,6.2,5.0)
y <- c(4.0,4.4,4.8,5.0,5.1,4.3,4.7,4.6,5.2,4.9)
print(BayesFactor::correlationBF(x,y,rscale=1))
"""
# No shell interpolation. A failed R execution raises an error in Python.
result = subprocess.run([rscript, "--vanilla", "-"], input=r_code,
text=True, capture_output=True)
print(result.stdout)
if result.stderr:
print(result.stderr)
result.check_returncode()
Validated — Executed successfully in the validation environment · needs BayesFactor
x <- c(4.2,5.1,5.4,4.8,6.0,5.8,4.9,5.6,6.2,5.0)
y <- c(4.0,4.4,4.8,5.0,5.1,4.3,4.7,4.6,5.2,4.9)
print(BayesFactor::correlationBF(x,y,rscale=1))
Output
Bayes factor analysis -------------- [1] Alt., r=1 : 1.209143 ±0% Against denominator: Null, rho = 0 --- Bayes factor type: BFcorrelation, Jeffreys-beta*
Sources
- BayesFactor — BayesFactor · correlationBFAuthor documentation/source reviewed: BayesFactor 0.9.12-4.8.search.r-project.org
- correlationBFsearch.r-project.org
- Statistics guide v4 (historical):
- Python: Executed end to end through Rscript · R: Executed successfully in the validation environment
- Reference's record:
- Edition 2 review: Python: skip · R: not executed (Rscript unavailable); why not run: Python: Python-to-R bridge; Rscript is unavailable. R code was not executed. Python: Not run in the reference's review: Python-to-R bridge; Rscript is unavailable. R code was not executed. R: Reviewed but not run: R wasn't available to the reference's authors.
From the CodeSplash statistics guide (v4), entry 312, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT312.