You are correct that a mixed model can be used here.
You are also correct to specify random intercepts for test
, although some would argue that 5 is insufficient to model it as random. There is no clear answer to this, but it would appear that the tests can be thought of as coming from some wider population of tests, so it is appropriate to fit such a model in the first instance. The reason for specifying random intercepts here, is that the results for each test are likely to be more similar to each other than to other tests. That is, the results within each test will be correlated. A mixed model with random intercepts is one way to control for this. The alternative to this is to include test
as a fixed effect, and you might want to fit different models, treating test
as fixed or random, and compare the results.
However you also have repeated measurements within subjects, so you need to allow for this, for the same reasons as for test
.
You have also specified random slopes for status, age and gender, as well as fixed effects for these. What this means is that you want to estimate a fixed effect, but you also want this effect to vary for each test. So, the software will also estimate a variance for these random effects. You should ask yourself whether this actually makes sense, and whether or not you want to estimate these variances, or just an overall estimate (ie, just a fixed effect). Also, note that while it is fine to specify random slopes over levels of the test
factor (subject to the forgoing caveats), it is not at all fine to specify random slopes for these variables over levels of subjects, as noted in the answer by @ErikRuzek because these variables do not vary by subject. Doing so should actually produce an error, or a warning of a singular fit if you tried to do so.
Additionally, most software will assume that random effects follow a multivariate normal distribution and will also estimate the correlations between them. Depending on how many subjects are in your sample, the data may not support such a complex random structure.
I would therefore suggest the following model:
value ~ status + age + gender + (1 | test) + (1 | subject)
You might also want to allow for a non linear effect of age, by fitting higher order terms, or splines, and you might also want to allow for interactions between age, status and gender.
Finally, note that the fixed effects in a mixed model are generally conditional on the random effects, so the estimates are for the same test, not averaged over all tests. You might want the average effect (marginal effect) instead, and if so you need to choose software which can do this (eg the GLMMadaptive
package in R.)