clear set obs 50 generate z = rnormal() // this is the random effect generate id = _n expand 2 generate x = runiform() generate y = 3 + 2*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. xtset id regress y x // incorrectly lumps variation due to id in with residual est store under xtreg y x // correct, random intercept model mixed y x || id: // same model, mixed command regress y x i.id // overfit est store over lrtest under over