Solved – How to adress problems of heteroscedasticity in mixed model analysis

heteroscedasticitylme4-nlmemixed model

I am analizing pupil size data using mixed model analysis in R. I use lme() from package nlme. However, I am encountering serious problems of heteroscedasticity and violation of normality assumption.
enter image description hereenter image description here
Do you have any suggestions on how to solve this problem?

I would like to test whether active neurostimulation (vs. control; Stimulation) increases pupil size over time (before stimulation vs. end stimulation; Time). We employed a between subject design.

I adopted the following strategies that did not solve the problem: 1. transformed the outcome – log(). 2. modelled the covariance-variance matrix following the instructions in this page https://rpsychologist.com/r-guide-longitudinal-lme-lmer#heteroscedasticity-at-level-1 .

Here the models:
Here the models:
Time (0 vs . 1)
Stimulation (0 vs 1)
Tonic_PS = pupil size
ID = participant ID

model.1 <- lme(Tonic_PS ~ Time * Stimulation,,
random = ~ Time|ID,
weights = varIdent(form= ~ 1 | Stimulation),
data =Tonic_pupilsize_T2,
method = "ML")

model.2 <- lme(Tonic_PS ~ Time * Stimulation,
random = ~ Time|ID,
weights = varIdent(form= ~ 1 | Stimulation * Time),
data =Tonic_pupilsize_T2,
method = "ML")

model.3 <- lme(Tonic_PS ~ Time * Stimulation,
random = ~ Time|ID,
correlation = corAR1(),
data =Tonic_pupilsize_T2,
method = "ML")

model.4 <- lme(Tonic_PS ~ Time * Stimulation, random = ~ Time|ID, 
weights= varIdent(form= ~ 1 | Time),
correlation = corAR1(),
data =Tonic_pupilsize_T2,
method = "ML")

Any suggestion will be very appreciated!

Best Answer

Rather than transforming data to fit a model, I suggest using a model that fits the data.

Quantile regression does not assume homoscedasticity and quantile regression for multilevel (or mixed) models now exists. There is an R package lqmm available from CRAN that should work.