I'm after some advice regarding heteroscedasticity in a residuals vs predicted plot.
I have measured the length of a group of animals at birth and then at five subsequent time points into the future. As length is a continuous variable and I have random factors to account for, I have built a set of gaussian GLMM models in the glmmTMB
package. I used AICc to select my most parsimonious model. My most parsimonious model is below, there are no random effects in my final model:
glmmTMB(length ~ time + small_length_at_birth, data = long, family = gaussian)
I created residual plots using the DHARMa
package and it appears that my model residuals are to some extent non-linear and heteroscedastic.
I then log()
transformed length and re-ran my model; I got the same most parsimonious model. When I create residual plots for this new transformed model the qq plot is much better, but the residuals vs predicted values still indicates a problem. My understanding from reading here (the Missing predictors or quadratic effects section) and here (Ben Bolker answer) is that this pattern in residuals vs predicted suggests I may be missing a quadratic effect. I have tried re-running my models with time + time^2
and time + time^2 + time^3
, but neither seems to improve the residuals vs predicted plot.
I have plotted length over time separately for a bunch of individuals (but not all individuals). There is definitely variation in how individual animal's length increases over time, but random intercepts for individual are not supported and random slop for individual will not run for some reason unknown to me.
Does anyone have any suggestions/advice on how else to go about solving problem with heteroscedasticity? I assume this pattern in the residuals is significant enough to not be appropriate to ignore it?
UPDATE I have plotted residuals against each predictor from the second set of models were length is log transformed. Below is the plot for residuals vs time - it appears that the time variable is driving the observed pattern in residuals vs predicted plot (plot 2), however despite this including 'time + time^2' or another quadratic does not solve the problem.
factor(time)
? Also, what is your reason for selecting the most parsimonious model? Random effects are used to account for dependence between measurements, so forgoing a mixed model based on parsimony alone does not seem like a good choice to me. $\endgroup$small_length_at_birth
? A random intercept would already account for baseline differences, and you can then simply include the baseline measurement as the first time point. $\endgroup$small_length_at_birth
, this is something that you could model with a random slope. If what you hypothesize is true, then the random slope will be positively correlated with the random intercept. $\endgroup$