richarddmorey / BayesFactor

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

"Irrelevant" matrix column causes warning in lmBF #111

Closed lindeloev closed 6 years ago

lindeloev commented 6 years ago

When running lmBF(var1 ~ var2 + var3, data, whichRandom='var4') where data contains an "irrelevant column" (say var5) that is a matrix, I get the following warning:

Warning messages:
1: In `[<-.data.frame`(`*tmp*`, indChar | indFac, value = list(id = c(1L,  :
  replacement element 3 has 60130 rows to replace 8590 rows
2: In `[<-.data.frame`(`*tmp*`, indChar | indFac, value = list(id = c(1L,  :
  replacement element 7 has 60130 rows to replace 8590 rows

As you can see, my data has 8590 rows and the matrix var5 has 7 columns, giving it 60130 elements. If I remove the matrix columns (data = data[, c('var1', 'var2', 'var3', 'var4')), the warning disappears.

As far as I can see, it does not affect the results. But it was quite confusing to debug.

richarddmorey commented 6 years ago

Sorry I missed this. Could you provide a reproducible example?

lindeloev commented 6 years ago

I tried reproducing it, but can't. So I'm closing this issue. The following runs just fine:

D = data.frame(a=c(1,2,3,4), b=c(2,3,1,4), c=c(3,1,2,0), d = c(1,1,2,2), e = matrix(1:(7*4), ncol=7))
BayesFactor::lmBF(a ~ b + c, data=D, whichRandom='d')