You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.
The text was updated successfully, but these errors were encountered: