# Mixed Effects Model: Writing Out Level 1/Level 2 Models

Suppose I have an LMER output (using Grunfeld data from plm package) as:

summary(lmer(inv ~ value + capital + (1|firm), data = Grunfeld))

> Random effects:
Groups   Name        Variance Std.Dev. Corr
firm     (Intercept) 7367     85.83
Residual             2781     52.74    0.831
Number of obs: 200, groups:  firm, 10

Fixed effects:
Estimate Std. Error t value
(Intercept) -57.86442   29.37776   -1.97
value         0.10979    0.01053   10.43
capital       0.30819    0.01717   17.95

Correlation of Fixed Effects:
(Intr) value
value   -0.328
capital -0.019 -0.368


I know we can write a Level 1/Level 2 model based on this as:

Level 1:
y = alpha_0 + alpha_1 * value + alpha_2 * capital + eps
Level 2:
alpha_0 = gamma_00 + u_0
alpha_1 = gamma_01 + u_1
alpha_2 = gamma_02 + u_2


The level 1 model should have alpha_0=-57.864, alpha_1=0.109, alpha_2=0.308.

Now, I'm actually not sure if this is the correct form of the level 2 model. Im wondering what exactly the level 1/2 models would be here (for example, are the gammas in the level 2 model concrete values, or are they RV's. For example, here, it is not clear what those values are supposed to be). And also what the correlation of the fixed effects means versus the correlation of random effects. I can't seem to find definitive answers online.

Note that you have only included a random intercept for the firm grouping variable. I.e., the model you are fitting is the following:

$$\left\{ \begin{array}{l} \texttt{Inv}_{ij} = \beta_0 + \beta_1 \texttt{Value}_{ij} + \beta_2 \texttt{Capital}_{ij} + b_i + \varepsilon_{ij},\\\\ b_i \sim \mathcal N(0, \sigma_b^2), \quad \varepsilon_{ij} \sim \mathcal N(0, \sigma^2), \end{array} \right.$$

where $$\texttt{Inv}_{ij}$$ denotes the $$j$$-th measurement within the $$i$$-th firm for you outcome variable, and likewise $$\texttt{Value}_{ij}$$ and $$\texttt{Capital}_{ij}$$ denote the $$j$$-th measurement within the $$i$$-th firm for the two predictors.

The estimated parameters according to the output are:

• $$\hat\beta_0 = -57.86442$$
• $$\hat\beta_1 = 0.10979$$
• $$\hat\beta_2 = 0.30819$$
• $$\hat\sigma_b = 85.83$$
• $$\hat\sigma = 52.74$$

You could also rewrite the same model as:

$$\left\{ \begin{array}{l} \texttt{Inv}_{ij} = \alpha_{0i} + \beta_1 \texttt{Value}_{ij} + \beta_2 \texttt{Capital}_{ij} + \varepsilon_{ij},\\\\ \alpha_{0i} = \beta_0 + b_i,\\\\ b_i \sim \mathcal N(0, \sigma_b^2), \quad \varepsilon_{ij} \sim \mathcal N(0, \sigma^2). \end{array} \right.$$

• Thank you! This is great. I have also been trying to understand what the correlation of random effects exactly represents. For example, I understand the correlation of fixed effects measures the correlation between coefficients for each of the individual fits. But what does the correlation of random effects show? Dec 8, 2018 at 19:54
• It is not clear which correlation you exactly mean. You only have a single random intercept per firm. BTW, when I run the same example in my laptop, I don't get the Corr column in the Random Effects output. Dec 8, 2018 at 20:37
• My apologies, you are correct. Suppose I run this code: summary(lmer(inv ~ value + capital + (1+value|firm), data = Grunfeld)). We see the correlation of random effects is -0.40. What does this term represent, exactly? The correlation of fixed effects measures the correlation between the coefficients for individual fits (which can be confirmed with, say, looking at LmList) but I cannot see what the -0.40 correlation for random effects corresponds to. Dec 8, 2018 at 20:50
• This is the (prior) correlation between the random intercepts and random slopes for value. Because it is negative it indicates that a-priori firms which have a positive intercept will tend to have a negative slope, and the otherway around. Dec 9, 2018 at 5:56
• Thats what I thought, but if I do the following: x=lmer(inv ~ value + capital + (1+value|firm), data = Grunfeld), then: cor(ranef(x)\$firm[,1], ranef(x)\$firm[,2]), I get a value of -0.3, not -0.4, which does not make sense to me... where exactly would we see what the -0.4 is measuring? Dec 9, 2018 at 18:59

It seems there are 10 firms in the dataset.

Level 1 model:

$$Y_{ki}=\alpha_{0k} + \alpha_1X_{1ki} + \alpha_2X_{2ki} + \epsilon_{ki}$$

So the level 2 model can be written as:

$$\alpha_{0k} = \alpha_0 + u_k$$

where $$k=,...,10$$ is index for firm. $$i$$ is the i-th measurement. $$X_{1ki}$$ is value and $$X_{2ki}$$ capital.

$$u_k\sim N(0,\sigma_u^2)$$ and $$\epsilon \sim N(0,\sigma^2)$$.