Skip to contents

Number of observations per variable pair.

Usage

md.pairs(data)

Arguments

data

A data frame or a matrix containing the incomplete data. Missing values are coded as NA.

Value

A list of four components named rr, rm, mr and mm. Each component is square numerical matrix containing the number observations within four missing data pattern.

Details

The four components in the output value is have the following interpretation:

list('rr')

response-response, both variables are observed

list('rm')

response-missing, row observed, column missing

list('mr')

missing -response, row missing, column observed

list('mm')

missing -missing, both variables are missing

References

Van Buuren, S., Groothuis-Oudshoorn, K. (2011). mice: Multivariate Imputation by Chained Equations in R. Journal of Statistical Software, 45(3), 1-67. doi:10.18637/jss.v045.i03

Author

Stef van Buuren, Karin Groothuis-Oudshoorn, 2009

Examples

pat <- md.pairs(nhanes)
pat
#> $rr
#>     age bmi hyp chl
#> age  25  16  17  15
#> bmi  16  16  16  13
#> hyp  17  16  17  14
#> chl  15  13  14  15
#> 
#> $rm
#>     age bmi hyp chl
#> age   0   9   8  10
#> bmi   0   0   0   3
#> hyp   0   1   0   3
#> chl   0   2   1   0
#> 
#> $mr
#>     age bmi hyp chl
#> age   0   0   0   0
#> bmi   9   0   1   2
#> hyp   8   0   0   1
#> chl  10   3   3   0
#> 
#> $mm
#>     age bmi hyp chl
#> age   0   0   0   0
#> bmi   0   9   8   7
#> hyp   0   8   8   7
#> chl   0   7   7  10
#> 

# show that these four matrices decompose the total sample size
# for each pair
pat$rr + pat$rm + pat$mr + pat$mm
#>     age bmi hyp chl
#> age  25  25  25  25
#> bmi  25  25  25  25
#> hyp  25  25  25  25
#> chl  25  25  25  25

# percentage of usable cases to impute row variable from column variable
round(100 * pat$mr / (pat$mr + pat$mm))
#>     age bmi hyp chl
#> age NaN NaN NaN NaN
#> bmi 100   0  11  22
#> hyp 100   0   0  12
#> chl 100  30  30   0