Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

BayesFactor anovaBF syntax

I would like to get Bayes factors for ANOVAs that are analogous to the classical F-tests, and I just want to make sure I understand correctly how to write the syntax, especially regarding subject IDs.

For example, I have between-subject independent variables a_between and b_between, and within-subject variables c_within and d_within, dependent variable values, with subject_id to identify each subject; in a dataset my_data.

If I understand correctly, for a full ANOVA, I should use:

anovaBF(values~a_between*b_between*c_within*d_within+subject_id, data = my_data, whichModels="bottom", whichRandom="subject_id") # and I assume the order of variables does not matter, e.g. it could also be d_within*a_between*c_within*b_between+subject_id

For only within-subjects ANOVA, I should use:

anovaBF(values~c_within*d_within+subject_id, data = my_data, whichModels="bottom", whichRandom="subject_id")

For only between-subjects ANOVA, I should use:

anovaBF(values~a_between*b_between, data = my_data, whichModels="bottom", whichRandom="subject_id")

So in the last case I have no +subject_id - otherwise I get Error in base::try(expression, silent = silent) : not enough observations. (Perhaps because there is only a single line per subject_id?)

Two main questions: 

 1. Regardless of reasons, are the solutions above corrects?

 2. If the solutions are correct, why do I have to specify subject ID twice (once as whichRandom and once in the beginning as +subject_id) for within-subject variables, and why not when there are only between-subject variables?

Sign In or Register to comment.