Modeling linear mixed regression in R - repeated measure and choosing random & fixed effects Thank you for your time and help with this. I know the topic has been discussed many times before but I still cannot incorporate previous answers and suggestions fully into my study.
My study is looking at whether there is an association between different metabolites and a surrogate marker. There are 130 participants (subject), 3 groups (group), 5 time points (time), and 5 metabolites (met1, met2, ..., met5), and 1 response (resp). I am also trying to account for covariates such as gender, race, etc.
Some caveats are that grp1 only has measurements for the first 3 time points and there are some missing measurements. In addition, some of the metabolites change over time and some do not. Some metabolites correlate with each other as well.
My attempt at modeling this in R using the lme4 package, starting with just one metabolite at a time, is:
lmer1 <- lmer(resp ~ met1 * time + gender + sex + group + (1|subj), data = data)

The things I am trying to figure out are:

*

*Are my choices for fixed and random effects appropriate? In particular, should I be including time as nested within each subject (e.g. (1|subject/time)) or as a cross random effect (e.g. (1|subject) + (1|time))? If I suspect subjects in each group are more similar to each other, then would the random effect term be: (1|group/subject)?


*I am trying to model random intercepts and random slopes, do I add the parameter of interest (i.e. met1) in to both random effect terms (if doing the cross random effect as above) or just the one it correlates with (e.g. (met1|subject) or (met1|subject) + (met1|time)?
There are a ton more I'm trying to figure out as I just started teaching myself stats and coding. But these are the big concepts I'm trying to figure out.
Again, thank you for any inputs!
 A: 
In particular, should I be including time as nested within each subject (e.g. (1|subject/time)) ?

This specifies that each level of the time variable occurs in one and only one level of subject (ie. time is nested within subject) and that does not appear to be the case according to your description. You are already including time as a fixed effect so it would not make sense to include it as grouping variable in the random effects anyway.

or as a cross random effect (e.g. (1|subject) + (1|time))?

As just mentioned, you are already including time as a fixed effect so it would not make sense to include it as grouping variable in the random effects, and with only 5 time points it would not be advisable to model it as random rather than fixed.

If I suspect subjects in each group are more similar to each other, then would the random effect term be: (1|group/subject)

This specifies that each subject occurs in one and only one level of group which might be true, however to model group as random you would need more than 3 of them. Including group as a fixed effect will control for the possible correlations within it.

I am trying to model random intercepts and random slopes, do I add the parameter of interest (i.e. met1) in to both random effect terms (if doing the cross random effect as above) or just the one it correlates with (e.g. (met1|subject) or (met1|subject) + (met1|time)?

As mentioned above it doesn't make sense to treat time as a random effect here.
When you fit random slopes you are letting the fixed effect for the variable in question vary among the subjects. Since met1 has 5 levels, this will be quite a complex random structure. If the theory indicates that random slopes are warranted, then go ahead and try to fit them, but don't be surprised if you get a singular fit.
Note that in longitudinal models, it is often a good idea to fit time as a random slope, if the data supports such a model.
