简体   繁体   English

当使用seed = NA时,如何找出MICE R-package选择哪个种子进行多重插补?

[英]How to find out which seed the MICE R-package chose for multiple imputation when using seed=NA?

I´m doing a multiple imputation for a dataframe named "mydata" with this code: 我正在使用以下代码对名为“ mydata”的数据框进行多次插补:

library(mice) 库(小鼠)

imp<-mice(mydata,pred=pred,method="pmm", m=10) imp <-mice(mydata,pred = pred,method =“ pmm”,m = 10)

Because the default argument for this is function is "seed=NA", the seed-number is chosen randomly. 因为此功能的默认参数是function“ seed = NA”,所以种子编号是随机选择的。 I would like to keep it like this, because i don´t know which number i should choose as a seed. 我想这样保留,因为我不知道我应该选择哪个数字作为种子。 But for replication i would like to know which seed this function chose for me. 但是对于复制,我想知道此功能为我选择了哪种种子。 Is there a possibility to inspect the mids-object "imp" for the seed-value? 是否有可能检查中间对象“ imp”的种子值? Or should i just use a random number generator and set the seed to a generated value? 还是我应该只使用随机数生成器并将种子设置为生成的值?

If you look at the documentation, there is no such thing as a set.seed argument for mice function. 如果你看一下文件,有没有这样的事,作为一个set.seed为了论证mice功能。 There is, however a seed argument which takes an integer. 但是,有一个使用整数的seed参数。 If left alone, the integer is generated randomly. 如果不予处理,则整数是随机生成的。

 An integer that is used as argument by the `set.seed()` for offsetting the random number generator. Default is to leave the random number generator alone 

You can choose your own integer. 您可以选择自己的整数。 If you're stuck at what to choose, try your lucky number, or some random integer, with sky or architecture of your system being the limit. 如果您选择什么,请尝试使用幸运数字或一些随机整数,以系统的天空或体系结构为限。

The function sets seed in the following manner, which translates to "set seed only if specified, otherwise leave alone" as mentioned in the documentation. 该函数以以下方式设置种子,如文档中所述,翻译为“仅在指定时设置种子,否则不做任何设置”。

   if (!is.na(seed))
        set.seed(seed)  ## FEH 1apr02

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM