Hello SAS users,
I am trying to add a level-1 predictor to my model and i am trying to allow the slopes of this predictor to vary across schools (ie random slopes).
I have written three codes for this but i am confused at which one it is. As all three gave me outputs. Can anyone who is familiar with proc mixed help me out?
Thanks!
proc mixed data=me method= reml covtest ;
class school;
model y = ses / s ddfm=bw cl;
random intercept ses / subject=school g type=un s;
run;
OR
proc mixed data=me method= reml covtest ;
class school;
model y = ses / s ddfm=bw cl;
random intercept / subject=school g type=un s;
run;
OR
proc mixed data=me method= reml covtest ;
class school;
model y = ses / s ddfm=bw cl;
random ses / subject=school g type=un s;
run;
The first one, it gives both random intercepts and random slopes. The second gives random intercepts only. The third gives random slopes with a fixed intercept, which is probably almost never useful; although for that reason it may default to random slopes and intercepts, and the results would be the same as the first.
As an aside, technically it’s best practice to only add random slopes it they significantly improve your model fit over random intercepts only. It’s a matter of parsimony.
The first one, it gives both random intercepts and random slopes. The second gives random intercepts only. The third gives random slopes with a fixed intercept, which is probably almost never useful; although for that reason it may default to random slopes and intercepts, and the results would be the same as the first.
As an aside, technically it’s best practice to only add random slopes it they significantly improve your model fit over random intercepts only. It’s a matter of parsimony.
Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.