Bayes factors or posterior samples for correlations.
correlationBF( y, x, rscale = "medium", nullInterval = NULL, posterior = FALSE, callback = function(...) as.integer(0), ... )
first continuous variable
second continuous variable
prior scale. A number of preset values can be given as strings; see Details.
optional vector of length 2 containing lower and upper bounds of an interval hypothesis to test, in correlation units
callback function for third-party interfaces
further arguments to be passed to or from methods.
The Bayes factor provided by
ttestBF tests the null hypothesis that
the true linear correlation
\rho between two samples (
n from normal populations is equal to 0. The Bayes factor is based on Jeffreys (1961)
test for linear correlation. Noninformative priors are assumed for the population means and
variances of the two population; a shifted, scaled beta(1/rscale,1/rscale) prior distribution
is assumed for
\rho (note that
rscale is called
Ly et al. 2015; we call it
rscale for consistency with other BayesFactor functions).
rscale argument, several named values are recognized:
"medium.narrow", "medium", "wide", and "ultrawide". These correspond
r scale values of
1/\sqrt(3) and 1, respectively.
The Bayes factor is computed via several different methods.
FALSE, an object of class
BFBayesFactor containing the computed model comparisons is
nullInterval is defined, then two Bayes factors will
be computed: The Bayes factor for the interval against the null hypothesis
that the probability is 0, and the corresponding Bayes factor for
the complement of the interval.
TRUE, an object of class
containing MCMC samples from the posterior is returned.
Richard D. Morey (email@example.com)
Ly, A., Verhagen, A. J. & Wagenmakers, E.-J. (2015). Harold Jeffreys's Default Bayes Factor Hypothesis Tests: Explanation, Extension, and Application in Psychology. Journal of Mathematical Psychology, Available online 28 August 2015, https://dx.doi.org/10.1016/j.jmp.2015.06.004.
Jeffreys, H. (1961). Theory of probability, 3rd edn. Oxford, UK: Oxford University Press.
bf = correlationBF(y = iris$Sepal.Length, x = iris$Sepal.Width) bf ## Sample from the corresponding posterior distribution samples = correlationBF(y = iris$Sepal.Length, x = iris$Sepal.Width, posterior = TRUE, iterations = 10000) plot(samples[,"rho"])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.