*Calculating the ICC;
data democ;
set "C:\...\democ"; *replace ... with your path name;
run;
*We know, however, that negaffect has 2 levels of variance because
Some people have more negative affect than others, on average (Between-Person Variation)
And the same person experiences more negative affect on some moments than he/she does on others (Within-Person Variation)
*An Empty Multilevel Model gives us the Intraclass Correlation (ICC),
telling us how much of the variance in negaffect is between people versus within people over time;
PROC MIXED data=democ method=ml covtest cl;
class id;
model negaffect = / s cl ddfm=bw;
random int /solution sub=id type=un g gcorr;
repeated /sub=id type=vc r rcorr;
ods exclude solutionr;
ods output covparms=covsave; *this exports the random effects components for the ICC calculator (below);
run; title;
*ICC calculator (run after the PROC MIXED code above);
proc transpose data=covsave out=icc; id covparm; var estimate; run;
data icc; set icc; icc=UN_1_1_/(UN_1_1_+Residual); run;
title1 "ICC from negaffect empty model";
proc print data =icc noobs label; var icc; run; title1;
*The ICC is .2797 -- which tells us that approx 28% of the variance is between people;
*1 - ICC = 1 - .2797 = .7203, which tells us that approx 72% of the variance is within people;