1
$\begingroup$

I am struggling to address a specific research question within a MLM-framework. I have got a large dataset (N > 75,000) and three levels. Let's just assume I got individuals nested in gender, and gender nested in schools. The dataset contains 50 schools, gender (women/men), and my dependent variable is happiness. How can I test whether happiness differs unsystematically between gender across schools? For example, in school 1 women might be statistically significant more happy than men, and vice versa in school 2, whereas in school 3 there are no significant gender differences. I thought the crucial test might be comparing a mixed model in which individuals and schools are random but gender is fixed with a model in which the slope of gender is also random. Does this make sense? If so, how can I specify this in R, for example within lme4 or nlme?

Thank you

EDIT: I was also playing around with interactions (not sure if it makes sense, thought), but a comparison revealed exactly the same model fit (p = 1):

fm.null <- lmer(Happi~ 1 + (1|gender) + (1|school), df1, na.action=na.omit)
fm2 <- lmer(Happi ~ 1 + (1|gender) * (1|school), df1, na.action=na.omit)
anova(fm.null, fm2)
$\endgroup$
3
  • $\begingroup$ Have you looked at the lme4 documentation? cran.r-project.org/web/packages/lme4/vignettes/lmer.pdf. See page 6. Also, I believe nlme only takes 1 level. $\endgroup$
    – Jon
    Commented Oct 10, 2016 at 18:45
  • $\begingroup$ Here is an example: ats.ucla.edu/stat/r/examples/alda/ch4.htm $\endgroup$
    – Jon
    Commented Oct 10, 2016 at 18:46
  • $\begingroup$ Thanks Jon, the lme4 documentation is useful. Unfortunately, I am unable to transfer the example codes to my research question. Also, I am not sure if the analytic approach suggested above makes sense. $\endgroup$
    – user134224
    Commented Oct 11, 2016 at 13:53

1 Answer 1

1
$\begingroup$

Here an answer to my own question in case someone is having the same problem: Compare a random intercept with a random intercept and random slope model.

h2.null <- lmer(Happi ~ gender+ (1|school), data = df, na.action=na.omit)    
h2 <- lmer(Happi ~ gender+ (gender|school), data = df1, na.action=na.omit)
anova(h2, h2.null)

The code is adapted from Rob Thomas' book "Data analysis with R statistical software: a guidebook for scientists" (p. 94).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.