How do I test the assumption Missing At Random (MAR) in R?
Below are example data with code for testing completely missing at random (CMAR), and as well as imputation of missing data (which however assume MAR).
# Example Questionnaire data
set.seed(1)
Q1 <- sample(c(1:10, NA), 100, replace = TRUE)
Q2 <- sample(c(1:10, NA), 100, replace = TRUE)
Q3 <- sample(c(1:10, NA), 100, replace = TRUE)
Q4 <- sample(c(1:10, NA), 100, replace = TRUE)
questionniare <- tibble(Q1, Q2, Q3, Q4)
# Test Completely Missing at Random
naniar::mcar_test(questionniare)
# Plot number of missing values across variables
naniar::gg_miss_var(questionniare)
### How do I test for Missing at Random (MAR)?
# (Impute Missing values)
questionniare_imp <- mice::complete(mice::mice(questionniare), action="long")
Try Logistic Regression: With respect to testing of MAR, we can create a binary variable that represents whether the data is missing(1) or not missing(0).
Modify sample code as per your requirements
OUTPUT
Hope this helps !