nicebread / BFDA

An R package for Bayes Factor Design Analysis
28 stars 9 forks source link

Unexpected number of simulations with multiple cores #7

Open kalenkovich opened 5 years ago

kalenkovich commented 5 years ago

It seems that parameter B of BFDA.sim sets the number of simulations per core and not the total number of simulations. This behavior was unexpected to me. While the help for BFDA.sim does not explicitly stay which way it is, it does say that B "should be dividable by the numbers of cores" which implies that B is the total number of simulations. I think that either the behavior or the docs should be changed. Personally, I would go for the behavior.

Steps to reproduce:

library(BFDA)

sim.H1 <- BFDA.sim(
  expected.ES = 0.5, type = "t.between", alternative = "greater",
  n.max = 20,
  B = 4, cores = 2
)

n_simulations <- length(unique(sim.H1$sim$id))
n_simulations

Output:

8

Expected output:

4

nicebread commented 5 years ago

Interesting, thanks for the note. In fact B should be the number of total simulations, and the expected output is 4, as you wrote.

I ran the code on my system (Mac OS, R version 3.5.2) and it returns the expected number of simulations (i.e., 4).

What version of BFDA, R, and what operating system do you use? Can you post the content of sim.H1$sim$id?

kalenkovich commented 5 years ago

I'm on Win 7 x64, R version 3.5.1, BFDA 0.5.0.

> sim.H1$sim$id
 [1] 101 101 101 101 101 101 101 101 101 101 101 102 102 102 102 102 102 102 102 102 102
[22] 102 103 103 103 103 103 103 103 103 103 103 103 104 104 104 104 104 104 104 104 104
[43] 104 104 201 201 201 201 201 201 201 201 201 201 201 202 202 202 202 202 202 202 202
[64] 202 202 202 203 203 203 203 203 203 203 203 203 203 203 204 204 204 204 204 204 204
[85] 204 204 204 204
nicebread commented 5 years ago

Thanks for the info; might be an OS problem. We'll look into it!