SCM

Forum: help

Monitor Forum | Start New Thread Start New Thread
RE: Factor vs dummy coding - different BFs [ Reply ]
By: Richard Morey on 2015-03-20 15:40
[forum:42072]
Hi Marcel,

No, it's not a bug; with dummy codes, the BayesFactor package does not know the factor structure and hence cannot apply the correct priors. A very important aspect of the BayesFactor priors is the hierarchical priors within factors that are independent between factors. (see Rouder et al 2012, section 12, Alternative g-priors, and Gelman 2005). If the factor structure is unknown, then the sizes of the effects of one factor cannot be differentiated from the sizes of the effects of another factor, and these will influence one another.

Dummy codes should not be used; always factor() should be used so that BayesFactor knows the factor structure.

Factor vs dummy coding - different BFs [ Reply ]
By: Marcel Falkiewicz on 2014-11-27 11:31
[forum:42069]
Hello,
I've tried fitting the same model to my data (a 2x2x2 design), but depending on whether I've used dummy coding or factors, I got different results:

model1 <- lmBF(logRT ~ rep*lie*Group + ID + Code,whichRandom = c("ID","Code"), data=data)
model2 <- lmBF(logRT ~ rep_fac*lie_fac*Group_fac + ID + Code,whichRandom = c("ID","Code"), data=data)

The first model codes the factors as 0/1, the second with R's own as.factor(x). What worries me is that both models get different Bayes Factors:

Bayes factor analysis
--------------
[1] rep * lie * Group + ID + Code : 7.752689 ±12.74%

Against denominator:
logRT ~ rep_fac * lie_fac * Group_fac + ID + Code

The dummy-coded 3-way interaction seems to be almost 8x more likely than the factor-coded 3-way interaction. I've ran the same analysis with lme4 and got exactly the same AIC and BIC values for both of above models.

Is this a bug?

Thanks to:
Vienna University of Economics and Business Powered By FusionForge