I'd like to replicate a Multilevel Model (MLM) using R with the below equations.
Level 1:
Y = Betaoj + Beta1jX1 + Beta2jX2 + Beta3j*(X1*X2) + Beta4j(X3) + rij
Level 2:
- Beta0j = g00 + g01 (Sector) + u0j
- Beta1j = g10 + g11 (Sector) + u1j
- Beta2j = g20 + g21 (Sector) + u2j
- Beta3j = g30 + g31 (Sector) + u3j
- Beta4j = g40
Both X1 & X3 are dummy variables.
Here is my R code:
model=lmer(Y ~ 1 + X1 + X2 + X1*X2 + X3 + (X1|Sector), data=df, REML=FALSE)
summary (model)
It does not return the expected result. How can I fix the code?