I have repeated measures data for some patients. Each patient is measured 3 times, but data can be missing in each measurement since some patients can be lost to followup or not show up for appointments.
I’d like to impute the missing data using mice. I understand I need to specify a prediction matrix, and I do this with the following code:
library(mice)
library(ggmice)
library(lme4)
pred <- quickpred(model_data)
pred[c('vit_d', 'ask_score', 'eq_vas'), 'patient'] <- -2
ggmice::plot_pred(pred)
Here, vit_d
, ask_score
, and eq_vas
are the only variables which have missing data. The patient
variable is the class variable, so I set the cells for the aforementioned variables to -2.
Now, when I try to use mice, I get the following error
Error in str2lang(x) : <text>:1:53: unexpected ')'
1: dv._lmer ~ 1+time+ask_score+eq_vas+age+weight_kg+(1|)
^
While I can’t be certain, it looks like mice is trying to use lmer, but it can’t specify a random effect because no random intercept is specified (the (1|)
term).
Have I correctly set up the call to mice? If so, what is wrong?