I am confused about the difference between linear model (LM) and linear mixed model (LMM). I use an example from Introduction to linear mixed models. Grateful if you can explain the subtle differences between 2 models by using the example below.
The LM I use is:
mountain.lm <- lm(testScore ~ bodyLength2 + mountainRange, data = dragons)
summary(mountain.lm)
The summary shows:
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 23.3818 2.5792 9.065 < 2e-16 ***
bodyLength2 0.2055 1.2927 0.159 0.87379
mountainRangeCentral 36.5828 3.5993 10.164 < 2e-16 ***
mountainRangeEmmental 16.2092 3.6966 4.385 1.43e-05 ***
mountainRangeJulian 45.1147 4.1901 10.767 < 2e-16 ***
mountainRangeLigurian 17.7478 3.6736 4.831 1.84e-06 ***
mountainRangeMaritime 49.8813 3.1392 15.890 < 2e-16 ***
mountainRangeSarntal 41.9784 3.1972 13.130 < 2e-16 ***
mountainRangeSouthern 8.5196 2.7313 3.119 0.00192 **
The ggplot by:
facet_wrap(~mountainRange, nrow=2)
The LMM I use is:
mixed.lmer <- lmer(testScore ~ bodyLength2 + (1|mountainRange), data = dragons)
summary(mixed.lmer)
The summary shows:
Random effects:
Groups Name Variance Std.Dev.
mountainRange (Intercept) 339.7 18.43
Residual 223.8 14.96
Number of obs: 480, groups: mountainRange, 8
Fixed effects:
Estimate Std. Error t value
(Intercept) 50.3860 6.5517 7.690
bodyLength2 0.5377 1.2750 0.422
The 2 plots look similar but I notice their slopes of bodylength2 are different: 0.2055 in LM, while 0.5377 in LMM. My understanding is if I want to explore the relationship between bodylength2 and testScore, I shall set mountainRange as a random effect, which means I shall use LMM. However, I can also explore the same relationship by using LM: the slopes are the same across mountainRange, which means the effect of mountainRange has been controlled. I am wondering what's the advantage of using LMM here. It would be better if you can explain in a simply mathematical way. Thanks!