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


By treating time as a categorical variable in this situation, you ensure that there is no constraint in your model between the effect of the two time periods.  This is generally preferable when you have enough data to do so, since it allows greater flexibility in the model.  The boxplot you show in your question makes it clear that the effect of time is nonlinear, so the categorical approach will capture this well.  As to the computational problem you are having, since you haven't told us anything about how much data you have in the categories, we can't possibly help.
