clear set obs 50 generate z = rnormal(0,sqrt(2)) // this is the random effect generate id = _n expand 20 generate x = 5*runiform() generate y = 3 + 4*x + z + rnormal() // Here, y=3+2*x is the fixed effect, // y = z is a random effect (a random intercept), // and y = rnormal() is the residual/error term. // In total we have y = fixed + random + residual. mixed y x || id: // mixed command predict yh1 predict yhr1, fitted generate x1 = x - 5 mixed y x1 || id: // same model, x recentered predict yh2 predict yhr2, fitted scatter yh2 yh1 scatter yhr2 yhr1 clear set obs 50 generate zi = rnormal(0,sqrt(2)) // this is the random effect generate zs = rnormal() // this is the random effect for slope generate id = _n expand 20 generate x = 5*runiform() generate y = 3 + 4*x + zi + x*zs + rnormal() mixed y x || id: x // mixed command predict yh1 predict yhr1, fitted generate x1 = x - 5 mixed y x1 || id: x1 // same model, x recentered predict yh2 predict yhr2, fitted scatter yh2 yh1 scatter yhr2 yhr1 // this part is no longer a linear transformation * However, if we fit these models with unstructured covariance among * the random effects, then recentering is just a linear transformation again. clear set obs 50 matrix C = (1, .5 \ .5, 1) drawnorm zi zs, corr(C) *generate zi = rnormal(0,sqrt(2)) // this is the random effect *generate zs = rnormal() // this is the random effect for slope generate id = _n expand 20 generate x = 5*runiform() generate y = 3 + 4*x + zi + x*zs + rnormal() mixed y x || id: x, cov(unstructured) // mixed command predict yh1 predict yhr1, fitted generate x1 = x - 5 mixed y x1 || id: x1, cov(unstructured) // same model, x recentered predict yh2 predict yhr2, fitted scatter yh2 yh1 scatter yhr2 yhr1 // this part is no longer a linear transformation