BF_for_everyone {mmibain}R Documentation

Compute Bayes Factors for Each Participant and Summarize Results

Description

This function splits a dataset by participants, fits linear models for each participant, computes Bayes Factors (BFs) using the bain package, and summarizes the results.

Usage

BF_for_everyone(.df, .participant, formula, hypothesis)

Arguments

.df

A data frame containing the data.

.participant

A string specifying the name of the participant column in the data frame.

formula

A formula specifying the linear model to be fit.

hypothesis

A string specifying the hypotheses to be tested using the bain package.

Value

A list containing:

GPBF

A matrix of the geometric product, evidence rate, and stability rate for each hypothesis.

BFs

A matrix of the Bayes Factors for each participant and hypothesis.

BF_summary

A summary matrix of the mean, median, standard deviation, minimum, and maximum of the Bayes Factors for each hypothesis.

N

The number of participants.

bain_res

A list of bain results for each participant.

Plot

A ggplot2 object visualizing the distribution of Bayes Factors by hypothesis.

References

Klaassen, F. (2020). Combining Evidence Over Multiple Individual Analyses. In R. van de Schoot & M. Miočević (Eds.), Small Sample Size Solutions: A Guide for Applied Researchers and Practitioners (1st ed., pp. 13). Routledge. doi:10.4324/9780429273872-11

Examples

 # Create data
 cars2 <- cars
 cars2[["parts"]] <- rep(1:10, each = 5)

 # Run analysis
 res <- BF_for_everyone(.df = cars2, .participant = "parts",
                        formula = "dist ~ speed", hypothesis = "speed > 0")

 # View GPBF results
 res$GPBF


[Package mmibain version 0.2.0 Index]