Cross-posting from stackoverflow
I am working with a dataset having the following structure (download data here).
The variable resp is a physiological response measured once for every subject during the study. In the study, each subject was observed for 5 days at 10 time points. The variables vala, valb, valc, vald are the observed values that indicate the percentage of time a subject spent performing a particular activity (I am not using the activity variables directly but a transformed-version of the variables. The transformation is performed using the R package compositions). Grp (5 groups), sbjt (10 subjects), dy (5 days), tm (10 time points) are factors.
library(compositions) # for the function ilr()
sim[10:12] <- ilr(sim[6:9]) # transforming the activity variables
I am interested in fitting a mixed-effects model with grp as fixed effect (because I am specifically interested in the groups that I have selected for the participants) and sbjt, dy, tm as random effects (because I am not specifically interested in the subjects that I have chosen and wish to generalize to the study population; day and time are random because different subjects were observed at different days and different times). The times are nested within days, which in turn, are nested within subjects (tm within dy within sbjt). I believe the model is appropriate for understanding the amount of variance my activity variables and random effect variables are contributing to my resp variable.
In nlme::lme(), I have specified my model as follows with subject autocorrelation:
library(nlme) # for the function lme()
model <- lme(resp ~ V1 + V2 + V3 + grp, random = ~ 1 | Sbjt/dy/tm, correlation = corAR1(), method = "REML", data = sim) # V1, V2, V3 are the transformed activity variables
# Error in solve.default(estimates[dimE[1] - (p:1), dimE[2] - (p:1), drop = FALSE]) :
system is computationally singular: reciprocal condition number = 1.24056e-17
I have the following questions about my model:
- Is it possible to fit a mixed-effects model with only 10 response values (another post seemed to suggest that running a mixed-model is not appropriate in such situations)? If possible, how do I get the above model to run? If not, what other models should I use instead?
- Could someone explain what the above error is telling me and how to correct it?
- If the 3-level nesting in my model is too complex, how do I simplify it so that my model runs?
I am also open to any other suggestions about the best way to model my data in nlme::lme() since I would like to specify subject autocorrelation. Thank you for your time and help! I greatly appreciate it!