Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set.seed does dot work with multicore option in anovaBF #153

Open
karlosluna opened this issue May 31, 2021 · 1 comment
Open

Set.seed does dot work with multicore option in anovaBF #153

karlosluna opened this issue May 31, 2021 · 1 comment

Comments

@karlosluna
Copy link

karlosluna commented May 31, 2021

Hi!

Package BayesFactor 0.9.12.4.2.

I was trying to conduct a 2x2 Bayesian ANOVA and I found that the multicore option disables or does not work well with set.seed. set.seed allows to replicate the results of the Bayesian ANOVA, but if the multicore option is added, then the results are no longer replicable. Here is an example:

#Load the required package:
library(doMC)

#Generate random data that (more or less) mimic my actual data:
rnorm2 <- function(n,mean,sd) { mean+sd*scale(rnorm(n)) }
vd1 <- rnorm2(50,70,10)
vd2 <- rnorm2(50,30,20)

a <- factor(rep(rep(1:2, each=25), 2), label=c("A1", "A2"))
b <- factor(rep(1:2, each=50), label=c("B1", "B2"))
part <- factor(rep(1:50, 2))
vd <- c(vd1, vd2)
df <- data.frame(part, a, b, vd)

#I use a low number of iterations because my computer is old and there is no need to wait for computations.
#Without multicore. Run a couple of times and verify that the results replicate.
set.seed(2021)
bf = anovaBF(vd ~ a * b + part, data=df, whichRandom = "part", iterations = 50)
bf

#With multicore. Run a couple of times and verify that the results do not replicate.
set.seed(2021)
bf = anovaBF(vd ~ a * b + part, data=df, whichRandom = "part", iterations = 50, multicore = TRUE)
bf

I have no questions, just wanted to inform the developer about this.

@richarddmorey
Copy link
Owner

Thanks, I'll look into it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants