Multilevel Cross Classified Multi-Member-Hedeker
Multilevel Cross Classified Multi-Member-Hedeker
1 2
⇒ interest is on assessing effects of schools and neighborhoods on • MED: Mother’s education (0,1)
student outcomes
3 4
5 6
PROC MIXED analyses (using default REML estimation) Alternative (simpler) syntax (using default REML estimation)
Null model Null model
PROC MIXED DATA=xw COVTEST; PROC MIXED DATA=xw COVTEST;
CLASS pid sid ; CLASS pid sid ;
MODEL attain = / S; MODEL attain = / S;
RANDOM INT / SUB=pid; RANDOM pid sid;
RANDOM INT / SUB=sid; RUN;
RUN;
Model including verbal reasoning score as a covariate
Model including verbal reasoning score as a covariate
PROC MIXED DATA=xw COVTEST;
PROC MIXED DATA=xw COVTEST; CLASS pid sid;
CLASS pid sid; MODEL attain = vrq / S;
MODEL attain = vrq / S; RANDOM pid sid;
RANDOM INT / SUB=pid; RUN;
RANDOM INT / SUB=sid;
RUN; SAS abbreviation: S=SOLUTION
The Mixed Procedure 103 104 105 106 107 108 109
110 111 112 113 114 115 116
Model Information 117 118 119 120 121 122 123
124 125 126 127 128 129 130
Data Set WORK.XW 131 132 133 134 135 136 137
Dependent Variable ATTAIN 138 139 140 141 142 143 144
Covariance Structure Variance Components 145 146 147 148
Subject Effects PID, SID SID 19 1 2 3 4 5 6 7 8 9 10 11 12 13
Estimation Method REML 14 15 16 17 18 19
Residual Variance Method Profile
Fixed Effects SE Method Model-Based
Degrees of Freedom Method Containment Dimensions
Covariance Parameters 3
Class Level Information Columns in X 1
Columns in Z Per Subject 167
Class Levels Values Subjects 1
Max Obs Per Subject 3435
PID 148 1 2 3 4 5 6 7 8 9 10 11 12 13
14 15 16 17 18 19 20 21 22 23
24 25 26 27 28 29 30 31 32 33 Number of Observations
34 35 36 37 38 39 40 41 42 43
44 45 46 47 48 49 50 51 52 53 Number of Observations Read 3435
54 55 56 57 58 59 60 61 62 63 Number of Observations Used 3435
64 65 66 67 68 69 70 71 72 73 Number of Observations Not Used 0
74 75 76 77 78 79 80 81 82 83
84 85 86 87 88 89 90 91 92 93
94 95 96 97 98 99 100 101 102
9 10
Standard Z Standard Z
Cov Parm Subject Estimate Error Value Pr > Z Cov Parm Subject Estimate Error Value Pr > Z
Intercept PID 1.1300 0.2074 5.45 <.0001 Intercept PID 0.2747 0.06171 4.45 <.0001
Intercept SID 0.3722 0.1743 2.14 0.0164 Intercept SID 0.01436 0.02402 0.60 0.2749
Residual 8.1107 0.2004 40.46 <.0001 Residual 4.2546 0.1050 40.54 <.0001
Standard Standard
Effect Estimate Error DF t Value Pr > |t| Effect Estimate Error DF t Value Pr > |t|
Intercept 5.5017 0.1787 18 30.79 <.0001 Intercept -10.0257 0.2782 18 -36.04 <.0001
VRQ 0.1600 0.002766 3268 57.87 <.0001
11 12
SPSS syntax after reading in Excel file (using default REML) Alternative (simpler) SPSS syntax
13 14
Information Criteria
|------------------------------------|---------| Estimates of Covariance Parameters
|-2 Restricted Log Likelihood |14859.140| |----------------------------------|--------|----------|------|----|-----------------------------------|
|------------------------------------|---------| |Parameter |Estimate|Std. Error|Wald Z|Sig.|95% Confidence Interval |
|Akaike’s Information Criterion (AIC)|14865.140| | | | | | |-----------------------|-----------|
|------------------------------------|---------| | | | | | |Lower Bound |Upper Bound|
|Hurvich and Tsai’s Criterion (AICC) |14865.147| |----------------------------------|--------|----------|------|----|-----------------------|-----------|
|------------------------------------|---------| |Residual |4.254604|.104958 |40.536|.000|4.053785 |4.465372 |
|Bozdogan’s Criterion (CAIC) |14886.563| |-------------------------|--------|--------|----------|------|----|-----------------------|-----------|
|------------------------------------|---------| |Intercept [subject = PID]|Variance|.274656 |.061712 |4.451 |.000|.176821 |.426624 |
|Schwarz’s Bayesian Criterion (BIC) |14883.563| |-------------------------|--------|--------|----------|------|----|-----------------------|-----------|
|----------------------------------------------| |Intercept [subject = SID]|Variance|.014365 |.024020 |.598 |.550|.000542 |.380736 |
The information criteria are displayed in smaller-is-better form. |------------------------------------------------------------------------------------------------------|
a Dependent Variable: ATTAIN. a Dependent Variable: ATTAIN.
15 16
Alternative way to run cross-classified multilevel models Alternative way to run cross-classified multilevel models
• SAS & SPSS perform cross-classified analyses seamlessly, but not • Identify cluster level with fewest number of clusters; here, 148
all software can primary schools and 19 secondary schools
• Create indicator variables for the secondary schools,
• Some hierarchical multilevel software programs can be “tricked” secs1-secs19 (0/1), which indicate the secondary school that a
into running cross-classified models if they allow student belongs to (each student belongs to only one)
– 3-level models • Create a variable cons that equals 1 for all observations in the
– Equality constraints on variances of random effects dataset
– Zero covariances of random effects • At the third level, specify cons as the level-3 ID variable, and the
19 indicator variables secs1-secs19 as random effects with
EQUAL variance and zero covariances
• At the second level, specify the primary school ID nested within
the level-3 ID (pid(cons) in SAS) and specify a random
intercept
17 18
Secondary School Indicator Variables DATA xw2; SET xw;
cons=1;
ID secs1 secs2 secs3 secs4 secs5 secs6 secs7 ... secs19
sid = 1 1 0 0 0 0 0 0 ... 0
ARRAY secschool(19) secs1-secs19;
sid = 2 0 1 0 0 0 0 0 ... 0 DO i = 1 TO 19;
sid = 3 0 0 1 0 0 0 0 ... 0 secschool(i)=0;
sid = 4 0 0 0 1 0 0 0 ... 0 IF sid=i THEN secschool(i)=1;
sid = 5 0 0 0 0 1 0 0 ... 0 END;
sid = 6 0 0 0 0 0 1 0 ... 0
sid = 7 0 0 0 0 0 0 1 ... 0
... ... ... ... ... ... ... ... ... ... PROC MIXED DATA=xw2 COVTEST;
... ... ... ... ... ... ... ... ... ... CLASS pid cons;
sid = 19 0 0 0 0 0 0 0 ... 1 MODEL attain = / S;
RANDOM INT / SUB=pid(cons);
RANDOM secs1-secs19 / SUB=cons TYPE=TOEP(1);
⇒ 19 indicator variables for the 19 secondary schools
RUN;
PID 148 1 2 3 4 5 6 7 8 9 10 11 12 13
14 15 16 17 18 19 20 21 22 23 Number of Observations
24 25 26 27 28 29 30 31 32 33
34 35 36 37 38 39 40 41 42 43 Number of Observations Read 3435
44 45 46 47 48 49 50 51 52 53 Number of Observations Used 3435
54 55 56 57 58 59 60 61 62 63 Number of Observations Not Used 0
64 65 66 67 68 69 70 71 72 73
74 75 76 77 78 79 80 81 82 83
84 85 86 87 88 89 90 91 92 93
21 22
23 24
Performing EM optimization: ------------------------------------------------------------------------------
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
Performing gradient-based optimization: -----------------------------+------------------------------------------------
_all: Identity |
Iteration 0: log restricted-likelihood = -8575.3795 sd(R.SID) | .6101043 .1428677 .3855483 .965449
Iteration 1: log restricted-likelihood = -8575.3795 -----------------------------+------------------------------------------------
PID: Identity |
Computing standard errors: sd(_cons) | 1.063027 .0975383 .88806 1.272467
-----------------------------+------------------------------------------------
Mixed-effects REML regression Number of obs = 3435 sd(Residual) | 2.847926 .0351921 2.77978 2.917744
------------------------------------------------------------------------------
----------------------------------------------------------- LR test vs. linear regression: chi2(2) = 280.57 Prob > chi2 = 0.0000
| No. of Observations per Group
Group Variable | Groups Minimum Average Maximum Note: LR test is conservative and provided only for reference.
----------------+------------------------------------------
_all | 1 3435 3435.0 3435
PID | 148 1 23.2 72
-----------------------------------------------------------
Wald chi2(0) = .
⇒ Stata estimates SDs (and not variances) for the random effects by
Log restricted-likelihood = -8575.3795 Prob > chi2 = . default; for variance estimates add the option variance
------------------------------------------------------------------------------
ATTAIN | Coef. Std. Err. z P>|z| [95% Conf. Interval] . xtmixed ATTAIN || _all: R.SID || PID:, reml variance
-------------+----------------------------------------------------------------
_cons | 5.501727 .1786809 30.79 0.000 5.151519 5.851935
------------------------------------------------------------------------------
25 26
Null model (no covariates), Residual var = 8.0873, Primary var = Subject k nested within crossing of primary schools i and secondary
0.9144, Secondary var = 0.3376, Interaction var = 0.2335 schools j
33 34
Example: Leckie, G. (2013). Multiple Membership Multilevel Models. LEMMA Excel file: nursedat2.xlsx - some subjects seen by only 1 nurse
VLE Module 13. (http://www.bristol.ac.uk/cmm/learning/course.html)
Simulated data from 1,000 patients who were treated in all by 25 nurses: 400 treated by only one
nurse, 300 treated by two nurses, 200 by three nurses, and 100 by four nurses.
• patient: Patient ID
• satis: Patient post-op satisfaction (mean=0, std=1)
• assess: Patient pre-op assessment (mean=0, std=1); higher scores are better
• nurses: Number of nurses seen by the patient (1 to 4)
• n1st: Nurse ID for patient’s 1st nurse
• n2nd: Nurse ID for patient’s 2nd nurse
• n3rd: Nurse ID for patient’s 3rd nurse
• n4th: Nurse ID for patient’s 4th nurse
• p1: Proportion of time with nurse 1
• p2: Proportion of time with nurse 2
. ..
• .. .
• p25: Proportion of time with nurse 25 value of 1 for only one of the variables p1 to p25 (all others equal 0)
• h1: Job Happiness score for nurse 1
• h2: Job Happiness score for nurse 2
. ..
• .. .
• h25: Job Happiness score for nurse 25
35 36
Excel file: nursedat2.xlsx - some subjects seen by 2 nurses Excel file: nursedat2.xlsx - Job Happiness values (mean=0, sd=1) of
nurses
Two of the variables p1 to p25 are non-zero and their sum equals 1
Similarly, for patients seen by 3 (or 4) nurses: three (or four) of the
variables p1 to p25 are non-zero and their sum equals 1 Nurse-level covariate doesn’t change value within a column (same
nurse), only across columns h1 to h25
37 38
39 40
p17 p17 1000 0.0298700 0.1288965 0 1.0000000 h20 h20 1000 1.0973895 0 1.0973895 1.0973895
p18 p18 1000 0.0405200 0.1626130 0 1.0000000 h21 h21 1000 -0.9833028 0 -0.9833028 -0.9833028
p19 p19 1000 0.0388300 0.1544260 0 1.0000000 h22 h22 1000 -0.2067423 0 -0.2067423 -0.2067423
p20 p20 1000 0.0327900 0.1439258 0 1.0000000 h23 h23 1000 -0.6376706 0 -0.6376706 -0.6376706
p21 p21 1000 0.0469600 0.1701150 0 1.0000000 h24 h24 1000 0.1376409 0 0.1376409 0.1376409
p22 p22 1000 0.0401100 0.1623559 0 1.0000000 h25 h25 1000 0.2539080 0 0.2539080 0.2539080
p23 p23 1000 0.0376800 0.1503983 0 1.0000000 cons 1000 1.0000000 0 1.0000000 1.0000000
p24 p24 1000 0.0357600 0.1463942 0 1.0000000 happiness 1000 -0.0231534 0.8019001 -1.9858233 1.7678539
p25 p25 1000 0.0356100 0.1463354 0 1.0000000 --------------------------------------------------------------------------------------------
h1 h1 1000 1.7678539 0 1.7678539 1.7678539
h2 h2 1000 -0.0044529 0 -0.0044529 -0.0044529
h3 h3 1000 -0.0398703 0 -0.0398703 -0.0398703
h4 h4 1000 -0.3772039 0 -0.3772039 -0.3772039
h5 h5 1000 -1.3820966 0 -1.3820966 -1.3820966
h6 h6 1000 0.9227986 0 0.9227986 0.9227986
h7 h7 1000 -0.1143707 0 -0.1143707 -0.1143707
h8 h8 1000 -1.3080722 0 -1.3080722 -1.3080722
h9 h9 1000 0.7863722 0 0.7863722 0.7863722
h10 h10 1000 1.0340058 0 1.0340058 1.0340058
h11 h11 1000 1.5630561 0 1.5630561 1.5630561
h12 h12 1000 -1.4213433 0 -1.4213433 -1.4213433
h13 h13 1000 0.5874567 0 0.5874567 0.5874567
h14 h14 1000 -0.3803294 0 -0.3803294 -0.3803294
h15 h15 1000 1.2916487 0 1.2916487 1.2916487
h16 h16 1000 -1.9858233 0 -1.9858233 -1.9858233
h17 h17 1000 1.0496269 0 1.0496269 1.0496269
h18 h18 1000 -1.0102353 0 -1.0102353 -1.0102353
h19 h19 1000 -0.7836885 0 -0.7836885 -0.7836885
41 42
SAS syntax for multi-membership multilevel models NULL MODEL
The Mixed Procedure
43 44
Fit Statistics
Fit Statistics
-2 Log Likelihood 2686.0
AIC (smaller is better) 2692.0 -2 Log Likelihood 2368.8
AICC (smaller is better) 2692.0 AIC (smaller is better) 2376.8
BIC (smaller is better) 2686.0 AICC (smaller is better) 2376.9
BIC (smaller is better) 2368.8
45 46
47 48
Type III Tests of Fixed Effects
49 50
------------------------------------------------------------------------------
satis | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
assess | .4912155 .0252988 19.42 0.000 .4416306 .5408003
happiness | .2935754 .0870952 3.37 0.001 .1228719 .4642789
_cons | -.0313536 .0857909 -0.37 0.715 -.1995006 .1367934
------------------------------------------------------------------------------
51 52
i=1
55 56