Chapter 6 Bayesian Approaches

With the many and varied styles of Bayesian Analysis, it is difficult to find succinct advice on the relative merits of the various approaches. But the availability of BayesFactor-based algorithms and their ease of use has made them a go-to approach. This section will not attempt to provide a thorough overview of implementation of Bayesian inference for the repeated measure design. Instead, it will demonstrate the utility of the BayesFactor package. Those interested in Bayesian inference should consult the work of John Kruschke to see alternative approaches.

6.1 Bayes Factor analysis

The approach used in the BayesFactor package is somewhat analogous to the way we specified LMM models. The anovaBF function simply requires specification of a standard model, including the case variable. The key is the specification of that case variable (snum) as a random factor with the “whichRandom” argument. The default prior for the effect with BayesFactor functions is Cauchy with a scale parameter \(r={}^{\sqrt{2}}/{}_{2}\).

Note that the anovaBF function uses the long-format data frame that was initially introduced in chapter 2. The large BF (555.149) indicates substantial evidence in support of the alternative hypothesis relative to a model that excludes the “type” factor.

mod1.bf = anovaBF(DV ~type + snum, data = rpt1.df, 
             whichRandom="snum")
mod1.bf
## Bayes factor analysis
## --------------
## [1] type + snum : 551.9204 ±0.36%
## 
## Against denominator:
##   DV ~ snum 
## ---
## Bayes factor type: BFlinearModel, JZS

In this simple model there is only one model comparison of interest, the full model with “type” vs an intercept only model. That is the comparison reported by the code above, so no further model comparison strategies are required.

The first of two remaining issues could be addressed in future revisions of this chapter. That first issue is the logic for choice of priors in repeated measures designs - we have used the commonly employed default method in anovaBF. The second is a return to the question of how to do contrast analysis or post hoc pairwise tests. An indirect way of doing contrasts from a Bayesian perspective is addressed next.

6.2 Contrasts with BayesFactor methods?

One way of approaching contrasts with the BF method is to return to the manually created contrast variables initially examined in chapter 3. I will repeat the creation of those objects here using the wide format data frame.

rpt1w.df <- mutate(rpt1w.df, 
            ac1=(4*clean+(-1)*homecage+(-1)*iguana+(-1)*whiptail+(-1)*krat))
rpt1w.df <- mutate(rpt1w.df, 
            ac2=(0*clean+(3)*homecage+(-1)*iguana+(-1)*whiptail+(-1)*krat))
rpt1w.df <- mutate(rpt1w.df, 
            ac3=(0*clean+(0)*homecage+(-1)*iguana+(-1)*whiptail+(2)*krat))
rpt1w.df <- mutate(rpt1w.df, 
            ac4=(0*clean+(0)*homecage+(-1)*iguana+(1)*whiptail+(0)*krat))
gt(rpt1w.df)
snum clean homecage iguana whiptail krat ac1 ac2 ac3 ac4
1 24 15 41 30 50 -40 -76 29 -11
2 6 6 0 6 13 -1 -1 20 6
3 4 0 5 4 9 -2 -18 9 -1
4 11 9 10 14 18 -7 -15 12 4
5 0 0 0 0 0 0 0 0 0
6 8 15 10 15 38 -46 -18 51 5
7 8 5 2 6 15 4 -8 22 4
8 0 0 0 11 54 -65 -65 97 11
9 0 3 1 1 11 -16 -4 20 0
10 7 7 4 7 23 -13 -13 35 3

Originally we did four separate one-sample t-tests (null was that each linear combination contrast had a mean of zero). We can do that again, but using BF methods for the 1-sample t-test analog. I illustrate here by examining the third contrast which compares the kangaroo rat condition to the average of the two lizard conditions. The alternative hypothesis that the effect size is not zero is favored moderately.

ttestBF(rpt1w.df$ac3, mu=0)
## Bayes factor analysis
## --------------
## [1] Alt., r=0.707 : 7.261164 ±0%
## 
## Against denominator:
##   Null, mu = 0 
## ---
## Bayes factor type: BFoneSample, JZS