Skip to content
Prev 18714 / 20628 Next

Standard Error of a coef. in a 2-level model vs. 2 OLS models

Thanks Phillip!

In other words, when we use the full data in a regular ols model (`ols1`
below), then the residual variation [i.e.,  sigma(ols1)^2] approximately
equals the sum of within- and between-cluster variation from a
corresponding mixed model (`m1` below).

But if we use cluster-level data in a regular ols model (`ols2` below), no
correspondence between the amounts of variation between the `ols2` model
and the corresponding mixed model (`m1` below) can be found?

library(lme4)
library(tidyverse)

hsb <- read.csv('
https://raw.githubusercontent.com/rnorouzian/e/master/hsb.csv')
hsb_ave <- hsb %>% group_by(sch.id) %>% mutate(math_ave = mean(math)) %>%
slice(1)

ols1 <- lm(math ~ sector, data = hsb)
summary(ols1)

m1 <- lmer(math ~ sector + (1|sch.id), data = hsb)
summary(m1)

ols2 <- lm(math_ave ~ sector, data = hsb_ave)
summary(ols2)
On Thu, Sep 17, 2020 at 12:23 PM Phillip Alday <phillip.alday at mpi.nl> wrote: