I've read the threads on some similar topics but I'm not positive that they address the issue that I'm having. I am conducting analysis on a data set investigating the factors that predict whether or not patients have had an exam (binary outcome variable, so I'm using logistic regression). One of the prediction factors is the implementation of an intervention (dichotomous, between-subjects predictor), and I want to see if this intervention was effective across pre-post measures (dichotomous, within-subjects predictor). Patients are nested within doctors, and it is actually the doctors that are either part of the intervention or not. Ultimately, I want to examine the interaction effect of the intervention x time, with the hypothesis that the change in proportion of exams completed (from pre to post) will be higher in the intervention group compared to the control group. I'm trying to run this analysis in R using the glmer package, but I'm not quite sure how to set it up correctly. If these are my variables:
intervention(dichotomous, between subjects)
Doctor(nominal, doctor name)
I essentially want to do:
outcome ~ intervention + time + intervention:time
but I want time to be within ID, and I also want to allow random intercepts and slopes by Doctor.
outcome ~ 1|Doctor + intervention + time|ID + intervention:time
But this gives me errors about a model frame, formula mismatch in R.
I can't share the data because of publicly identifiable information, but I'm stuck and was hoping somebody could help point me in the right direction.