richarddmorey / BayesFactor

BayesFactor R package for Bayesian data analysis with common statistical models.
https://richarddmorey.github.io/BayesFactor/
132 stars 49 forks source link

generalTestBF() problem with particular analysis #46

Closed ghost closed 9 years ago

ghost commented 9 years ago

When I run:

library(BayesFactor) #version 0.9.9
dataset <- read.csv("ssgo-fred.csv")
dataset$response <- as.factor(dataset$response)
dataset$trialType <- as.factor(dataset$trialType)
dataset$target <- as.factor(dataset$target)
generalTestBF(rt ~ response + trialType:target, dataset)

It gives the error:

Error in apply(mb, 1, function(v) all(v[toKeep])) : 
  dim(X) must have a positive length

Same error occurs with:

generalTestBF(rt ~ target + trialType:target, dataset)
generalTestBF(rt ~ trialType + trialType:target, dataset)

These do work:

generalTestBF(rt ~ trialType:target, dataset)
generalTestBF(rt ~ response + trialType + trialType:target, dataset)
generalTestBF(rt ~ response + target + trialType:target, dataset) 
generalTestBF(rt ~ trialType + target + trialType:target, dataset)
generalTestBF(rt ~ response + trialType + target + trialType:target, dataset)

I emailed you the ssgo-fred.csv file earlier.

richarddmorey commented 9 years ago

This is due to those models being inconsistent with the "withMain" default model enumeration method. With main requires all constituent effects in an interaction to also be in model. Therefore, if "trialType:target" is in the model, then "trialType + target" must also be in the model. in the next version, I'll add an warning when this happens, and perhaps automatically change over to the "full" enumeration method.