440 likes | 660 Vues
Multilevel Linear Modeling. aka HLM. The Design. We have data at two different levels In this case, 7,185 students (Level 1) Nested within 160 Schools (Level 2) We want to investigate effects at both levels. Get the Data. Download data file in XLS format Print the Cheat-Sheet
E N D
Multilevel Linear Modeling aka HLM
The Design • We have data at two different levels • In this case, 7,185 students (Level 1) • Nested within 160 Schools (Level 2) • We want to investigate effects at both levels.
Get the Data • Download data file in XLS format • Print the Cheat-Sheet • Boot up SAS and import the data • name the imported member “HLM” • The first analysis will be have no predictors, only means.
Level 1 Equation • The math achievement of the ith student at the jth school = • the intercept for the jth school (the mean at that school) • + error. Note: We are using “0” instead of “a” to stand for intercept.
Level 2 Equation • The intercept (mean match achievement) at the jth school = • The average intercept (mean) across schools • + (group j intercept) – (overall intercept) • the effect of being in the jth school.
Combine the Two Equations • Substitute (00 + 0j), from the Level 2 equation, for 0jin the Level 1 equation • A student’s score = • The average intercept across schools • + the effect of being at the jthschool • + other stuff
SAS title'Model 1: Unconditional Means Model, Intercepts Only'; optionsformdlim='-'pageno=min nodate; procmixeddata = covtestnoclprint; class School; modelMathAch = / solution; random intercept / subject = School; run;
Fixed Effects • Effects that are constant across schools. • modelMathAch=/ • No effect follows "=," the only parameter estimated will be mean across schools.
Random Effects • Effects that vary across schools. • random intercept / subject = School; • There is significant variance across schools (8.6097) in intercepts. • And among students within schools (39.1487)
Intraclass Correlation • the proportion of the variance in MathAch that is due to differences among schools • = (that due to schools) / (total variance) • = 8.6097 / (8.6097 + 39.1487) = 18%. • Next, we are going to add a Level 2 predictor, MeanSES. Do note that this variable has been centered to mean 0.
Add a Level 2 Predictor • The intercept (mean math achievement) at the jth school = • The average intercept across schools when all predictors have value 0 (the mean, since we centered MeanSES). • + the effect of being in a school with the MeanSES of school j • + the effect of everything else on which j differs from the other schools.
title'Model 2: Including Effects of School (Level 2) Predictors'; title2'-- predicting MathAch from MeanSES'; run; procmixedcovtestnoclprint; class school; modelMathAch = MeanSES / solutionddfm = bw; random intercept / subject = school; run; “bw” specifies between/within partitioning of df
Fixed Effects • MeanSES was centered about zero. That is, transformed to mean zero. • Math Achievement = 12.6495 + 5.8635(School MeanSES – GrandMean SES) • Each 1 point increase in School’s mean SES increases achievement by 5.86 points.
Random Effects • Including school mean SES in model reduced variance in intercepts from 8.6097 to 2.6357 = a drop of 5.974. • School mean SES accounts for 5.974/8.6097 = 69% of the variance among schools.
Unexplained Variance • After accounting for SES, MathAch intercepts (means) still differ significantly across schools (z = 6.53) • Residual variance = 2.6357 (among schools) + 39.1578 (within schools) = 41.7935. • 2.6357/41.7935 = 6.3% remains to be explained by some other Level 2 predictor.
Use a Level 1 Predictor • Score for the ijthstudent = the intercept for the jth school + the effect of this student’s SES + other things involving that student. • Student SES will be centered by subtracting from it the mean SES at the student’s school
Level 2 Equations • Have dropped the MeanSAS predictor • Need a random intercept and a random slope. • Intercept for School j = Grand intercept + effect of being in School j
Slope (for relating student’s SES to MathAch) at School j = The grand slope + the effect (on slope) of being at School j
Combined Equation • The fixed effects • The random effects
title'Model 3: Including Effects of Student-Level Predictors'; title2'--predicting MathAch from cSES'; data HLM2; set HLM; cSES = SES - MeanSES; run; procmixeddata = hsbcnoclprintcovtestnoitprint; class School; modelMathAch = cSES / solutionddfm = bwnotest; random intercept cSES / subject = School type = un; run;
Fixed Effects • estimated MathAch for a student whose SES is average for his or her school is 12.6493 • average slope, across schools, for predicting MathAch from student SES is 2.1932, which is significantly different from zero
Random Effects • The estimated variance in intercepts, across schools, is a significant 8.6769, even after controlling for student SES.
The correlation between School Intercept and School Slope is a nonsignificant .051.
The variance in slopes (for predicting MathAch from student SES) is a significant .694. • The slopes differ significantly across schools.
There remains significant within-school variance, 36.7, after controlling for student SES. SES accounted for 39.1487-36.7006 – 2.4481 units of variance, or 2.4881/39.1487* = 6.25% of the within-school variance. *See Slide 9
Predictors at Both Levels • Level 1: Student’s SES • Level 2: School mean SES • And a new Level 2 predictor, whether the school is in the public sector (0) or is Catholic (1).
title'Model 4: Model with Predictors From Both Levels and Interactions'; procmixednoclprintcovtestnoitprint; class School; modelmathach = MeanSES sector cSESMeanSES*Sector MeanSES*cSES Sector*cSESMeanSES*Sector*cSES/ solutionddfm = bwnotest; random intercept cSES/ subject= School type = un; run;
Nonsignificant Fixed Effects • Without further comment, I shall drop these two nonsignificant interactions from the model
. Our Reduced Model • Level 1 • Level 2, intercepts • Level 2, slopes
Combined Equation • Fixed Effects • Grand intercept • Overall slope for School SES (Predictor 1) • Overall slope School Sector (Predictor 2) • Overall slope for Student SES • Interaction between School SES and Student SES • Interaction between School Sector and Student SES
Random Effects • Effect on intercept of being at School j • Effect on slope being at School j • Everything else affecting Student i at School j
title'Model 5: Model with Two Interactions Deleted'; title2'--predicting mathach from meanses, sector, cses and '; title3'cross level interaction of meanses and sector with cses'; run; procmixednoclprintcovtestnoitprint; class School; modelMathAch = MeanSES Sector cSESMeanSES*cSES Sector*cSES / solutionddfm = bwnotest; random intercept cSES / subject = School type= un; procmeansmeanq1q3minmaxskewnesskurtosis; varMeanSES Sector cSES; run;
Interpret New Effects • Sector: Math achievement is higher at Catholic Schools • MeanSES x cSES: the slopes for predicting MathAch from cSES differ across levels of MeanSES. • Sector x cSES: the slopes for predicting MathAch from cSES differ between public and Catholic schools
Sector x cSES • In the combined equation, substitute 0 for value of sector to get equation for public schools • And 1 to get equation for Catholic schools • Public: 12.11+ 5.34(MeanSES) + 2.94(cSES) + 1.04(MeanSES)(cSES) • Catholic: 13.33+ 5.34(MeanSES) + 1.30(cSES) + 1.04(MeanSES)(cSES)
Intercept higher for Catholic than for public – MathAch higher at Catholic schools. • Slope for student SES higher at public schools than at Catholic schools.
MeanSES x cSES • Find Q1, Q2, and Q3 for School SES • Substitute the quartile values into the combined equation to get one equation for each quartile. • For each of two values (-3, +3) of cSES, predict MathAch at each value with each equation. • Prepare table and plot of predicted values.
Random Effects • UN(1,1): The intercepts still differ significantly across schools.
UN(2,1): No significant correlation between intercepts and slopes. • UN(2,2): The slopes (predicting MathAch from cSES) do not differ significantly across schools. • I shall drop cSES from the random effects.
Trimmed Model title'Model 6: Simpler Model Without cSES Slopes'; procmixednoclprintcovtestnoitprint; class School; modelMathAch = MeanSES Sector cSESMeanSES*cSES Sector*cSES / solutionddfm = bwnotest; random intercept / subject = School; run;
Effects of Trimming • All of the fixed effects are still significant. • Intercepts still differ significantly across schools. • The Log Likelihood statistic has increased from 46503.7 to 46504.8, indicating slightly poorer fit. • We can evaluate the difference in Log Likelihood statistics via Chi-square on 2 df. p = .58.