Imputes missing values using distributional random forests within the multiple imputation by chained equations framework implemented in the mice package.
Usage
mice.impute.DRF(
y,
ry,
x,
wy = NULL,
min.node.size = 1,
num.features = 10,
num.trees = 10,
...
)Arguments
- y
Vector to be imputed.
- ry
Logical vector indicating which elements of
yare observed and used to fit the imputation model.- x
Numeric design matrix with
length(y)rows, containing predictors fory. The matrix should not contain missing values.- wy
Logical vector indicating elements of
yfor which imputations are generated. IfNULL, defaults to!ry.- min.node.size
Target minimum number of observations in each tree leaf in the distributional random forest. Default is
1.- num.features
Number of random features to sample at each split. Default is
10.- num.trees
Number of trees in the distributional random forest. Default is
10.- ...
Additional arguments passed by
micefor compatibility with themice.imputeinterface. Currently ignored.
Value
A numeric vector of imputed values for the entries of y
indicated by wy. The vector has length sum(wy) and is
returned to mice to replace the missing values in the current
variable.
Details
This function is called internally by mice when the imputation
method is set to "DRF". For each variable with missing values, a
distributional random forest is fitted to the observed values using the
remaining variables as predictors. Missing values are then imputed by
sampling observed responses according to the forest weights.
References
Näf, J., Scornet, E., and Josse, J. (2024). "What is a good imputation under MAR missingness?" https://arxiv.org/abs/2403.19196.
Cevid, D., Michel, L., Näf, J., Meinshausen, N., and Buehlmann, P. (2022). "Distributional random forests: Heterogeneity adjustment and multivariate distributional regression." Journal of Machine Learning Research, 23(333), 1–79.
Examples
library(mice)
#>
#> Attaching package: ‘mice’
#> The following object is masked from ‘package:stats’:
#>
#> filter
#> The following objects are masked from ‘package:base’:
#>
#> cbind, rbind
set.seed(123)
X <- matrix(rnorm(1000), nrow = 100)
X[runif(length(X)) < 0.3] <- NA
imp <- mice(X, method = "DRF", m = 1, maxit = 1, printFlag = FALSE)
complete(imp)
#> V1 V2 V3 V4 V5 V6
#> 1 -1.13813694 -0.71040656 2.19881035 -0.71524219 -0.07355602 -0.60189285
#> 2 0.89512566 0.25688371 1.31241298 -0.75268897 -1.16865142 -0.99369859
#> 3 -1.12310858 -0.24669188 -0.26514506 -1.99274849 0.12631586 1.02678506
#> 4 0.07050839 -0.34754260 0.02098359 -1.05251328 -0.02884155 0.75106130
#> 5 0.12928774 -0.95161857 -0.56187636 -0.43715953 0.67069597 -1.50916654
#> 6 1.71506499 -0.04502772 -0.47624689 0.65119328 -1.65054654 -0.09514745
#> 7 0.46091621 -0.38022652 -0.26565163 -2.01421050 -0.53880916 -0.89594782
#> 8 0.89512566 0.56298953 -0.59461727 0.21198043 0.75640644 -2.07075107
#> 9 0.21594157 -0.38022652 1.65090747 1.23667505 -0.53880916 0.15012013
#> 10 0.44820978 0.91899661 0.09049665 2.03757402 0.22729192 -0.07921171
#> 11 1.22408180 -0.57534696 0.11924524 1.30117599 0.49222857 0.07950200
#> 12 -1.54875280 -0.23627957 0.24368743 -0.75268897 0.26783502 -0.05129789
#> 13 0.40077145 0.68791677 -0.57438869 -1.72673040 1.08477509 0.96726726
#> 14 0.11068272 -0.05556197 1.08079950 -0.60150671 -0.29515780 -0.78173971
#> 15 -0.55584113 0.51940720 -0.99250715 -0.35204646 -0.41367651 -0.61643584
#> 16 0.92226747 -0.37458086 0.16806538 0.70352390 0.23061683 -0.73479925
#> 17 0.49785048 0.10567619 -0.52111732 -0.89320757 -0.09294102 -0.13180279
#> 18 1.09683901 1.05271147 -0.72306597 -1.25864863 0.43028470 0.31001699
#> 19 0.70135590 -0.84970435 -1.23627312 2.03757402 0.53539884 -1.03968035
#> 20 1.71506499 -1.02412879 -1.28471572 0.91139129 -0.55527835 -0.18430887
#> 21 -1.06782371 0.11764660 0.24368743 0.23743027 1.77950291 0.96726726
#> 22 -0.21797491 -0.94747461 0.61798582 1.21810861 0.28642442 -0.10828009
#> 23 -1.02600445 0.78773885 1.10984814 -1.33877429 0.12631586 -0.69842067
#> 24 -1.22071771 -0.23627957 -0.26514506 0.66082030 1.27226678 0.70416728
#> 25 1.20796200 1.84386201 -0.36365730 -0.52291238 -0.71846622 1.11464855
#> 26 1.20796200 -0.89536336 -1.23627312 1.67105483 -0.45033862 0.55004396
#> 27 0.83778704 0.23538657 -0.50219872 -0.06082195 0.23061683 1.23667580
#> 28 0.15337312 0.07796085 -0.71721816 -1.99274849 0.01112919 0.84053983
#> 29 -1.13813694 -0.96185663 0.88465050 1.50390061 1.63356842 0.41027510
#> 30 1.25381492 -0.07130809 -0.34391723 0.00729009 -1.43850664 -0.55845691
#> 31 0.42646422 -0.74133610 1.95529397 2.03757402 -0.19051680 0.60537067
#> 32 -0.29507148 0.45150405 -0.09031959 0.70352390 0.37842390 -0.50633354
#> 33 0.89512566 -0.74133610 0.21453883 -0.72160444 -1.08999187 -1.42056550
#> 34 -0.50232345 -1.06332613 -0.73852770 1.51921771 -1.00563626 0.12799297
#> 35 -1.12310858 -2.05324722 -0.57438869 0.37738797 0.67069597 1.94585122
#> 36 0.68864025 1.13133721 -1.31701613 0.86577940 -1.07742065 -1.18620659
#> 37 0.55391765 -1.46064007 -0.18292539 -0.97400958 -1.16865142 1.16525339
#> 38 -0.06191171 0.73994751 -1.53290200 -0.20078102 1.08477509 0.35885572
#> 39 -0.30596266 1.90910357 0.09049665 0.86577940 -2.05233698 -0.60855718
#> 40 -0.38047100 -1.44389316 -0.78153649 -0.10188326 1.23569346 -0.20224086
#> 41 -0.69470698 0.70178434 2.00248273 0.62418747 -1.24104450 -0.27324811
#> 42 0.38528040 0.21444531 -0.50219872 0.05601673 1.21001051 1.65191539
#> 43 -1.26539635 -1.57214416 -0.10097489 1.67105483 0.16532102 0.70416728
#> 44 2.16895597 0.91899661 -1.13730362 0.05601673 0.43028470 -1.19736350
#> 45 1.20796200 -0.74133610 -0.17905159 1.21810861 0.67069597 0.86636613
#> 46 -1.12310858 1.90910357 1.90236182 0.66082030 0.16532102 0.86415249
#> 47 -0.40288484 -0.84970435 -0.10097489 0.09932759 -0.22768406 -1.19862236
#> 48 0.89512566 0.68791677 -1.35984070 -0.57185006 -0.41367651 0.63949200
#> 49 0.11068272 2.10010894 2.19881035 -0.97400958 -2.05233698 2.43022665
#> 50 -0.08336907 -1.28703048 1.05418102 -0.17990623 -1.63637927 -1.50775732
#> 51 0.25331851 0.78773885 -0.37560287 1.01494317 1.43040234 0.84490424
#> 52 0.42646422 0.76904224 -0.56187636 -1.99274849 1.04662885 0.31001699
#> 53 -0.04287046 0.33220258 -0.34391723 0.21198043 -0.34847245 1.11071142
#> 54 -0.08336907 -0.23627957 0.09049665 0.11663728 0.71517841 0.24982472
#> 55 -0.22577099 -0.11945261 1.59850877 -0.89320757 0.91717492 1.65191539
#> 56 -0.30596266 -0.28039534 0.09049665 -0.17990623 -2.66092280 -1.45897073
#> 57 -1.54875280 0.56298953 1.08079950 1.50390061 1.11027710 -0.05129789
#> 58 0.58461375 -0.37243876 0.63075412 -0.52291238 -0.87307100 -0.20224086
#> 59 0.12385424 -0.34754260 0.84964305 0.66082030 0.23061683 -0.19726487
#> 60 0.21594157 -0.37458086 -1.53290200 2.57145815 -0.29515780 0.57872237
#> 61 0.42646422 1.05271147 -0.52111732 -0.20529926 -0.71846622 -0.83384358
#> 62 -0.50232345 0.33220258 -0.48987045 0.65119328 -0.34847245 0.57872237
#> 63 -0.33320738 -1.26015524 0.04715443 1.67105483 0.51850377 -1.08758071
#> 64 -1.01857538 3.24103993 -0.47624689 1.02467323 -1.24104450 1.48403093
#> 65 -0.40288484 -0.41685759 2.29307897 0.81765945 -1.09278721 -1.18620659
#> 66 -1.22071771 0.29822759 -0.78153649 0.05601673 1.21001051 0.10107915
#> 67 0.44820978 0.73994751 -1.53290200 0.37816777 -1.63637927 -0.83384358
#> 68 1.71506499 -0.48378063 -1.75652740 -0.94540883 -0.21404124 0.58673534
#> 69 0.92226747 0.51686204 -0.57438869 0.85692301 0.06515393 0.02610023
#> 70 2.05008469 0.36896453 -0.72306597 -0.46103834 0.43028470 0.07950200
#> 71 -1.12310858 -0.07130809 -1.53290200 2.41677335 0.53539884 0.96126415
#> 72 -2.30916888 0.06529303 0.96252797 -1.65104890 0.26783502 -1.45646592
#> 73 1.00573852 -1.28703048 0.22101947 0.51013255 -1.32295111 -0.78173971
#> 74 -0.70920076 2.12845190 1.05418102 0.82537986 -0.23935157 0.32040231
#> 75 -0.68800862 -0.74133610 0.84964305 0.51013255 -0.21404124 0.86636613
#> 76 1.02557137 1.05271147 -0.44655722 0.45623640 0.15168050 0.35885572
#> 77 -0.28477301 0.03778840 0.17480270 -0.99678074 1.71230498 0.58673534
#> 78 -1.22071771 0.31048075 0.07455118 0.14447570 0.26783502 0.86415249
#> 79 0.18130348 1.13133721 0.42816676 -0.46103834 0.37300466 -1.50775732
#> 80 -0.22577099 -0.45836533 -0.99250715 -1.79028124 -0.22768406 0.02610023
#> 81 0.58461375 -1.06332613 -1.66747510 0.03455107 -0.10578417 -0.31641587
#> 82 0.38528040 1.26318518 0.73649596 2.03757402 0.31405766 -0.22622198
#> 83 -0.37066003 -0.05556197 0.38602657 0.17472640 1.32821470 -1.18155923
#> 84 2.05008469 -0.86551286 -0.26565163 -1.05501704 1.27226678 -1.31651040
#> 85 -0.22048656 -0.23627957 0.11814451 0.47613328 0.71284232 -1.03895644
#> 86 0.33178196 0.11764660 -1.28471572 1.23667505 -1.07742065 -0.22622198
#> 87 1.09683901 1.10992029 0.22101947 0.45623640 0.06515393 0.38142583
#> 88 0.43518149 0.08473729 -0.34391723 -1.13558847 -0.57439455 -0.78351579
#> 89 -0.32593159 -1.25127136 -0.21905038 -0.72160444 -1.43850664 0.58299141
#> 90 1.14880762 -0.49929202 0.16806538 0.34610362 -0.38095674 -1.31651040
#> 91 -1.54875280 0.21444531 -0.99250715 -0.64704563 -0.10578417 -2.80977468
#> 92 0.54839696 1.84386201 1.05418102 0.85692301 0.43028470 0.46496799
#> 93 1.53261063 0.09458353 0.11924524 0.37816777 1.29408391 0.84053983
#> 94 0.25331851 -0.89536336 -0.57746800 -0.82947761 -1.08999187 -0.12714861
#> 95 1.36065245 -1.31080153 2.00248273 -0.57356027 -0.87307100 -0.60855718
#> 96 -0.60025959 1.99721338 -0.99250715 1.50390061 -1.35807906 -1.15591653
#> 97 2.18733299 0.60070882 -0.99250715 0.47613328 0.18184719 -0.12714861
#> 98 1.53261063 -1.25127136 -1.35090269 0.84573154 0.23061683 -1.94151838
#> 99 -0.23570036 -0.61116592 0.02098359 -1.26068288 0.36411469 1.18118089
#> 100 0.12928774 -0.11945261 1.24991457 -0.35454240 -1.07742065 -1.31651040
#> V7 V8 V9 V10
#> 1 0.63612404 -0.728219111 -0.35091783 -1.014114173
#> 2 -0.02734697 -1.540442405 -0.65801021 -0.791313879
#> 3 -0.03333034 0.213957980 0.47703724 0.299593685
#> 4 -1.51606762 0.118849433 -0.36835258 0.301313652
#> 5 -2.07848927 0.374643568 0.27627456 1.084617009
#> 6 -1.93850470 0.589982679 0.14410466 -0.624567474
#> 7 -0.65674293 0.289344029 -0.07562508 0.825922902
#> 8 -1.22292618 -0.904215026 2.16141585 -0.048568353
#> 9 -0.29976250 0.226324942 0.27631553 0.301313652
#> 10 -0.84906114 0.748081162 -0.15829403 0.260361491
#> 11 -0.39703052 1.061095253 -2.50791780 2.575449764
#> 12 -1.21759999 -0.212848279 -1.56528177 -1.185288811
#> 13 0.48361753 -0.093636794 -0.07767320 0.100919859
#> 14 -0.01600253 -0.086714135 0.20629404 -1.779977288
#> 15 1.07494508 -1.692101521 0.27687246 0.589835923
#> 16 -2.60169967 1.125071892 1.01645522 1.096608472
#> 17 0.12071933 -0.728219111 -0.65801021 1.445662241
#> 18 -0.67548229 -2.210633111 1.21458879 -1.925145252
#> 19 -1.22292618 0.373241434 -0.92151604 0.412769497
#> 20 1.54660915 0.403290331 -1.20844272 1.593369951
#> 21 -1.41528192 -1.041673294 -1.22898618 2.575449764
#> 22 -1.11989972 0.001683688 0.74229702 -0.212150532
#> 23 0.84643629 0.641830028 -0.08291994 -0.036537222
#> 24 0.17819019 -1.529310531 0.78981792 -0.359975118
#> 25 -0.87525548 0.001683688 -0.45839014 0.665159876
#> 26 0.94116581 0.250247821 -0.59189210 0.784170879
#> 27 -1.22292618 0.563867390 -0.36835258 -0.095487590
#> 28 -0.67850315 -0.093636794 -0.35245320 0.196278045
#> 29 -1.38804905 -0.728219111 -1.16961526 2.487997877
#> 30 -1.54777654 -2.037682494 -1.44203465 0.431098928
#> 31 -0.67850315 1.738633767 1.05432227 0.188753109
#> 32 -1.85557165 0.881178809 -0.59733009 -1.005377582
#> 33 0.12071933 -1.943650901 0.78945985 0.002856048
#> 34 0.31023026 1.399576185 1.51649060 -1.779977288
#> 35 0.12071933 -0.056055946 -0.19177481 -0.011045830
#> 36 -0.83081153 0.524914279 0.28387891 -0.575417641
#> 37 -0.11630252 0.622033236 -1.75106752 -0.686815652
#> 38 1.13939629 -0.096686073 -0.81866978 -0.720773632
#> 39 0.63612404 -0.075263198 0.05621485 0.825922902
#> 40 -0.49293742 1.019157069 0.29908690 1.368132648
#> 41 -0.84906114 0.711601922 -0.75939812 1.049086627
#> 42 0.27106676 0.904435464 2.68485900 -0.359975118
#> 43 -0.72738353 0.250247821 -0.45839014 -0.799513954
#> 44 2.45806049 0.904435464 0.06424356 -0.082086904
#> 45 -0.39579795 0.207381157 0.64979187 0.156702987
#> 46 0.89935405 -2.210633111 -0.02601863 0.103638004
#> 47 -0.83081153 1.061095253 -0.64356739 -0.662607276
#> 48 -0.03333034 0.904435464 2.68485900 2.006680691
#> 49 0.74081452 -0.913566048 0.39529587 0.002856048
#> 50 1.96624802 0.374643568 0.20629404 -1.213944470
#> 51 -1.93850470 1.538430199 0.56226735 -0.799513954
#> 52 0.10719041 -0.086714135 1.21458879 -1.005377582
#> 53 0.60877901 -0.904215026 1.01645522 0.156155707
#> 54 0.89935405 0.213957980 1.21458879 1.070516037
#> 55 0.03152600 0.279627862 2.32086022 -0.522616697
#> 56 -0.82817427 -0.120393825 -0.60353125 -1.621858259
#> 57 1.02025301 0.904435464 -1.45884941 0.301313652
#> 58 0.53848203 -0.201458147 -0.35091783 0.310450081
#> 59 -1.21759999 -2.037682494 0.14670848 -1.421108448
#> 60 0.12071933 -0.195889249 1.62362121 -1.074206610
#> 61 2.45806049 0.539790606 0.91120968 0.784170879
#> 62 -1.21759999 0.001683688 0.05621485 -1.925145252
#> 63 1.96624802 0.616567817 1.51649060 0.156702987
#> 64 0.10719041 -1.692101521 -0.86603774 0.046733528
#> 65 -2.24905109 0.368742058 -0.16328493 0.096585834
#> 66 0.03152600 0.967859210 2.55302611 0.054736525
#> 67 0.20556121 1.276578681 -1.86022757 -1.848472775
#> 68 -0.15534535 -0.195889249 1.13105465 -1.621858259
#> 69 0.56828862 -0.321892586 1.13105465 -0.791313879
#> 70 -0.29976250 1.487837832 1.66599090 0.260361491
#> 71 -1.93850470 0.904435464 -1.13920064 0.054736525
#> 72 0.89935405 -0.436829977 -0.97199421 -2.111208373
#> 73 0.39784221 0.457462079 -0.65801021 -0.662607276
#> 74 0.17819019 -1.617773765 0.05621485 0.986058221
#> 75 0.84643629 0.279627862 1.48377949 0.986058221
#> 76 -0.85362370 1.877864021 1.95072101 -1.098490007
#> 77 -1.11989972 -0.004060653 0.79760066 -0.799513954
#> 78 -1.32775548 0.279627862 0.78981792 1.070516037
#> 79 -0.85362370 -0.904215026 -0.15829403 -0.322746362
#> 80 -0.69330453 -0.279072171 -0.13187491 0.046733528
#> 81 0.38230514 0.813400374 0.47703724 2.305061982
#> 82 0.98211300 0.904435464 -0.97199421 0.103638004
#> 83 -0.72738353 -0.086714135 -0.18520217 -0.799513954
#> 84 -0.99683898 -1.176692158 1.22096371 -0.212150532
#> 85 1.07494508 -1.318220727 -0.65801021 -1.185288811
#> 86 -0.41458873 -0.592997366 0.45735733 -0.769484923
#> 87 0.98211300 0.797380501 -1.03813104 -0.082086904
#> 88 0.48361753 -0.913566048 -0.65801021 0.787133614
#> 89 0.20556121 -1.886325159 -0.76460601 1.593369951
#> 90 -2.07848927 -0.653779825 0.39529587 1.655175816
#> 91 -0.49293742 -0.195889249 -0.08291994 0.675762415
#> 92 1.18718681 -0.913566048 0.56204139 -1.074206610
#> 93 -2.07848927 0.886749037 2.68485900 0.454577809
#> 94 -0.78896322 0.333369970 0.27627456 -1.621858259
#> 95 -1.54777654 -0.170639618 -1.56528177 0.313228772
#> 96 2.45806049 0.818828137 -0.70100361 -0.791313879
#> 97 0.48361753 0.388365163 0.24104593 1.070516037
#> 98 -0.09745125 -0.445935027 -0.35245320 -1.421108448
#> 99 0.42057419 0.333369970 0.37114796 -0.522616697
#> 100 -1.61403946 0.647513358 -0.35091783 -0.249190678