Formula: for the random-intercept model y_ij = x_ij' b + u_j + e_ij with u_j ~ N(0, sigma2_u) and e_ij ~ N(0, sigma2_e), the E-step conditional moments are closed form,
uhat_j = sigma2_u sum_i r_ij / (sigma2_e + n_j sigma2_u)
var(u_j|y) = sigma2_u sigma2_e / (sigma2_e + n_j sigma2_u)
with r_ij = y_ij - x_ij' b, and the M-step is sigma2_u' = mean_j (uhat_j^2 + var(u_j|y)) and sigma2_e' = (sum_ij (r_ij - uhat_j)^2 + sum_j n_j var(u_j|y)) / N.
Details
b is the GLS estimate at the current variances, formed cluster-wise
from the Sherman-Morrison inverse
V_j^-1 = (I - sigma2_u J_j / (sigma2_e + n_j sigma2_u)) / sigma2_e,
or supplied fixed via beta, in which case sigma2_e = 0 is
admissible and the update reduces to its exact limit.
