4
$\begingroup$

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)?

$\endgroup$
  • 3
    $\begingroup$ It's conventional to use Latin letters for variables and Greek for coefficients. I would write: \begin{gather} y\sim\mathcal N(\beta_0 + \beta_1\cdot x + \beta_2\cdot y + \beta_3\cdot xy, \sigma^2_e) \\ \beta_0 \sim \mathcal N(\bar\beta_0, \sigma^2_0) \end{gather}With a slight abuse of notation one can also write it a bit simpler as \begin{gather} y = \beta_0 + \beta_1\cdot x + \beta_2\cdot y + \beta_3\cdot xy\\ \beta_0 \sim \mathcal N(\bar\beta_0, \sigma^2_0) \end{gather} $\endgroup$ – amoeba Oct 18 '17 at 12:15
  • 1
    $\begingroup$ @amoeba, post as answer? You can express this in matrix notation ($\mathbf y = \mathbf X \mathbf \beta + \mathbf Z \mathbf b$ etc.) but I think amoeba's notation is probably clearer. Depends on your audience. $\endgroup$ – Ben Bolker Oct 18 '17 at 12:56
  • 1
    $\begingroup$ (1) You are right, this should be changed. Do your variables 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. $\endgroup$ – amoeba Oct 18 '17 at 13:43
  • 1
    $\begingroup$ By the way, this assumes that your var2 and var3 are continuous. If they are categorical, then the model has to be written differently. $\endgroup$ – amoeba Oct 18 '17 at 13:46
  • 1
    $\begingroup$ So if Item is 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 making Item a random effect. $\endgroup$ – amoeba Oct 19 '17 at 15:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.