I would like to determine the variance explained by random factors and slopes in a mixed model but am unsure if the analysis I use and my interpretation are correct. Furthermore, comparing models and analysing a mixed model with random slopes seem to give opposite conclusions, therefore I would like to know when to include random slopes? Below I give an overview of the analysis.
I tested three groups of 10 individuals twice in the same task. As I expect individuals to differ in their response across the two tasks, I also include random slopes. The analysis I run is:
lme(behaviour ~ stage * group, random = ~ stage|ID, data=data)
Part of the output I get is the following:
Linear mixed-effects model fit by maximum likelihood Data: data AIC BIC logLik -72.07494 -48.50785 46.03747 Random effects: Formula: ~stage | ID Structure: General positive-definite, Log-Cholesky parametrization StdDev Corr (Intercept) 0.12646601 (Intr) stage2 0.12662159 -0.455 Residual 0.05714907
To calculate the variance I extract the SD of ID, slopes, and the residual variance as follows:
SD.ID <- (fm2$sigma * attr(corMatrix(fm2$modelStruct[])[],"stdDev"))[] SD.slope <- (fm2$sigma * attr(corMatrix(fm2$modelStruct[])[],"stdDev"))[] SD.residual <- fm2$sigma
And then calculate the percentage of variance explained:
In this case this seems to suggest: "individual ID and random slopes explained 40.8% and 40.8% repectively of the variance of behaviour".
Although this seems to suggest the random slopes explain a large part of the variance, it seems perhaps a more simple model without slopes is more appropriate:
fm1 <- lme(behaviour ~ stage * group, random = ~ stage|ID, data=data, method="ML") fm0 <- lme(behaviour ~ stage * group, random = ~ 1|ID, data=data, method="ML") anova(fm0,fm1)
since I get the following output:
Model df AIC BIC logLik Test L.Ratio p-value fm0 1 8 -76.00947 -57.15580 46.00473 fm1 2 10 -72.07494 -48.50785 46.03747 1 vs 2 0.06547599 0.9678
Which to me seems to suggest the model with the random slope does not significantly better fit the data. This seems contrasting to the 40% of the variance that it seems to explain, as shown with the data above.
Furthermore, if I correlate the coefficients from model fm1, thus the intercept with the slope:
I get the following output:
Pearson's product-moment correlation data: fm1$coefficients[][][, 1] and fm1$coefficients[][][, 2] t = -2.6802, df = 37, p-value = 0.01092 alternative hypothesis: true correlation is not equal to 0 95 percent confidence interval: -0.6376166 -0.1004855 sample estimates: cor -0.4032186
Which thus seems to suggest that individuals with lower initial behaviour scores change more in their behaviour over time. Therefore again I would think running the model with the slopes would make the most sense.
Thus, to repeat my question: how can I determine the variance explained by random factors and slopes in a mixed model and when do I know when to include random slopes?