| p_to_bf | R Documentation |
Convert p-values to (pseudo) Bayes Factors. This transformation has been suggested by Aust, Pawel, and Wagenmakers (2026), but is based on a vast amount of assumptions. It might therefore be not reliable. Use at your own risks.
p_to_bf(x, ...)
## S3 method for class 'numeric'
p_to_bf(x, n_obs = NULL, log = FALSE, ...)
## Default S3 method:
p_to_bf(x, n_obs = NULL, log = FALSE, ...)
x |
A (frequentist) model object, or a (numeric) vector of p-values.
p-values must come from a two-tailed z- or t-test or from an F- or
a |
... |
Arguments passed to |
n_obs |
(Effective) number of observations. For mixed models this must
be supplied and generally corresponds to the number of clusters. Either
length 1, or same length as |
log |
Whether to return log Bayes Factors. Note: The |
A data frame with the p-values and pseudo-Bayes factors (against the null).
Aust, F., Pawel, S., & Wagenmakers, E.J. (2026). Extracting Bayesian Evidence from Frequentist p-Values. Preprint available on ArXiv: https://arxiv.org/abs/2607.12132
bic_to_bf() for approximate Bayes factors based on BICs.
# Compare to BIC-approximated and pseudo BF
# --------------------------------------------
m0 <- lm(mpg ~ 1, data = mtcars)
m1 <- lm(mpg ~ am, data = mtcars)
m2 <- lm(mpg ~ factor(cyl), data = mtcars)
# BIC-approximated BF, m1 against null model
bayesfactor_models(m1, denominator = m0)
# bic_to_bf(BIC(m1), denominator = BIC(m0)) # equivalent
# pseudo-BF based on p-values
p_to_bf(m1)[-1, ] # dropping intercept
# When using a p-value from an F/chisq-test with more than one degree of
# freedom, the pseudo-BF is not reliable:
bayesfactor_models(m2, denominator = m0)
p_to_bf(anova(m2), n_obs = nrow(mtcars))
# Mixed models
# ------------------
data("sleepstudy", package = "lme4")
mixed0 <- lmerTest::lmer(Reaction ~ 1 + (Days | Subject), data = sleepstudy)
mixed1 <- lmerTest::lmer(Reaction ~ Days + (Days | Subject), data = sleepstudy)
bayesfactor_models(mixed1, denominator = mixed0)
p_to_bf(
mixed1,
n_obs = nlevels(lme4::sleepstudy$Subject), # *effective* sample size here
method = "S" # make sure to get the correct p-values for the fixed effects
)[-1, ] # dropping intercept
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.