richarddmorey / BayesFactor

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

problems with model enumeration fallback #12

Closed richarddmorey closed 10 years ago

richarddmorey commented 10 years ago

The following code:

library(languageR)
library(BayesFactor)
data(primingHeidPrevRT)

primingHeidPrevRT$lRTmin1 <- log(primingHeidPrevRT$RTmin1)

replacementNames <- c(RT = "RT", Word = "W", Subject = "S", Condition = "trt", RTtoPrime = "rtP", ResponseToPrime = "rspP", lRTmin1 = "prvRt", BaseFrequency = "bfrq")

oldNames <- colnames(primingHeidPrevRT)
newNames <- sapply(oldNames, function(name) {
ifelse(is.na(replacementNames[name]), name, replacementNames[name])
})
colnames(primingHeidPrevRT) <- newNames

bfResults <- generalTestBF(RT ~ trt + prvRt + rtP + rspP + rtP:rspP + bfrq + 
                         W + S, data = primingHeidPrevRT, whichRandom = c("W", "S"))

fails with the error:

Error in checkFormula(formula, data, analysis = "lm") : 
  Some variables missing in data frame.
In addition: Warning message:
In possibleRestrictionsWithMainGeneral(trms, NULL) :
  Falling back to slow recursive method of enumerating models due to many factors.

If the following argument is added,

neverExclude = c("^W$", "^S$")

then the code works.

It is likely a problem with the model enumeration fallback method.

richarddmorey commented 10 years ago

Fixed.