richarddmorey / BayesFactor

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

invalid class errors of regressionBF with R3.3.3 #116

Closed Smalboy closed 6 years ago

Smalboy commented 6 years ago

Hi,

when trying "BF_score <- regressionBF(yval ~ xval,data=res_scores)", it works OK with R3.4.*, but the following error message was present when I ran the command line in the R3.3.3:

invalid class “BFBayesFactor” object: Some numerators are not BFmodel objects. Calls: logBF_scores[note: MY FUNCTION] ... BFBayesFactor -> new -> initialize -> initialize -> validObject

Best, Chunliang

richarddmorey commented 6 years ago

Can you provide a reproducible example?

Smalboy commented 6 years ago

Yes. The following code was in a "BF_test.R" file, and I ran it in the terminal with: Rscript ./BF_test.R > BFtest.txt. The following error message is present.

#############################messages############################ Welcome to BayesFactor 0.9.12-2. If you have questions, please contact Richard Morey (richarddmorey@gmail.com).

Type BFManual() to open the manual.


Error in validObject(.Object) : invalid class “BFBayesFactor” object: Some numerators are not BFmodel objects. Calls: regressionBF ... BFBayesFactor -> new -> initialize -> initialize -> validObject Execution halted #############################messages############################

#########################R code################################## library("coda",lib="/media/homefolders/cfeng/Rlib") library("BayesFactor",lib="/media/homefolders/cfeng/Rlib")

res_scores <- data.frame("xval"=runif(60),"yval"=runif(60)) BF_score <- regressionBF(yval ~ xval,data=res_scores,progress=FALSE) print(BF_score@bayesFactor$bf) #########################R code##################################

richarddmorey commented 6 years ago

This works fine for me in R 3.3.3:

library(coda)
library(BayesFactor)

set.seed(1)
res_scores <- data.frame("xval"=runif(60),"yval"=runif(60))
BF_score <- regressionBF(yval ~ xval,data=res_scores,progress=FALSE)
print(BF_score@bayesFactor$bf)
# [1] -1.335096

It could be related to how you've installed your library; have you tried re-installing the package under R 3.3.3?

Smalboy commented 6 years ago

Thanks Richard. I got it running in the R console ~Best, Chunliang.