I’m producing samples from a G-Wishart distribution (for example Mohammadi and Wit (2015) and Mohammadi et al. (2017) ) using the BDgraph package in R, but I’m getting different results from one OS to another.
The results are however consistent on the same OS across different machines!
To see this (and to give a minimum reproducible example) I’ll sample from the rgwish function on one OS (say linux)
library(BDgraph) N = 10000 s=7 nu = s+5 m = sample(5:50,s,replace = TRUE) G = matrix(nrow = s,ncol = s, c(0,1,0,0,0,0,0, 0,0,1,1,0,0,0, 0,0,0,1,1,1,0, 0,0,0,0,1,1,0, 0,0,0,0,0,1,0, 0,0,0,0,0,0,1, 0,0,0,0,0,0,0)) sample_linux <- rgwish( n = N, adj.g = G, b = nu - s + 1 , D = diag(m,s,s) ) save.image("foo.RData")
I’ll then save the resulting samples and the parameters somewhere. Reboot on (say) Windows and run
load("foo.RData") library(BDgraph) sample_win <- rgwish( n = N, adj.g = G, b = nu - s + 1 , D = diag(m,s,s) ) plot( density( sample_linux[7,7,],n=2024), type="l") lines( density( sample_win[7,7,],n=2024 ) ,col="red" )
The two marginal distribution (of this last diagonal element in this example) are clearly different in my experience:
If I however repeat the procedure on another machine with linux installed the two samples coincide.
The underlying graph G doesn’t seem to matter, I’ve tried with both decomposable or non-decomposable graphs and tried different formats for the adjacency matrix (with diagonal or not, symmetric or upper trianguar etc..) although the one here seems to be the preferred format, and inside the rgwish function the authors correct for it anyway.
R version is 3.4.1 on all the machines and BDgraph and all connected packages are at their last version available*.
For those who might be curious OSX gives a consistently different third set of answers…
The only thing changing that I can think of are the BLAS and LAPACK libraries, but I haven’t installed any “experimental”/weird package, openBLAS on both my linux systems and I don’t even know which one on Windows (the one R comes with in the binaries from CRAN)…
EDIT: I suppose that there wasn’t really a question, so…what do you think of it? Any idea why this could happen? Any idea how to solve the issue?
Until proven wrong I’ll assume I’m the one doing something wrong, either in sampling or in verifying, so I decided to write here before contacting the maintainer of the package directly.
*(igraph compiled from github in both cases as normal install on linux fails.)