R: Creates a 'blocks' argument

make.blocks {mice} | R Documentation

## Creates a `blocks` argument

### Description

This helper function generates a list of the type needed for `blocks` argument in the `[=mice]{mice}` function.

### Usage

    make.blocks(
      data,
      partition = c("scatter", "collect", "void"),
      calltype = "type"
    )

### Arguments

`data` | A `data.frame`, character vector with variable names, or `list` with variable names.
`partition` | A character vector of length 1 used to assign variables to blocks when `data` is a `data.frame`. Value `"scatter"` (default) will assign each column to it own block. Value `"collect"` assigns all variables to one block, whereas `"void"` produces an empty list.
`calltype` | A character vector of `length(block)` elements that indicates how the imputation model is specified. If `calltype = "type"` (the default), the underlying imputation model is called by means of the `type` argument. The `type` argument for block `h` is equivalent to row `h` in the `predictorMatrix`. The alternative is `calltype = "formula"`. This will pass `formulas[[h]]` to the underlying imputation function for block `h`, together with the current data. The `calltype` of a block is set automatically during initialization. Where a choice is possible, calltype `"formula"` is preferred over `"type"` since this is more flexible and extendable. However, what precisely happens depends also on the capabilities of the imputation function that is called.

### Details

Choices `"scatter"` and `"collect"` represent to two extreme scenarios for assigning variables to imputation blocks. Use `"scatter"` to create an imputation model based on fully conditionally specification (FCS). Use `"collect"` to gather all variables to be imputed by a joint model (JM). Scenario's in-between these two extremes represent hybrid imputation models that combine FCS and JM.

Any variable not listed in will not be imputed. Specification `"void"` represents the extreme scenario that skips imputation of all variables.

A variable may be a member of multiple blocks. The variable will be re-imputed in each block, so the final imputations for variable will come from the last block that was executed. This scenario may be useful where the same complete background factors appear in multiple imputation blocks.

A variable may appear multiple times within a given block. If a univariate imputation model is applied to such a block, then the variable is re-imputed each time as it appears in the block.

### Value

A named list of character vectors with variables names.

### Examples

    make.blocks(nhanes)
    make.blocks(c("age", "sex", "edu"))

[Package mice version 3.8.0 Index]