# Difference between two lmer model .

#### Cynderella

##### New Member
Can you please explain where is the difference between the following two models :

Code:
fm1 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
fm2 <- lmer(Reaction ~ Days + (1|Subject) + (0+Days|Subject), sleepstudy)
I noticed there is some discrepency in the estimate for random effect between model fm1 and fm2 . But don't know why ?

Many thanks! Regards .

#### Jake

The first model allows and estimates a covariance between the random intercepts and random slopes across Subjects. The second model does not--it forces the covariance to be zero. To the extent that the covariance in question is in fact non-zero, this can affect the other parameter estimates.

A more compact (and newer, and way cool) syntax that is an equivalent way to write the second model is:
Code:
lmer(Reaction ~ Days + (Days||Subject), sleepstudy)
(note the double pipe character rather than single pipe character in the random part of the model)

#### Cynderella

##### New Member
If I write down the model Reaction ~ Days + (Days | Subject) :

$$\text{Reaction}_{ij}=\beta_{0j}+\beta_{1j}\text{Days}_{ij}+e_{ij}$$
$$\beta_{0j}=\gamma_{00}+u_{0j}$$
$$\beta_{1j}=\gamma_{10}+u_{1j}$$

Combining the last two equations into first one , that is , by substituting the level-2 equation to level-1 equation, we have ;

$$\text{Reaction}_{ij}=\gamma_{00}+\gamma_{10}\text{Days}_{ij}+u_{0j}+u_{1j}\text{Days}_{ij}+e_{ij}$$

Does
The second model does not--it forces the covariance to be zero.
mean for the second model $$cov(u_{0j},u_{1j})=0$$ ?

Many thanks! Regards .