md.pattern2: Display missing-data patterns

Description Usage Arguments Details Value Author(s) References Examples

View source: R/md.pattern2.R

Description

md.pattern2 displays missing-data patterns

Usage

1

Arguments

x

a data frame

Details

This function displays missing-data patterns. md.pattern in library(mice) is extended to sort variables.

Value

Return a matrix with ncol(x) + 1 columns, in which each row corresponds to a missing data pattern (1 = observed, 0 = missing). Rows and columns are sorted in increasing amounts of the sample sizes. The last column and row contain row and column counts, respectively. The row name contains the sample sizes in the specific missing data patterns.

Author(s)

Yasuyuki Okumura
Department of Social Psychiatry,
National Institute of Mental Health,
National Center of Neurology and Psychiatry
yokumura@blue.zero.jp

References

Iwasaki M (2002) Foundations of incomplete data analysis (in Japanese) Tokyo: EconomistSha Publishing.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
##Iwasaki (2002)
dat <- data.frame(matrix(c(
71  ,  68,  72,  72,  90,  72,  77,  76,  84,  77,
1850,2000,2100,1700,  NA,2200,2150,  NA,  NA,  NA,
136 , 139, 147, 142,  NA, 150, 156,  NA, 152,  NA,
34  , 45 ,  50,  38,  NA,  41,  43,  52,  57,  48
), ncol=4))
md.pattern2(dat)


#sample sizes in the specific pattern
#^
#^               numbers of missing data in each pattern
#|                ^
#|                |
#    X2 X3 X4 X1 NA
#6    1  1  1  1  0
#2    0  0  1  1  2
#1    0  0  0  1  3
#1    0  1  1  1  1
#Sum  4  3  1  0  8 --> numbers of missing data in each variable

rpsychi documentation built on May 29, 2017, 12:57 p.m.

Search within the rpsychi package
Search all R packages, documentation and source code