I want to evaluate the effectiveness of a psychological intervention in a RCT. My study consists of 150 subjects. Half of them were assigned to the intervention group. They are nested within three therapists. The data consists of four measurement points for every subject. I want to modell a linear mixed model using the R nlme software. I want to predict treatment outcome by treatment condition and time. However, I found out that residuals differ across the measurement points which I assume to be heteroskedasticity. I used the following formula for testing for heteroskedasticity (sosci is my df and HLM my model):
sosci$residualsOutcome<- residuals(HLM)
sosci$abs.residualsOutcome <- abs(sosci$residualsOutcome)
sosci$residuals2Outcome <- sosci$abs.residualsOutcome^2
levene1 <- lm(residuals2Outcome ~ Time, data =sosci)
levene2 <- lm(residuals2Outcome ~ Treatment, data =sosci)
anova(levene1)
anova(levene2)
The anova than indicated that residuals might differ between the measurement points (p<.01). Additionally, I tried to plot the residuals, I hope I used the right code:
plot(HLM)
The plot looks okay to me; still, I am concerned about the results of the anova. I might have misunderstood something. I was wondering wether this does matter at all as Linear mixed Models do not demand for Sphericity. I am not good at statistics at all, but I was wondering wether heteroskedasticity across measurement points could be considered to be the same as no sphericity, which would mean that I could simply ignore it.
ANother idea was to account for this problem by using the weight
function in nlme. I thought about this correction, but it might be wrong:
HLM <- lme(outcome~ Treatment*Time, random = ~1|Therapist/subject,
data = sosci, weights = varIdent(form = ~1|Time),
method = "ML", na.action = na.exclude)