For analysis of a longitudinal data with repeated measures, should you use continuous or categorical variable for time? I have performed a study over 6 months: measuring pain between two groups of patients at baseline, and at 3 and 6 months after an intervention.
I am performing a LMM analysis: but just now getting confused if I should use time as a categorical variable (ordered or non-ordered) or a continuous variable.
If I use the former (categorical factor), and try the following for a random slope, intercept using R:
pain ~ 1 + intervention*interval + (interval|subject)

I get an error that the number of observations is smaller than number of random effects.
Any help appreciated: the more I read, the more confused I become.
EDIT: Included image of boxplot of scores against time, per study group


With your categorization of time, you presumably have the pre-intervention time as reference and 2 time-associated coefficients representing the other 2 time categories (3 and 6 months). With your mixed model for fixed effects you are modeling an intercept, an intervention coefficient, 2 time coefficients, and 2 intervention:time interaction terms. With a random intercept and 2 random time coefficients, you are also effectively estimating the individual differences of those 3 values from the corresponding fixed-effect values. Yet you only seem to have 3 observations per individual. Hence your problem with too few observations.
There are a few ways to proceed.
First, you could try to use continuous time as a simple linear predictor and maintain the random slopes. But even if that doesn't throw an error you are then assuming that the effects of time on outcome are linear, other things being equal. That might not be a good assumption.
Second, you could continue with the mixed model and time categories but not include random slopes.
Third, you could use a different way to handle the repeated measures. With a simple design like this you could use repeated-measures multivariate ANOVA or generalized least squares instead. Chapter 7 of Frank Harrell's course notes or book outlines different approaches to repeated-measures data like yours, with an emphasis on generalized least square.
