I'm working on a dataset with individual-level and school-level variables using multilevel model. The independent variable is a categorical variable (with four categories) which is transformed to three dummy variables.
Code:
mixed PV1MATH ESCS male i.gr9 i.gr1011 i.c1p_sg1 i.c2p_sg1 i.cc_fg1 /// immiage ltt ESCSave IMMIrate||CNTSCHID:
But when I tried to test the random effect of school-level variables on these dummy variables' slops, there were always some errors:
First, the code is like this:
Code:
mixed PV1MATH ESCS male i.gr9 i.gr1011 i.c1p_sg1 i.c2p_sg1 i.cc_fg1 /// immiage ltt ESCSave IMMIrate||CNTSCHID: i.c1p_sg1 i.c2p_sg1 i.cc_fg1
must use R. when specifying factor variables in random-effects equations
Code:
mixed PV1MATH ESCS male i.gr9 i.gr1011 i.c1p_sg1 i.c2p_sg1 i.cc_fg1 /// immiage ltt ESCSave IMMIrate||CNTSCHID: R.c1p_sg1 R.c2p_sg1 R.cc_fg1
R.c1p_sg1 R.c2p_sg1 R.cc_fg1 invalid level specification
Code:
mixed PV1MATH ESCS male i.gr9 i.gr1011 i.c1p_sg1 i.c2p_sg1 i.cc_fg1 /// immiage ltt ESCSave IMMIrate||CNTSCHID: c1p_sg1 c2p_sg1 cc_fg1, cov (un)
Warning: standard-error calculation failed
Code:
mixed PV1MATH ESCS male i.gr9 i.gr1011 i.c1p_sg1 i.c2p_sg1 i.cc_fg1 /// immiage ltt ESCSave IMMIrate||CNTSCHID: c1p_sg1 c2p_sg1 cc_fg1
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
CNTSCHID: Independent |
var(c1p_sg1) | 549.0446 . . .
var(c2p_sg1) | .00066 . . .
var(cc_fg1) | 3.43e-13 . . .
var(_cons) | 1068.627 . . .
-----------------------------+------------------------------------------------
var(Residual) | 4851.256 . . .
------------------------------------------------------------------------------
LR test vs. linear model: chi2(4) = 601.67 Prob > chi2 = 0.0000
-----------------------------+------------------------------------------------
CNTSCHID: Independent |
var(c1p_sg1) | 549.0446 . . .
var(c2p_sg1) | .00066 . . .
var(cc_fg1) | 3.43e-13 . . .
var(_cons) | 1068.627 . . .
-----------------------------+------------------------------------------------
var(Residual) | 4851.256 . . .
------------------------------------------------------------------------------
LR test vs. linear model: chi2(4) = 601.67 Prob > chi2 = 0.0000
I want to know why that happens and how to deal with these problems.
Also, I have to admit that I don't know much about the principle of how multilevel model deals with dummy variables and I should have understood. Could you please also recommend some books or papers if you know any reference for related issues?
Thank you very much.
0 Response to How to deal with categorical variable (a group of dummy vars) in Multilevel model?
Post a Comment