I want to perform Little's MCAR Test to evaluate missing data pattern with a dataset of 36 Variables (metric, ordinal, nominal) and 106 observations.
I get the following error applying little MCAR test in R with Naniar package:
mcar_test(myData)
Error: Problem with
mutate()
columnd2
.i
d2 = purrr::pmap_dbl(...)
. x system is computationally singular:
reciprocal condition number = 9.76219e-17i The error occurred in
group 1: miss_pattern = 1. Runrlang::last_error()
to see where the
error occurred.In addition: Warning message: In
norm::prelim.norm(data) : NAs introduced by coercion to integer range
When I exclude certain variables (A,B,C, D, E) it works.
Here's my code for the relevant Variables:
#packages (tidyverse, broom, robustbase, readxl, ggThemeAssist, knitr, MASS, rmarkdown, devtools, naniar)
#A (ordinal variabel) myData <- myData %>% mutate(A = factor(A, ordered = TRUE,
levels = c(0, 1, 2, 3, 4, 5, 6), labels = c("no Attempt", "1th" , "2nd", "3rd",
"4th", "5th", "6th and more")))
myData$A[myData$A==-999] <-NA
#B (metric variabel, time variabel in hours)
myData$B <- as.factor(myData$B)
myData$B[myData$B==-999] <-NA
#C (metric variabel, time variabel in hours)
myData$C <- as.factor(myData$C)
myData$C[myData$C==-999] <-NA
#D (ordinal variabel)
myData <- myData %>%
mutate(D = factor(D, ordered = TRUE, levels = c(0, 1, 2, 3, 4), labels = c("0",
"1" , "2a", "2b", "3")))
myData$D[myData$D==-999] <-NA
#E (kategorial variabel)
myData <- myData %>%
mutate(E = factor(E, levels = 0:1, labels = c("no", "yes")))
myData$E[myData$E==-999] <-NA
dput(mydata[1:10, 1:5])
structure(list(A = structure(c(1L, 1L, 1L, 2L, 2L, 1L, 1L, 2L,1L, 2L), .Label =
c("no Attempt", "1th", "2nd", "3rd", "4th",
"5th", "6th and more"), class = c("ordered", "factor")), B = structure(c(36L,
35L, 42L, 38L, 20L, 17L, 40L, 27L, 44L, 39L), .Label = c("-999",
"0.07", "0.09", "0.11", "0.16", "0.18", "0.21", "0.22", "0.3",
"0.32", "0.33", "0.38", "0.39", "0.4", "0.41", "0.43", "0.44",
"0.47", "0.5", "0.51", "0.55", "0.59", "1", "1.12", "1.13", "1.15",
"1.18", "1.28", "1.35", "1.37", "1.39", "1.45", "1.49", "1.55",
"1.57", "2.02", "2.03", "2.24", "2.26", "2.33", "2.41", "3.28",
"3.54", "6.25", "6.32", "23.3"), class = "factor"), C = structure(c(NA,
19L, 53L, NA, NA, 42L, NA, 5L, 13L, 10L), .Label = c("-999",
"0.15", "0.48", "0.54", "1", "1.1", "1.13", "1.15", "1.16", "1.2",
"1.25", "1.28", "1.3", "1.39", "1.41", "1.43", "1.45", "1.52",
"1.8", "2", "2.3", "2.35", "2.45", "2.48", "2.5", "3", "3.15",
"3.28", "3.29", "3.53", "3.55", "4", "4.02", "4.09", "4.2", "4.31",
"4.47", "5", "5.14", "5.47", "6", "6.3", "6.45", "7.2", "7.21",
"7.56", "7.58", "10", "10.05", "10.11", "11.14", "11.51", "12",
"12.13", "15", "16.14", "19.32", "22.11", "24", "25.52", "32.3",
"42", "48", "53", "70", "72", "96"), class = "factor"), D =
structure(c(5L,
3L, 3L, 5L, 5L, 3L, 3L, 4L, 3L, 5L), .Label = c("0", "1", "2a",
"2b", "3"), class = c("ordered", "factor")), E = structure(c(2L,
2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 1L), .Label = c("no", "yes"), class =
"factor")),
row.names = c(NA,
-10L), class = c("tbl_df", "tbl", "data.frame"))
Any advice?
M.