The helper make.calltype() creates a vector that identifies per block if
the imputation model is taken from predictorMatrix or formulas. The
function is used internally by mice().
Arguments
- calltype
A character vector of length equal to the number of blocks in
predictorMatrix. Each element specifies how the imputation model for the corresponding block is defined. Valid values are"pred"and"formula". IfNULL, the calltype will be"pred"for all blocks, unlesspriorityis"formula".- predictorMatrix
A matrix specifying the predictors for each block. Each row corresponds to a block, and each column corresponds to a variable. Non-zero entries indicate that the variable is used as a predictor for the block.
- formulas
A list of formulas, where each element corresponds to a block in
predictorMatrix. If a formula is provided for a block, the correspondingcalltypeentry is set to"formula". IfNULL, formulas are not used to modifycalltype.- priority
A character string specifying the default value for
calltypewhen it isNULL. Defaults to"pred". Ifpriority == "formula", the calltype will be"formula"for blocks found informulaswith a matching name.
Value
A character vector of length equal to the number of rows in predictorMatrix.
Each element is either "pred" or "formula", indicating how the imputation model
is specified for the corresponding block.
Examples
# Example predictorMatrix
predictorMatrix <- matrix(1, nrow = 3, ncol = 3,
dimnames = list(c("block1", "block2", "block3"), c("x1", "x2", "y")))
predictorMatrix[1, 3] <- 0
# Case 1: No calltype or formulas specified
make.calltype(NULL, predictorMatrix, NULL)
#> block1 block2 block3
#> "pred" "pred" "pred"
# Case 2: Formulas provided
formulas <- list(
NULL,
y ~ x1 + x2,
NULL
)
make.calltype(NULL, predictorMatrix, formulas)
#> block1 block2 block3
#> "pred" "pred" "pred"
# Case 3: Custom calltype
calltype <- c("pred", "formula", "pred")
make.calltype(calltype, predictorMatrix, NULL)
#> block1 block2 block3
#> "pred" "formula" "pred"
