Suppose we have $m$ schools chosen randomly from among thousands in a large country. Suppose also that $n$ students of the same age are chosen at each school. Let $Y_{ij}$ be the score of the $j$th student at the $i$th school.
One model we can come up with is:
$$ Y_{ij} = \mu + U_i + W_{ij} $$
where the $\mu$ variable is the average score for the entire population. From this model, $U_i$ is a random effect with $W_{ij}$ being the error term. Suppose that I want $U_i$ to be normally distributed. That is, each school has a different normal distribution parameter: $U_i$.
I am wondering how a scenario like this can be simulated in R
, for say $m = 5$ schools, $n = 100$ students?