pingouin.bayesfactor_ttest

pingouin.
bayesfactor_ttest
(t, nx, ny=None, paired=False, tail='twosided', r=0.707)[source] Bayes Factor of a Ttest.
 Parameters
 tfloat
Tvalue of the Ttest
 nxint
Sample size of first group
 nyint
Sample size of second group (only needed in case of an independent twosample Ttest)
 pairedboolean
Specify whether the two observations are related (i.e. repeated measures) or independent.
 tailstring
Specify whether the test is ‘onesided’ or ‘twosided’
Warning
Onesided Bayes Factor (BF) are simply obtained by doubling the twosided BF, which is not exactly the same behavior as R or JASP. Be extra careful when interpretating onesided BF, and if you can, always doublecheck your results.
 rfloat
Cauchy scale factor. Smaller values of
r
(e.g. 0.5), may be appropriate when small effect sizes are expected a priori; larger values ofr
are appropriate when large effect sizes are expected (Rouder et al 2009). The default is \(\sqrt{2} / 2 \approx 0.707\).
 Returns
 bfstr
Scaled JeffreyZellnerSiow (JZS) Bayes Factor (BF10). The Bayes Factor quantifies the evidence in favour of the alternative hypothesis.
See also
ttest
Ttest
pairwise_ttest
Pairwise Ttests
bayesfactor_pearson
Bayes Factor of a correlation
bayesfactor_binom
Bayes Factor of a binomial test
Notes
Adapted from a Matlab code found at https://github.com/anneurai/Tools/tree/master/stats/BayesFactors
If you would like to compute the Bayes Factor directly from the raw data instead of from the Tvalue, use the
pingouin.ttest()
function.The JZS Bayes Factor is approximated using the formula described in ref [1]:
\[\text{BF}_{10} = \frac{\int_{0}^{\infty}(1 + Ngr^2)^{1/2} (1 + \frac{t^2}{v(1 + Ngr^2)})^{(v+1) / 2}(2\pi)^{1/2}g^ {3/2}e^{1/2g}}{(1 + \frac{t^2}{v})^{(v+1) / 2}}\]where \(t\) is the Tvalue, \(v\) the degrees of freedom, \(N\) the sample size, \(r\) the Cauchy scale factor (= prior on effect size) and \(g\) is is an auxiliary variable that is integrated out numerically.
Results have been validated against JASP and the BayesFactor R package.
References
 1(1,2)
Rouder, J.N., Speckman, P.L., Sun, D., Morey, R.D., Iverson, G., 2009. Bayesian t tests for accepting and rejecting the null hypothesis. Psychon. Bull. Rev. 16, 225–237. https://doi.org/10.3758/PBR.16.2.225
Examples
Bayes Factor of an independent twosample Ttest
>>> from pingouin import bayesfactor_ttest >>> bf = bayesfactor_ttest(3.5, 20, 20) >>> print("Bayes Factor: %s (twosample independent)" % bf) Bayes Factor: 26.743 (twosample independent)
Bayes Factor of a paired twosample Ttest
>>> bf = bayesfactor_ttest(3.5, 20, 20, paired=True) >>> print("Bayes Factor: %s (twosample paired)" % bf) Bayes Factor: 17.185 (twosample paired)
Bayes Factor of an onesided onesample Ttest
>>> bf = bayesfactor_ttest(3.5, 20, tail='onesided') >>> print("Bayes Factor: %s (onesample)" % bf) Bayes Factor: 34.369 (onesample)