# Mixed bayesian ANOVA using BayesFactor package in R

According to a recent paper (open pdf here), one can specify both within- and between-subjects effects in a Bayes factor ANOVA. In the example they give (p. 28), this is specified in the following way:

bf = anovaBF(rt~a*d*p+s, data = dat, whichModels="withmain", whichRandom="s", iterations = 100000)

With: a = age , hence a between-subjects effect d = distanceand p = presentation as experimental manipulations and hence within-subjects effects. And s = subject

I just want to double check: is it not necessary at all to specify which effects are between- and which are within-subjects?

In Bayesian Linear Mixed models, there is no distinction between random effects and fixed effects. This is a terminology inherited from the classical framework (which is often useful to understand in order to communicate the results).

This is explained in Chapter 15 (page 383, footnote) of Gelman et al. book Bayesian data analysis.

• I see, thank you.In JASP one does have to specify this but it's probably the result of trying to keep the interface consistent with SPSS, or consistent with the classical anova setup. – elisa Aug 17 '16 at 9:07
• @elisa Indeed. This distinction may be helpful for recently converted Bayesians, and also, as I said, to communicate results with non-statisticians or non-Bayesians. – Caf Aug 17 '16 at 9:08

Hmmm. Lot's of issues here.

a. Within-subject vs. between subject is quite different than fixed-vs-random. Within subject is a design where ea. subject is exposed to all levels of the factor. Between subject is where ea. subject is exposed to only one level of the factor. This necessitates different modeling strategies which are largely orthogonal to the fixed-vs-random question.

b. The information inputed to the package, the design columns (or the design matrix), already code for whether a variable is within or between. Consequently, the user need not worry about it. I agree it does seem a bit magical at first, but if you think about it, you will see that the info is already there.

c. While off topic, I would never argue that fixed-vs-random is moot in Bayesian. They are the same in some cases and not the same in others. For example, take a 2-by-2 ANOVA design. If you dont include interactions, then I would argue whether you treat the factors as fixed or random is irrelevant. But when you include the interactions it matters greatly. See Rouder et al. (2012), JMP, http://pcl.missouri.edu/sites/default/files/Rouder.JMP_.2012.pdf