I have the following model fitted using the lme4 package in R:
mod <- lmer(var1 ~ var2 * var3 + (1|var4) , data=s1, REML=F)
I want to express this as an equation. I have the following:
$$ Y_{i} = \beta_0 + \beta_{0\varpi} + \beta_{1\nu}\nu_i + \beta_{1\varsigma}\varsigma_i + \beta_{1\vartheta}\nu_i\varsigma_i + e_{i} $$
Where $\nu=var2$, $\varsigma=var3$ and $\varpi = var4$, so $\beta_0$ is the overall intercept, $\beta_{0\varpi}$ is the random intercept for var4, $\beta_{1\nu}\nu_i$ is the slope for var2, $\beta_{1\varsigma}\varsigma_i$ is the slope for var3 and $\beta_{1\vartheta}\nu_i\varsigma_i$ is the slope for the interaction (var2,var3).
I am wondering if this is the best way to express this model/if there are any better alternatives (such as expressing var2 and var3 as a matrix)?
var1,var2, etc. have some meaningful names? If so, I would write smth like $$\mathrm{Height}=\beta_0+\beta_1\cdot\mathrm{Age}+\beta_2...$$ As long as you have only a handful of variables this is going to be fine. (2) $\beta_0$ is the intercept and the second line shows that it's random. $\bar\beta_0$ is the "fixed intercept" and $\sigma^2_0$ is the variance of random intercept. – amoeba Oct 18 '17 at 13:43var2andvar3are continuous. If they are categorical, then the model has to be written differently. – amoeba Oct 18 '17 at 13:46Itemis categorical then it does not make any sense to write $\beta_2\cdot\mathrm{Item}$... The value ofItemis an integer, but we are not multiplying beta with this integer. Instead, one can write $\gamma_i$ where $i$ can take values from 1 to K-1 where K is the number of levels of theItemfactor. You are essentially fitting different intercepts for different values of Item. And similarly for the interaction term. – amoeba Oct 18 '17 at 21:29@amoebawhen you reply.) Eq 1 on page 9 in Barr et al. considers X that is indeed categorical but has only 2 levels. That's a bit of a special case, because then there is only one additional intercept to be estimated, so one can write $\beta\cdot X$ as they do. Is yourItemalso binary or does it have more levels? – amoeba Oct 19 '17 at 07:49Itemis categorical then instead of $\beta \cdot \mathrm{Item}$ you can write something like $\gamma_k$ and explain that $k$ stands for Item number $k$, or you can write the same thing more explicitly as $\gamma_k \cdot I(\mathrm{Item}=k)$. Here $I()$ is an indicator function. By the way, note that 30 levels is quite a lot, so you should consider makingItema random effect. – amoeba Oct 19 '17 at 15:16