# Complex level 1 variance mixed effects models in R

Take this mixed effects model in R:

$y_i = \beta_0 + \beta_1X_{ij} + u_{j} + e_{ij}$

where $u$ is a random effect (level 2 residual) with groups $j$. It is possible to allow the variance of $e_{ij}$ (level 1 residuals) to be a function of $X$. This could potentially result in a 'fanning out' or 'fanning in' of level 1 residuals within each group $j$.

Is it possible to implement this 'complex level 1 variance' mixed effects model in R? Does lme4 allow it?

(Stack Overflow doesnt appear to allow LaTeX formatting of mode formula so I've asked this question here)

lme4 does not offer possibility to model variance components, however it is possible with nlme package, where you can define different variance functions. Check also this answer and the references: Modeling error structure in lmer in R?
• nlme is not older version of lme4, I don't know why it was not implemented in lme4 - you could ask the authors. – Tim Dec 26 '14 at 16:22