I am trying to write the mathematical notation for the following mixed effect model:

lmer(Y ~ 0 + A + B + C + (0 + B | A)

With subjects nested in A and a stratified intercept for every A should be estimated. So what I think this means is:
Stratified Intercept for A
Fixed Effect for A, B and C
Varying Random Slope for B

But I struggle to set up the mathematical notation for this formula. My first attempt was this:

\begin{aligned} \operatorname{Y}_{ij} &\sim N \left(\mu_{i}, \sigma^2\right) \\ \end{aligned}

\begin{aligned} E(\operatorname{Y{ij}}) = \beta_{0j}(A) + \beta_{1j} (A) + \beta_{2j} (B) + \beta_{3} (C) + \epsilon_{ij} \end{aligned}

\begin{aligned} E(Y_{ij}) = (\beta_0(A) + \upsilon_{0j}(A)) + (\beta_{1}(A) + \upsilon_{1j}(A)) + (\beta_{2}(B) + \upsilon_{2j}(B)) + \beta_{3}(C) + \epsilon_{ij} \end{aligned}

\begin{aligned} E(Y_{ij}) = \beta_0(A) + \beta_{1}(A) + \beta_{2}(B) + \beta_{3}(C) + \upsilon_{0j}(A) + \upsilon_{1j}(A)+ \upsilon_{2j}(B) + \epsilon_{ij} \end{aligned}

\begin{aligned} \upsilon_{0j} \sim N(0, \tau^2_{\upsilon_{0j}}) \\ \upsilon_{1j} \sim N(0, \tau^2_{\upsilon_{1j}}) \\ \upsilon_{2j} \sim N(0, \tau^2_{\upsilon_{2j}}) \end{aligned}

\begin{aligned} Cov(\sigma^2_{\upsilon_{0j}}, \sigma^2_{\upsilon_{2j}}) = \sigma^2_{\upsilon_{0j}, \upsilon_{2j}} \end{aligned}

\begin{aligned} \left( \begin{array}{c} \beta_{0j} \\ \beta_{2j} \end{array} \right) &\sim N \left( \left( \begin{array}{c} \mu_{\beta_{0j}} \\ \mu_{\beta_{2j}} \end{array} \right) , \left( \begin{array}{c} \sigma_{\beta_{0j}} & \rho_{\beta_{0j}\beta_{2j}} \\ \rho_{\beta_{2j}\beta_{0j}} & \sigma_{\beta_{0j}} \end{array}\right) \right) , for \ A \ j = 1, ...,J \end{aligned}

I really struggle with the intercepts, especially with the random elements of A, so I am thankful for every kind of help!

  • 1
    $\begingroup$ B has a random slope. I can't tell that A has a random effect from the lmer statement. $\endgroup$
    – JTH
    Jun 24, 2021 at 15:28

1 Answer 1


The model

lmer(Y ~ 0 + A + B + C + (0 + B | A)

does indeed have three fixed effects and a single random slope.

I would write this model (using a vectorized notation) as

$$ Y = \beta_{a} A + (\beta_b + b_a) B + \beta_c C + \epsilon \\ \epsilon \sim N(0, \sigma^2_\epsilon) \\ b_a \sim N(0, \sigma^2_b) $$

where $b_a$ is the random slope of $B$, which varies depending on the levels of $A$, and $\epsilon$ is the error term.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.