# Interpreting the statistical model implied by an lmer formula for mixed effect modelling

Consider the scenario in which a dataset has two grouping variables (say group 1 and group 2), and a time variable $$x$$. I would like to understand the difference between the following two models:

m1: lmer(y ~ fixed_component + ( 1 + x | g1 ) + ( 1 + x | g2 )
m2: lmer(y ~ fixed_component + ( 1 + x | g1 ) + ( 1 + x | g2:g1 )


For the first one, the statistical model implied is:

$$y_{ijk} = \text{fixed component} + (u_{jI} + v_{kI}) + (u_{jS} + v_{kS})x_i + \text{error}$$ where $$x_i$$ is the time variable for the $$i$$-th observation, for group 1 $$=j$$ and group 2 $$=k$$, and where $$I,S$$ denote intercept and slope random effects respectively, and where $$\begin{bmatrix}u_{jI} \\ u_{jS}\end{bmatrix} \sim N \left ( \begin{bmatrix}0 \\ 0\end{bmatrix} , \begin{bmatrix}\sigma^2_{uI} & \rho_U\sigma_{uI} \sigma_{uS} \\ \rho_U\sigma_{uI} \sigma_{uS} & \sigma^2_{uS}\end{bmatrix} \right )$$ $$\begin{bmatrix}v_{kI} \\ v_{kS}\end{bmatrix} \sim N \left ( \begin{bmatrix}0 \\ 0\end{bmatrix} , \begin{bmatrix}\sigma^2_{vI} & \rho_V\sigma_{vI} \sigma_{vS} \\ \rho_V\sigma_{vI} \sigma_{vS} & \sigma^2_{vS}\end{bmatrix} \right )$$ where the two vectors are independent.

I am confused about what statistical model we have for the second lmer formulation though, since in that model we restrict the second random effects to model the residuals remaining after the first group is accounted for.

edit: Assume that the nested group is not coded uniquely. So e.g. group1 is school1, school2, school3,.., and group2 is class1, class2, class3,...

I know that the second model will be

$$y_{ijk} = \text{fixed component} + (u_{jI} + v_{jkI}) + (u_{jS} + v_{jkS})x_i + \text{error}$$ and I know that the distribution of $$[u_{jI}, u_{jS}]^T$$ will not differ, but what about the distribution of $$[v_{jkI}, v_{jkS}]^T$$ ?

Generally speaking, in the first model we have an intercept varying within g1 and g2, while in the 2nd model we have an intercept varying within g1, and g2 varying within g1. The second formulation is typically used for nested factors, where levels of g2 appear in 1 and only 1 level of g1. An example of this would be students nested within schools. Each student "belongs" to one and only one school.
In terms of the data, for a nested study, when the lower level factors are coded uniquely, then the two formulations will be equivalent. For example, with students nested within schools, of students are not coded uniquely. Consider two students in different schools. If both students had the same ID, say student1 then it is necessary to use the second formulation, but if the students are coded unuquely, say student1-1 and student1-2, then the two formulations are equivalent.