[R] Random seed problem in MCMC coupling of chains

Gorjanc Gregor Gregor.Gorjanc at bfro.uni-lj.si
Wed Jun 8 19:28:17 CEST 2005


Thanks to Paul and Gabor for additional tips/examples. Actually, I find
Pauls suggestion with setRNG also nice and is exactly what I wanted. 
Paul, if I understand this correctly, your suggestion with setRNG does not
alter "RNG flow", it just takes care that chains really have equal seeds.
I remember that I have read somewhere that destroying "RNG flow over and
over to get real randomness" is not a good idea. Can someone confirm this?

niter <- 3
nchain <- 2
for (i in 1:niter) { # iterations
  tmpSeed <- setRNG()
  for (j in 1:nchain) { # chains
    setRNG(tmpSeed)
    a <- runif(1)
    cat("iter:", i, "chain:", j, "runif:", a, "\n")
  }
}

iter: 1 chain: 1 runif: 0.8160078
iter: 1 chain: 2 runif: 0.8160078
iter: 2 chain: 1 runif: 0.4909793
iter: 2 chain: 2 runif: 0.4909793
iter: 3 chain: 1 runif: 0.4425924
iter: 3 chain: 2 runif: 0.4425924

[... removed other stuff ...]

Lep pozdrav / With regards,
    Gregor Gorjanc

----------------------------------------------------------------------
University of Ljubljana
Biotechnical Faculty        URI: http://www.bfro.uni-lj.si/MR/ggorjan
Zootechnical Department     mail: gregor.gorjanc <at> bfro.uni-lj.si
Groblje 3                   tel: +386 (0)1 72 17 861
SI-1230 Domzale             fax: +386 (0)1 72 17 888
Slovenia, Europe
----------------------------------------------------------------------
"One must learn by doing the thing; for though you think you know it,
 you have no certainty until you try." Sophocles ~ 450 B.C.




More information about the R-help mailing list