generate_patterns | R Documentation |
Generate all possible missing patterns in a multivariate data set. The function
can be used to complement the function ampute()
from package mice
in which a matrix of patterns is needed to allow for general missing-data
patterns with missing-data mechanism missing at random (MAR). Using this
function, each observation can have more than one missing value.
generate_patterns(d)
d |
The number of variables or columns of the data set. |
An observation cannot have all values missing values. A complete observation
is not qualified for missing-data pattern. Note that a large value of d
may
result in memory allocation error.
A matrix where 0 indicates that a variable should have missing values
and 1 indicates that a variable should remain complete. This matrix has d
columns and 2^d - 2
rows.
generate_patterns(4)
#++++ To use with the function ampute() from package mice ++++#
library(mice)
patterns_matr <- generate_patterns(4)
data_missing <- ampute(iris[1:4], prop = 0.5, patterns = patterns_matr)$amp
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.