Skip to contents

Performs a Bayesian repeated-measures ANOVA using the generalTestBF(..., whichModels = "top") function from the BayesFactor package, assuming one subject column, multiple within-subject factor columns, and one dependent variable column.

Usage

rmANOVA_bf(
  x,
  rscaleFixed = "medium",
  rscaleRandom = "nuisance",
  rscaleCont = "medium",
  rscaleEffects = NULL,
  method = "auto",
  progress = TRUE,
  multicore = FALSE,
  summarize = TRUE,
  inc_ranef = FALSE,
  seed = NULL
)

Arguments

x

A data frame in long format. The first column should be the subject identifier. The last column should be the dependent variable, and the columns in between should be within-subject factors.

rscaleFixed

Prior scale for fixed effects. Default is "medium".

rscaleRandom

Prior scale for random effects. Default is "nuisance".

rscaleCont

Prior scale for continuous covariates. Default is "medium".

rscaleEffects

Optional vector of prior scales for individual effects.

method

Method for computing Bayes factors. See BayesFactor::generalTestBF(). Default is "auto".

progress

Logical. Whether to display progress bar. Default is TRUE.

multicore

Logical. Whether to use multicore processing. Default is FALSE.

summarize

Logical. Whether to output summarized results or not. Default is 'TRUE'.

inc_ranef

Logical. Whether to output results of random effects.

seed

Optional. A numeric seed to fix the random number generator state for reproducibility.

Value

A tibble summarizing Bayes factors for each model compared to the full model. Columns include:

effect

The effect excluded from the full model

BF

Bayes factor for the null (exclusion) over the alternative hypothesis

error

Estimated numerical error

log10_BF

Base-10 logarithm of the Bayes factor

favor

Indicates whether data favor the null or alternative hypothesis

evidence

Strength of evidence ("anecdotal", "moderate", "strong", "very strong", "extreme")

Details

The function currently supports designs with 2 or 3 within-subject factors only. The subject column is automatically renamed to "s", factor columns to "fw1", "fw2", etc., and the outcome variable to "y" internally for formula construction.

Examples

library(BayesFactor)
# Simulated data with subject, 2 factors, and outcome
set.seed(123)
dat <- data.frame(
  id = rep(1:30, each = 4),
  A = rep(c("low", "high"), times = 60),
  B = rep(c("left", "right"), each = 2, times = 30),
  y = rnorm(120)
)
res <- rmANOVA_bf(dat)
#> 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==========                                                            |  14%
  |                                                                            
  |====================                                                  |  29%
  |                                                                            
  |==============================                                        |  43%
  |                                                                            
  |========================================                              |  57%
  |                                                                            
  |==================================================                    |  71%
  |                                                                            
  |============================================================          |  86%
  |                                                                            
  |======================================================================| 100%
#> Error in str_detect(full_model_vars, "s"): could not find function "str_detect"
print(res)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'print': object 'res' not found