Fixed/Random Variable Inputs
There's nothing stopping you from adding any number of variables that were measured at baseline. If this measure was also repeated, then you would need to code that into your regression in some way that incorporates the repeated measurements across time, but for the purpose of this question that doesn't seem to be an issue. So adding in z
or covariate
can be done straightforwardly and will partial out the unique variance of the response attributed to that effect after controlling for your other predictors. Whether those should be modeled as an interaction depends on whether or not you believe that is theoretically justifiable. Do you believe the two combined influences of these variables changes how the response looks? If so, you can use an interaction (the *
operator), otherwise it doesn't need to be added by default.
As to the random effects portion of your question, it depends on if you believe the main effects or interaction will vary by person. However, random slopes are already difficult to fit if the data doesn't support it (e.g. the by-subject slopes don't vary at all) and are even more difficult to fit with interactions. I would start off fitting a random intercepts-only model first, see if that fits without error messages, then build up to more complicated random effects if present or justifiable (such as uncorrelated slopes, then correlated slopes). The three references below discuss how you code random effects and what the rationale should be for fitting random effects, which includes commentary on fitting simpler models before building up from there.
References
Coding Random Effects:
On Simple vs Maximal Models:
- Matuschek, H., Kliegl, R., Vasishth, S., Baayen, H., & Bates, D. (2017). Balancing Type I error and power in linear mixed models. Journal of Memory and Language, 94, 305–315. https://doi.org/10.1016/j.jml.2017.01.001
Best Practices for Fitting:
- Meteyard, L., & Davies, R. A. I. (2020). Best practice guidance for linear mixed-effects models in psychological science. Journal of Memory and Language, 112, 104092. https://doi.org/10.1016/j.jml.2020.104092