Multilevel model

We begin by specifying our model in the 'multlevel' format:

$$ \begin{aligned} M_{ik} &\sim \mathrm{Binomial}(1,p_{ik})\\ \mathrm{logit}(p_{ik}) &= \beta_{0k} + \beta_{1k}Age_i + \beta_{2k}Female_i\\ \\ \beta_{0k} &= \gamma_{00} + \gamma_{01}TExp_k + \gamma_{02}TFemale_k + \eta_{0k}\\ \beta_{1k} &= \gamma_{10} + \eta_{1k}\\ \beta_{2k} &= \gamma_{20} + \gamma_{21}TFemale_k + \eta_{2k}\\ \end{aligned} $$

Expanded model

We expand the model into a "mixed effects" format to see how we will specify it in R:

$$ \begin{aligned} \mathrm{logit}(p_{ik}) &= \gamma_{00} + \gamma_{01}TExp_k + \gamma_{02}TFemale_k + \gamma_{10}Age_i + \gamma_{20}Female_i + \gamma_{21}TFemale_kFemale_i + \\ &\phantom{{}={}} \eta_{0k} + \eta_{1k}Age_i + \eta_{2k}Female_i \end{aligned} $$