richarddmorey / BayesFactor

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

Is there a way to access individual model errors? #54

Open jonathon-love opened 9 years ago

jonathon-love commented 9 years ago

Hi,

When we run multiple models, some of them can fail. An error is produces at the console, but we would like to have access to this information as well. Take the following code for example:

library(BayesFactor)
z <- y <- c(0,0,0,1,1,1)
x <- rnorm(6)
data <- data.frame(x=x,y=y,z=z)

generalTestBF(z~x*y,data,progress=FALSE)

It produces some NaN BFs, but we would like to provide explanations to the user why these models failed. Is there a way to access this? if not, could these errors be added to the individual BF objects?

with thanks

jonathon-love commented 9 years ago

hey,

@mmarsman1 and i have been discussing this, and i think we're going to transition to calling lmBF() directly, rather than calling generalTestBF()

so perhaps it would be simpler if lmBF() just threw an error, and we could catch that for each model.

richarddmorey commented 9 years ago

Well, lmBF in turn calls one of many functions, depending on the kind of model involved. I think you'll have the same issue one level deeper. I'll have a think about this.

jonathon-love commented 9 years ago

yup,

so i gather you catch and handle errors in these underlying functions so that if one model fails, all the other models in the analysis continue to run.

wouldn't this be best if error handling happened at the level of generalTestBF()? lmBF() could throw errors, and generalTestBF() could catch them.

this way you achieve the same functionality, but allow people who call lmBF() the opportunity to access the error information.

of course, my reading of how this all works might be neive.

richarddmorey commented 9 years ago

I'll see what I can do.

jonathon-love commented 9 years ago

cheers