1

I need help correctly writing out this mixed model for an academic paper. I'm a bit dyslexic and really struggle with math notation more complicated than multiplication and division!

Lets say the score of a pupil is correlated to their height (fixed effects) and an additional term of height^-1. I've formulated the dataset so that every pupil is assigned to a unique class which is nested in a unique school and nested in a unique school district. I dont need to explicitly nest the random effects in the lmer formula so long as they are nested in the dataset per -> Multilevel model with 4 levels?

I also want to incorporate two other random effects which are effectively crossed as these do not cluster inside of any other level. These are each student's Music_Taste and Favourite_Food

lmer(score ~ 1 + pupil_height + I(pupil_height^-1) + (1|Class) + (1|School) + (1|School_District) + (1|Music_Taste) + (1|Favourite_Food), data=data_file)

From Gelman and Hill, 2006 (p263) I think I need something like this formulae but with additional terms for the crossed random effects;

yi = αj[i] + β1Xi1 + β2Xi2 + e

Can anyone help out with the formula?

Its something like this but different to account for the nested random effects.

scorei jklmn=α + β₁⋅ heighti jklmn + β2⋅ heighti jklmn-1 + uj + uk + ul + um + un + εi jklmn

where Uj,k,l,m,n are the seperate random intercepts for class, school, school_district, music_taste and favorite_food.

As discussed the class, school and school district are nested in the dataset by virtue of unique IDs. The others are music_taste and favorite_food to be crossed random effects.

  • So the score is proportional to $x + 1/x$ where $x$ is height ? Why is this ? As for the formula, since you don't have any random slopes, you just specify a seperate intercept term for all the random effect grouping variables. Having said that, I would expect that you have some nested random effects (eg class in school and school in district) as well, so just take care with the subscripting. – Robert Long Nov 27 '20 at 21:41
  • +1/ where is height? Why is this ? I'm fitting to a standard regression formula from elsewhere – Hamish Robertson Nov 27 '20 at 21:44
  • Your model has these fixed effects `pupil_height + I(pupil_height^-1)` . That's the same as $x + 1/x$ where $x$ is `pupil_height ` – Robert Long Nov 27 '20 at 21:47
  • Yeh the formula I want to fit my data to is y = a + b*pupil_height + c/pupil_height The coefficients a,b and c have meaning in other formula elsewhere – Hamish Robertson Nov 27 '20 at 21:54
  • Also I mentioned in the question that the way I have added unique IDs to each class etc I have made a nested structure of class – Hamish Robertson Nov 27 '20 at 21:57
  • OK, that seems strange but I assume you have some theoretical reason for that. So just write the formula with a seperate intercept term for each random effect. Each random effect will need it's own subscript, so you will need something like $y_{ijklm} = \dots$ and you will have to define the subscripting seperately (to distinguish between crossed and nested random effects). You may find books like Bosker and Snyders to be more helpful that Gelman and Hill when it comes to these notational issues. – Robert Long Nov 27 '20 at 22:10
  • Yeh its an equation for chemical thermodynamics. I'll look at the book, thanks for the tip, I'm horrible at math notation :( I can write it out for the crossed random effects (see question) only but incorporating this nested stuff as I said in the question I find the notation challenging. – Hamish Robertson Nov 27 '20 at 23:45

0 Answers0