In this example, there are three observations for each combination of the three machines (A, B, C) and the six workers. I'll use $I_n$ to denote a $n$-dimensional identity matrix and $1_n$ to denote an $n$-dimensional vector of ones. Let's say $y$ is the vector of observations, that I will assume is ordered by worker then machine then replicate. Let $\mu$ be the corresponding expected values (e.g. the fixed effects), and let $\gamma$ be a vector of group-specific deviations from the expected values (e.g. the random effects). Conditional on $\gamma$, the model for $y$ can be written:
$$y \sim \mathcal{N}(\mu + \gamma, \sigma^2_y I_{54})$$
where $\sigma^2_y$ is the "residual" variance.
To understand how the covariance structure of the random effects induces a covariance structure among observations, it is more intuitive to work with the equivalent "marginal" representation, which integrates over the random effects $\gamma$. The marginal form of this model is,
$$y \sim \mathcal{N}(\mu, \sigma^2_y I_{54} + \Sigma)$$
Here, $\Sigma$ is a covariance matrix that depends on the structure of $\gamma$ (e.g. the "variance components" underlying the random effects). I'll refer to $\Sigma$ as the "marginal" covariance.
In your m1
, the random effects decompose as:
$$\gamma = Z \theta$$
Where $Z = I_{18} \otimes 1_3$ is a design matrix that maps the random coefficients onto observations, and $\theta^T = [\theta_{1,A}, \theta_{1,B}, \theta_{1,C} \dots \theta_{6,A}, \theta_{6,B}, \theta_{6,C}]$ is the 18-dimensional vector of random coefficients ordered by worker then machine, and is distributed as:
$$\theta \sim \mathcal{N}(0, I_6 \otimes \Lambda)$$
Here $\Lambda$ is the covariance of the random coefficients. The assumption of compound symmetry means that $\Lambda$ has two parameters, that I'll call $\sigma_\theta$ and $\tau$, and the structure:
$$\Lambda = \left[\begin{matrix} \sigma^2_\theta + \tau^2 & \tau^2 & \tau^2 \\
\tau^2 & \sigma^2_\theta + \tau^2 & \tau^2 \\
\tau^2 & \tau^2 & \sigma^2_\theta + \tau^2 \end{matrix}\right]$$
(In other words, the correlation matrix underlying $\Lambda$ has all the elements on the offdiagonal set to the same value.)
The marginal covariance structure induced by these random effects is $\Sigma = Z (I_6 \otimes \Lambda) Z^T$, so that the variance of a given observation is $\sigma^2_\theta + \tau^2 + \sigma^2_y$ and the covariance between two (separate) observations from workers $i, j$ and machines $u, v$ is:
$$\mathrm{cov}(y_{i,u}, y_{j,v}) = \begin{cases}
0 & \text{if } i\neq j \\
\tau^2 & \text{if } i=j, u\neq v \\
\sigma^2_\theta + \tau^2 & \text{if } i=j, u=v \end{cases}$$
For your m2
, the random effects decompose into:
$$\gamma = Z \omega + X \eta$$
Where Z is as before, $X = I_6 \otimes 1_9$ is a design matrix that maps the random intercepts per worker onto observations, $\omega^T = [\omega_{1,A}, \omega_{1,B}, \omega_{1,C}, \dots, \omega_{6,A}, \omega_{6,B}, \omega_{6,C}]$ is the 18-dimensional vector of random intercepts for every combination of machine and worker; and $\eta^T = [\eta_{1}, \dots, \eta_{6}]$ is the 6-dimensional vector of random intercepts for worker. These are distributed as,
$$\eta \sim \mathcal{N}(0, \sigma^2_\eta I_6)$$
$$\omega \sim \mathcal{N}(0, \sigma^2_\omega I_{18})$$
Where $\sigma_\eta^2, \sigma_\omega^2$ are the variances of these random intercepts.
The marginal covariance structure of m2
is $\Sigma = \sigma^2_\omega Z Z^T + \sigma^2_\eta X X^T$, so that the variance of a given observation is $\sigma^2_\omega + \sigma^2_\eta + \sigma^2_y$, and the covariance between two observations from workers $i, j$ and machines $u, v$ is:
$$\mathrm{cov}(y_{i,u}, y_{j,v}) = \begin{cases}
0 & \text{if } i\neq j \\
\sigma_\eta^2 & \text{if } i=j,u\neq v \\
\sigma^2_\omega + \sigma^2_\eta & \text{if } i=j,u=v \end{cases}$$
So ... $\sigma^2_\theta \equiv \sigma^2_\omega$ and $\tau^2 \equiv \sigma^2_\eta$. If m1
assumed compound symmetry (which it doesn't with your call to lmer, because the random effects covariance is unstructured).
Brevity is not my strong point: this is all just a long, convoluted way of saying that each model has two variance parameters for the random effects, and are just two different ways of writing of the same "marginal" model.
In code ...
sigma_theta <- 1.8
tau <- 0.5
sigma_eta <- tau
sigma_omega <- sigma_theta
Z <- kronecker(diag(18), rep(1,3))
rownames(Z) <- paste(paste0("worker", rep(1:6, each=9)),
rep(paste0("machine", rep(1:3, each=3)),6))
X <- kronecker(diag(6), rep(1,9))
rownames(X) <- rownames(Z)
Lambda <- diag(3)*sigma_theta^2 + tau^2
# marginal covariance for m1:
Z%*%kronecker(diag(6), Lambda)%*%t(Z)
# for m2:
X%*%t(X)*sigma_eta^2 + Z%*%t(Z)*sigma_omega^2
lme4
syntax. It'd be helpful - & widen the pool of potential answerers - if you explained them for people unfamiliar withlme4
. $\endgroup$