R: Function for Bayesian analysis of correlations

correlationBF {BayesFactor} | R Documentation

## Function for Bayesian analysis of correlations

### Description

Bayes factors or posterior samples for correlations.

### Usage

    correlationBF(y, x, rscale = "medium", nullInterval = NULL,
      posterior = FALSE, callback = function(...) as.integer(0), ...)

### Arguments

`y` | first continuous variable
`x` | second continuous variable
`rscale` | prior scale. A number of preset values can be given as strings; see Details.
`nullInterval` | optional vector of length 2 containing lower and upper bounds of an interval hypothesis to test, in correlation units
`posterior` | if `TRUE`, return samples from the posterior instead of Bayes factor
`callback` | callback function for third-party interfaces
`...` | further arguments to be passed to or from methods.

### Details

The Bayes factor provided by `ttestBF` tests the null hypothesis that the true linear correlation rho between two samples (y and x) of size 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 kappa by Ly et al. 2015; we call it `rscale` for consistency with other BayesFactor functions).

For the `rscale` argument, several named values are recognized: "medium.narrow", "medium", "wide", and "ultrawide". These correspond to r scale values of 1/sqrt(27), 1/3, 1/sqrt(3) and 1, respectively.

The Bayes factor is computed via several different methods.

### Value

If `posterior` 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 probability is 0, and the corresponding Bayes factor for the complement of the interval.

If `posterior` is `TRUE`, an object of class `BFmcmc`, containing MCMC samples from the posterior is returned.

### Author(s)

Richard D. Morey (richarddmorey@gmail.com)

### References

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, http://dx.doi.org/10.1016/j.jmp.2015.06.004.

Jeffreys, H. (1961). Theory of probability, 3rd edn. Oxford, UK: Oxford University Press.

### See Also

`cor.test`

### Examples

    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"])

[Package BayesFactor version 0.9.12-4.2 Index]