richarddmorey / BayesFactor

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

Why is lmBF function in R giving me different results at each run? #139

Closed acquafredda closed 4 years ago

acquafredda commented 4 years ago

I am running a linear mixed model analysis, in which I have a dependent variable(pupil mean), two fixed factors (condition and phase type) and one random factor (subj). I want to compute the related bayes factor with lmBF function of the BayesFactor package in R. However, the variable full_BF_pupil keeps giving different results at each run. For example: at 1st run: 1.386933e+137 ±2.19% , 2nd run: 1.381459e+137 ±2.18%

Even if the difference is very small, since other computations are made on this value the final results are more different. What is this due to? Is there a more reliable function for my purposes? Thank you, this is the code line of interest.

[ full_BF_pupil = lmBF(pupil_mean_bin~ cond*phasetype+ subj, data = BR_pre, whichRandom="subj")]

richarddmorey commented 4 years ago

The integration required to compute the BF is performed in this case by a Monte Carlo algorithm, and hence will have an associated Monte Carlo error. You can decrease the error by increasing the Monte Carlo iterations (see the manual for details).

acquafredda commented 4 years ago

Perfect, thank you!