# Treatment (equivalent to experimental groups) in Experiment as Fixed AND Random Effect in Mixed Model Linear Regression

I have data from a sociology experiment with three groups. Each group is equivalent with a different treatment for a subject (n=700). The treatment were surveys, differing in the amount of information provided (info=0/1) and the response format (single vs multiple choice, choice=0/1). Group 1 (info = 0, choice = 0), Group 2 (info = 1, choice = 0), and Group 3 (info = 1, choice = 1) are coded as group (1-3) or alternatively the dummys info and choice. It should be noted that group 1 to 3 is also expressing ordinal degree of complexity of the treatment. From the responses of the treatment surveys I calculated the quality of the response (=y). This is the response variable I am interested in. Moreover, I have several information on the subjects, such as age (age), level of education (edu), level of trust (trust), and the time they spend "filling out" the treatment (time). I am now mostly interested in the effect of the treatment:
y ~ group.

Yet, I want to include "random" factors as level of education, age etc in the model. As said, treatment in group 3 is more complicated than in 1, thus I expect to have "edu" a different effect among the groups. Similarly, i also expect "time" to have different implication for the different groups: e.g., the leverage of spending time in group 3 for increasing y is much greater due to the more information and more complex response options. At the same time, time is also correlated with the treatment - "info" and ”choice" provide incentives for subjects to engage longer. Additionally, I expect education to have an interaction effect with "time" (which again should differ between the treatment groups). Also, old subjects (going into the high eighties) can be expected to be slower in general, providing another contextual variable.

I am not sure how to construct a lmer model correctly. My idea is:
y ~ group + (time/edu/age | group)

I also tried a model without "group" as the grouping factor after reading other threads.
E.g., y ~ group + (group/edu | time)

However, I receive either a singular fit warning - even when only including the random effects. Sometimes I receive also "maxfun < 10 * length(par)^2 is not recommended." warnings. I assume, there is something wrong with my model, as n=700 should provide enough data. Does anyone have a suggestion?

UPATE BASED ON COMMENT:
group: 3 levels
edu: 8 levels
time: log transformed duration in seconds
age: number of years

• Are you sure you are in a mixed effects modelling setting? There doesn't seem to be any indication from your post that the subjects in each treatment group were followed repeatedly over time and asked to fill in the same survey at multiple time points. Also, you only have 3 treatment groups and those are the only ones you are interested in, so you can't have something like (...|group), which would assume the 3 groups are representative of many more groups that were not included in your study. – Isabella Ghement Jan 30 at 23:25
• So you really need to clarify what "time" is in your study and what it consists of. I assume education (edu) consists of a small set of known levels (e.g., high school, graduate, post-graduate), so you shouldn't treat it as a random grouping factor. Again, those education levels are the only ones you are interested in. If you categorize age (e.g., young vs mature vs old), then you can't treat age as a random grouping factor since you included all categories you are interested in in your study. If age will be treated as continuous, it obviously cannot be a (random) grouping factor. – Isabella Ghement Jan 30 at 23:30
• How you specify your model will depend on how many time points you have to work with for each subject. If all subjects complete their surveys just once, then you are not in a mixed effects setting. If some or all of the subjects complete their surveys multiple times, then you are in a mixed effects modelling setting. – Isabella Ghement Jan 30 at 23:32
• I agree with @IsabellaGhement "I want to include "random" factors as level of education, age etc in the model". - these should be fixed effects, not random. Same for time. If you are interested in the fixed effect of group then it makes no sense to also include it as random. Besides, you have only 3 groups and this is insufficient to warrant modelling it as random. – Robert Long Jan 31 at 13:19
• Thanks a lot for your feedback! Then I misunderstood the concept. Just as a follow up question: For some subjects I have two measurements of y. I assume there it would make sense to update the model with 1|subject? – Jonathan Raphael Feb 1 at 12:58