I am trying to do multiple imputation using the mice package in R for multilevel models. i am following the steps listed out in here and here to set up my predictor matrix. however, the examples provided only include not more than 7 variables in the dataset for the predictor matrix. How can I do it when I have many variables in the dataset?
Do I have to repeat this (see below- pred) for every variable that I want to impute? (total of 19 variables, and 4 dummy variables) it seems extremely tedious..
#create imputation model for Race_R
pred["Race_R", c("a","SchlPre","c", "Age",
"Gender","Race_R", "Ethnicity","EnrDipType",
"DemHHInc_Rnum","IQ","ABC_SS","d",
"SD","GASEndMnAcad","wj3","a1","a2",
"DemHHIncx","DemHHIncy")] <- c(0, -2, 1, 1, 1, 0, 1, 1, 1,1,1,1,1,1,1,0,0,0,0)
Also i tried to run the imputation with
imp <- mice(data, pred = pred, meth = impmethod, seed = 919,
m = 10, print = FALSE)
but ended up with a bunch of boundary (singular) fit: see help('isSingular'), and no imputation data was generated. How can i troubleshoot this? thanks!!