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

3.6k Views Asked by At

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

There are 1 best solutions below

2
On

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