amices / mice

Multivariate Imputation by Chained Equations
https://amices.org/mice/
GNU General Public License v2.0
428 stars 107 forks source link

restore futuremice parallelseed to old behaviour #518

Closed gerkovink closed 1 year ago

gerkovink commented 1 year ago

Closes #517.

Revert back parrallelseed behaviour. .Random.seed was not found when calling futuremice() outside of .GlobalEnv. Now this works:

library(mice, warn.conflicts = FALSE)
ex <- function(x){
  run <- function(x){
    futuremice(x, m=5, n.core=2)
  }
  run(x)
}
ex(nhanes)
#> Class: mids
#> Number of multiple imputations:  5 
#> Imputation methods:
#>   age   bmi   hyp   chl 
#>    "" "pmm" "pmm" "pmm" 
#> PredictorMatrix:
#>     age bmi hyp chl
#> age   0   1   1   1
#> bmi   1   0   1   1
#> hyp   1   1   0   1
#> chl   1   1   1   0

{futuremice(nhanes, n.core=2)}
#> Class: mids
#> Number of multiple imputations:  5 
#> Imputation methods:
#>   age   bmi   hyp   chl 
#>    "" "pmm" "pmm" "pmm" 
#> PredictorMatrix:
#>     age bmi hyp chl
#> age   0   1   1   1
#> bmi   1   0   1   1
#> hyp   1   1   0   1
#> chl   1   1   1   0

Created on 2022-11-10 with reprex v2.0.2

Saw no need to use .Random.seed from whatever frame as the mids object inherits the used parallelseed.

gerkovink commented 1 year ago

This PR is unrelated to #515 and relates to the internal parallelseed in futuremice().

stefvanbuuren commented 1 year ago

Addressed by c084cdd48