bfcor: Bayesian Sequential Correlation Test

View source: R/bayestest.R

bfcorR Documentation

Bayesian Sequential Correlation Test

Description

Calculates sequential Bayes Factors for correlation between two continuous variables, showing how evidence evolves as data accumulates. Uses 'correlationBF' from the BayesFactor package.

Usage

bfcor(
  x,
  y,
  alternative = c("two.sided", "greater", "less"),
  prior.r = 0.1,
  nstart = 5,
  exact = TRUE
)

Arguments

x

A vector containing continuous data

y

A vector containing continuous data

alternative

Direction of alternative hypothesis: "two.sided", "greater", or "less"

prior.r

Scale parameter for the prior distribution (default: 0.1)

nstart

Minimum number of data points before first BF calculation (>= 2)

exact

Logical. If TRUE, calculates BF for all points; if FALSE, uses steps for efficiency

Value

A list of class "seqbf" containing:

  • r: Pearson correlation coefficient

  • p-value: from classical correlation test

  • BF: vector of sequential Bayes Factors

  • test type: "correlation"

  • prior: list with prior distribution details

  • sample size: total number of observations

  • alternative: chosen alternative hypothesis

Examples

x <- rnorm(100)
y <- x + rnorm(100, 0, 0.5)  # Correlated data
result <- bfcor(x, y, alternative = "greater")

mrzdcmps/changeofevidence documentation built on Feb. 27, 2025, 3:10 a.m.