I have data from two eyes that have been repeatedly measured across time (5 time points) for their intraocular pressure (IOP). Various measurements were taken including categorical and continuous data. Not all patients have both eyes eligible for the study, so there is a mixture of patients, some with 1 and some with 2 eyes. Covariates assesed at baseline include age, gender, corneal thickness and other parameters that vary between eyes of each participant.
I have formatted the data so that there are additional rows for each eye and rows for each measurement across time. I also want to investigate the interaction effect between CornealThickness and Time, as well as Gender and Time.
Is the following the correct specification of the model in R, specifically unsure how nesting should be specified:
lmer(IOP ~ Age + Gender + CornealThickness + as.factor(Time) + Gender*as.factor(Time) + CornealThickness*as.factor(Time) + (1|ID/Eye), data=data)
Alternatively, would it be the following:
lmer(IOP ~ Age + Gender + CornealThickness + as.factor(Time) + Gender*as.factor(Time) + CornealThickness*as.factor(Time) + (as.factor(Time)|ID/Eye), data=data)
UPDATE: I have tried to run the mmrm model on this dataset:
m1 <- mmrm::mmrm( formula = IOP ~ age + eye_visit +diabetes_duration+ us(eye_visit | id), data = data, control = mmrm_control(method = "Kenward-Roger") )
However I get the following error message:
Problem with these data entries: y_vector 5 Error in fit_single_optimizer(formula = formula, data = data, weights = weights, : Only numeric matrices, vectors, arrays, factors, lists or length-1-characters can be interfaced
What does this mean?
Thank you!
Time
as a factor instead of continuous? $\endgroup$