richarddmorey / BayesFactor

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

New options for recompute(): maxError and attempts #70

Open crsh opened 8 years ago

crsh commented 8 years ago

Hi Richard,

I'm currently writing an analysis script for a sequential Bayesian analysis. I will run the script every night to decide if I continue data collection. For obvious reasons I want to base this decision on precise estimates of the Bayes Factors, so I want to recompute the BayesFactor objects until a desired level of precision is reached, without having to manually fiddle with the number of iterations and recomputation attempts.

My current approach to this is quite simply this:

while(any(object@bayesFactor$error > 0.01)) object <- recompute(object)

I think it would be helpful to offer this functionality within recompute(), e.g., by providing an option maxError. Additionally, an option such as attempts could provide the maximum number of recomputation attempts to satisfy the maxError condition.

object <- recompute(object, maxError = 0.01, attempts = 25)

This, to me at least, would be quite helpful.

I'm happy to give this a shot myself and make a pull request, if you like the idea.

Best regards, Frederik

crsh commented 8 years ago

The more I think about it, maxError would also be nice to have in the original call to e.g. anovaBF()

richarddmorey commented 8 years ago

Well, as to having it in the original call: there are cases where the Bayes factor is so large that it makes do difference. Consider a Bayes factor of 4e10 \pm 20%. Do we really want to have an algorithm get that under, say, 1%? Not really. The Bayes factor is so large that we would simply ignore the 20% error. Otherwise we're just wasting CPU cycles.

Perhaps what we need is iterative cycles of ignoring and zooming in on the models we want (or the best models), rather than simply going for a maxError.

richarddmorey commented 8 years ago

But a pull request for recompute would be welcome.