Last chance! 50% off unlimited learning
Sale ends in
Using the classical t test statistic for a one- or two-sample design, this function computes the corresponding Bayes factor test.
ttest.tstat(
t,
n1,
n2 = 0,
nullInterval = NULL,
rscale = "medium",
complement = FALSE,
simple = FALSE
)
If simple
is TRUE
, returns the Bayes factor (against the
null). If 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.
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
if TRUE
, compute the Bayes factor against the complement of the interval
if TRUE
, return only the Bayes factor
Richard D. Morey (richarddmorey@gmail.com) and Jeffrey N. Rouder (rouderj@missouri.edu)
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
test statistic.
For details about the model, see the help for ttestBF
, and the
references therein.
The Bayes factor is computed via Gaussian quadrature.
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
## Classical example: Student's sleep data
data(sleep)
plot(extra ~ group, data = sleep)
## t.test() gives a t value of -4.0621
t.test(sleep$extra[1:10], sleep$extra[11:20], 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']])
Run the code above in your browser using DataLab