ttestBF(x = NULL, y = NULL, formula = NULL, mu = 0,
nullInterval = NULL, paired = FALSE, data = NULL, rscale = "medium",
posterior = FALSE, callback = function(...) as.integer(0), ...)
TRUE
, observations are pairedformula
, a data frame containing all the
dataTRUE
, return samples from the posterior instead
of Bayes factorposterior
is FALSE
, an object of class
BFBayesFactor
containing the computed model comparisons is
returned. If nullInterval
is defined, then two Bayes factors will
be computed: The Bayes factor for the interval against the null hypothesis
that the standardized effect is 0, and the corresponding Bayes factor for
the compliment of the interval. If posterior
is TRUE
, an object of class BFmcmc
,
containing MCMC samples from the posterior is returned.
ttestBF
tests the null hypothesis that
the mean (or mean difference) of a normal population is $\mu_0$
(argument mu
). Specifically, the Bayes factor compares two
hypotheses: that the standardized effect size is 0, or that the standardized
effect size is not 0. For one-sample tests, the standardized effect size is
$(\mu-\mu_0)/\sigma$; for two sample tests, the
standardized effect size is $(\mu_2-\mu_1)/\sigma$.A noninformative Jeffreys prior is placed on the variance of the normal
population, while a Cauchy prior is placed on the standardized effect size.
The rscale
argument controls the scale of the prior distribution,
with rscale=1
yielding a standard Cauchy prior. See the references
below for more details.
For the rscale
argument, several named values are recognized:
"medium", "wide", and "ultrawide". These correspond
to $r$ scale values of $\sqrt{2}/2$, 1, and $\sqrt{2}$
respectively.
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
Perception and Cognition Lab (University of Missouri): Bayes factor
calculators.
integrate
, t.test
## Sleep data from t test example
data(sleep)
plot(extra ~ group, data = sleep)
## paired t test
ttestBF(x = sleep$extra[sleep$group==1], y = sleep$extra[sleep$group==2], paired=TRUE)
## Sample from the corresponding posterior distribution
samples = ttestBF(x = sleep$extra[sleep$group==1],
y = sleep$extra[sleep$group==2], paired=TRUE,
posterior = TRUE, iterations = 1000)
plot(samples[,"mu"])
Run the code above in your browser using DataLab