richarddmorey / BayesFactor

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

anovaBF Error in if (...length() && any(...names() == "Dimnames")): missing value where TRUE/FALSE needed #165

Closed lenarddome closed 1 year ago

lenarddome commented 1 year ago

I am experiencing some issues with anovaBF. It was previously reported with lmBF in #163 but no solutions were provided - the issue was closed. The example in the documentation should be enough to reproduce it:

data(sleep)
## Gives a Bayes factor of about 11.6
## in favor of the alternative hypothesis
anovaBF(extra ~ group + ID, data = sleep, whichRandom = "ID",
    progress=FALSE) 

The error as follows:

> anovaBF(extra ~ group + ID, data = sleep, whichRandom = "ID",
        progress=FALSE)
Error in if (...length() && any(...names() == "Dimnames")) .Object@Dimnames <- fixupDN(.Object@Dimnames) : 
  missing value where TRUE/FALSE needed

I uploaded renv.lock and sessionInfo as a simple text file.

renv.lock.txt sessionInfo.txt

R was run in a docker container with Ubuntu 22.04.2 LTS.

lenarddome commented 1 year ago

Okay, so it seems that the error is specific to the setup - I don't get the error outside of the docker and renv with the following setup:

R version 4.3.1 (2023-06-16)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.2.1

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

locale:
[1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8

time zone: Europe/London
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] BayesFactor_0.9.12-4.4 Matrix_1.6-0           coda_0.19-4           

loaded via a namespace (and not attached):
 [1] lattice_0.21-8     magrittr_2.0.3     glue_1.6.2         stringr_1.5.0      parallel_4.3.1     lifecycle_1.0.3    mvtnorm_1.2-2     
 [8] cli_3.6.1          grid_4.3.1         compiler_4.3.1     tools_4.3.1        pbapply_1.7-2      Rcpp_1.0.11        rlang_1.1.1       
[15] stringi_1.7.12     MatrixModels_0.5-2
richarddmorey commented 1 year ago

I've never seen the error and fixupDN appears to be a function in the Matrix package. But I see the same error here: https://stackoverflow.com/questions/75279787/error-when-working-on-a-corpus-missing-value-where-true-false-needed

They say:

"UPDATE: Actually, the problem was caused by a bug that occurred to RStudio itself. Uninstalling and re-installing R and RStudio solved the issue and made the error disappear. Thanks to everyone who looked and provided a solution."

Can you try this?

lenarddome commented 1 year ago

No problem. Thank you for having a look through. I gave this a shot - pulled the latest Ubuntu image and set up a new docker container with brand new installs - and I still get the same error.

Nonetheless, it works when I run the command outside a container, so this must be an edge case. And as you say, it seems to be coming from the Matrix dependency and not from anovaBF. I am looking at the r-forge issue tracker of Matrix, but it is really hard to sort...

Anyways, I am closing the issue as the bug is not coming from the BayesFactor package. 😃