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

空扰寡人 提交于 2019-12-13 19:17:54

问题


I´m doing a multiple imputation for a dataframe named "mydata" with this code:

library(mice)

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. 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? Or should i just use a random number generator and set the seed to a generated value?


回答1:


If you look at the documentation, there is no such thing as a set.seed argument for mice function. There is, however a seed argument which takes an integer. 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


来源:https://stackoverflow.com/questions/27291025/how-to-find-out-which-seed-the-mice-r-package-chose-for-multiple-imputation-when

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!