2

I had a quick question. I have a cross-level interaction in my model below (ses*sector). My cluster-level predictor "sector" is a binary variable (0=Public, 1=Private). My level-1 predictor ses is numeric.

QUESTION: The Corr = 1 is indicating the correlation between intercepts and slopes across BOTH public & private sectors (like their average) OR something else?

NOTE: Regardless of size of Corr ($.1$ or $.99$), I just want to know the answer to my question above.

library(lme4)
hsb <- read.csv('https://raw.githubusercontent.com/rnorouzian/e/master/hsb.csv')

summary(lmer(math ~ ses*sector + (ses|sch.id), data = hsb))


Random effects:
 Groups   Name        Variance Std.Dev. Corr
 sch.id   (Intercept)  3.82107 1.9548       
          ses          0.07587 0.2754   1.00  # Corr HERE ##
 Residual             36.78760 6.0653  
```
Robert Long
  • 53,316
  • 10
  • 84
  • 148
rnorouzian
  • 3,056
  • 2
  • 16
  • 40

1 Answers1

3

This seems very likely to be a case of a singular fit. I would be very surprised if this model converged without a warning. The correlation isn't actually 1, but the software cannot estimate it, probably because there is vey little variation in the random slopes.

The best way forward is to fit a model with correlated random slopes and intercetps, and if you find that the variance of the random slopes is close to zero, then remove the random slopes from the model.

See these answers for further details:
Dealing with singular fit in mixed models
How to simplify a singular random structure when reported correlations are not near +1/-1

Now, regarding the question

The Corr is indicating the correlation between intercepts and slopes across BOTH public & private sectors (like their average) OR something else?

The random structure specified is (ses|sch.id), so the software will estimate 160 random intercepts, that is an offset from the global intercept, for each sch.id. Since ses is a numeric variable it will also estimate 160 random slopes of ses, that is, an offset from the fixed effect of ses for each sch.id, and the correlation that you refer to is simply the correlation between them. Since it does not taje account of the sector variable, you are right that it is estimating the correlation across both public and private sectors, so in that sense it would be some kind of average. It could be an interesting topic to study with a simulation, where you simulate the random effects seperately for public and private, and combine them, generate data and see how the estimated correlation relates to the two individual ones. It could be just a weighted average but I would not be surprised if it was more complicated than that. I recently wrote an answer on how to simulate data for a mixed model, and I think you could adapt that to this situation fairly easily:
What are the steps to simulate data for a linear model with random slopes and random intercepts

Robert Long
  • 53,316
  • 10
  • 84
  • 148