我有一个脚本,看起来像这样:[R种子sedding不是“设置”,结果没有再现
#This is the master script. It runs all other scripts.
rm(list=ls())
#Run data cleaing script
source("datacleaning.R")
set.seed(413) #Seed pre-selected as lead author's wife's birthday (April 13th)
reps=128
#Make imputated datasets
source("makeimps.R")
#Model selection step 1.
source("model_selection.1.R")
load("AIC_results.1")
AIC_results
#best model removed the year interaction
#Model selection step 2. removed year interaction
source("model_selection.2.R")
load("AIC_results.2")
AIC_results
#all interactions pretty good. keeping this model
#Final selected model:
source("selectedmodel.R")
我送这个主脚本的超级计算集群;在32个内核上需要大约17个小时的CPU时间和40分钟的壁挂时间。 (因此我不可重现的例子)。但是,当我运行脚本时,查看结果,然后再次运行,再次查看结果,它们稍有不同。为什么?我设定了种子!种子是否以某种方式重置?我是否需要在每个脚本文件中指定种子?
我需要增加代表的数量,因为它清楚地表明我还没有充分收敛。但这是一个单独的问题。为什么我的结果不能复制自己,我该如何解决?
在此先感谢。
编辑:我正在通过doMC
和plyr
进行并行化。根据下面的评论,一些轻的谷歌搜索引起了人们无法真正使用这些软件包设置“并行种子”的事实。我需要以某种方式将我的代码迁移到SNOW
。如果有人知道doMC
和plyr
的解决方案,我会很高兴知道它是什么。
看在你似乎被保存那些RDATA文件。在他们中的任何一个中,是否有一个'.Random.seed'对象?尝试使用[此问题]的答案(http://stackoverflow.com/q/4831050/1465387)。 – 2013-04-10 05:17:05
如果任何您正在输出使用R多核包中的文件,看看这个:http://stats.stackexchange.com/a/3534 – hrbrmstr 2013-04-10 05:21:26
@hrbrmstr:完蛋了。做了一些挖掘工作。谢谢。 – 2013-04-10 05:29:08