This helper function creates a valid predictMatrix. The
predictorMatrix is an argument to the mice function.
It specifies the target variable or block in the rows, and the
predictor variables on the columns. An entry of 0 means that
the column variable is NOT used to impute the row variable or block.
A nonzero value indicates that it is used.
Usage
make.predictorMatrix(data, blocks = make.blocks(data), predictorMatrix = NULL)Details
Rows of variables without missing data also get predictors. These rows
are not used by default, because there is nothing to impute, as the
empty method from make.method() shows. They are used if
the where argument of mice() asks to impute
observed values, e.g. for over-imputation or synthetic data. A row
without predictors then gives an intercept-only imputation model, which
mice() writes to loggedEvents.
Examples
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
make.predictorMatrix(nhanes, blocks = make.blocks(nhanes, "collect"))
#> age bmi hyp chl
#> collect 1 1 1 1
