Use t statistic to compute Bayes factor for one- and two- sample designs
Using the classical t test statistic for a one- or two-sample design, this function computes the corresponding Bayes factor test.
classical t statistic
size of first group (or only group, for one-sample tests)
size of second group, for independent-groups tests
optional vector of length 2 containing lower and upper bounds of an interval hypothesis to test, in standardized units
numeric prior scale
This function can be used to compute the Bayes factor corresponding to a
one-sample, a paired-sample, or an independent-groups t test, using the
classical t statistic. It can be used when you don't have access to the
full data set for analysis by
ttestBF, but you do have the
For details about the model, see the help for
ttestBF, and the
The Bayes factor is computed via Gaussian quadrature.
TRUE, returns the Bayes factor (against the
FALSE, the function returns a
vector of length 3 containing the computed log(e) Bayes factor,
along with a proportional error estimate on the Bayes factor and the method used to compute it.
In version 0.9.9, the behaviour of this function has changed in order to produce more uniform results. In
version 0.9.8 and before, this function returned two Bayes factors when
NULL: the Bayes factor for the interval versus the null, and the Bayes factor for the complement of
the interval versus the null. Starting in version 0.9.9, in order to get the Bayes factor for the complement, it is required to
complement argument to
TRUE, and the function only returns one Bayes factor.
Morey, R. D. & Rouder, J. N. (2011). Bayes Factor Approaches for Testing Interval Null Hypotheses. Psychological Methods, 16, 406-419
Rouder, J. N., Speckman, P. L., Sun, D., Morey, R. D., & Iverson, G. (2009). Bayesian t-tests for accepting and rejecting the null hypothesis. Psychonomic Bulletin & Review, 16, 225-237
ttestBF for the intended interface to this function, using
the full data set.
1 2 3 4 5 6 7 8 9 10
## Classical example: Student's sleep data data(sleep) plot(extra ~ group, data = sleep) ## t.test() gives a t value of -4.0621 t.test(extra ~ group, data = sleep, paired=TRUE) ## Gives a Bayes factor of about 15 ## in favor of the alternative hypothesis result <- ttest.tstat(t = -4.0621, n1 = 10) exp(result[['bf']])
Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.