amices / mice

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

Default behavior of `make.predictorMatrix()` outputs `1`s for complete variables #602

Open hanneoberman opened 1 year ago

hanneoberman commented 1 year ago

The behavior is inconsequential, but might confuse users. I would suggest adding an argument that takes care of this (or change the behaviour altogether, but I don't think that's necessary)

library(mice)
make.predictorMatrix(nhanes)
#>     age bmi hyp chl
#> age   0   1   1   1
#> bmi   1   0   1   1
#> hyp   1   1   0   1
#> chl   1   1   1   0
quickpred(nhanes)
#>     age bmi hyp chl
#> age   0   0   0   0
#> bmi   1   0   1   1
#> hyp   1   0   0   1
#> chl   1   1   1   0

Created on 2023-11-21 with reprex v2.0.2

stefvanbuuren commented 1 year ago

Would setting the first row of quickpred(nhanes) to 0, 1, 1, 1 be appropriate?

hanneoberman commented 1 year ago

I was thinking the other way around: setting the first row of make.predictorMatrix(nhanes) to 0s if the user requests it (with an additional argument).

In my opinion, the predictor matrix should reflect which predictor variables are used to impute the target variable. So if there is nothing to impute, there should not be any predictors set. Although I do see how this suggested behaviour should not be the default, e.g. for over-imputing observed data.