BookmarkSubscribeRSS Feed
jsberger
Obsidian | Level 7

Hi All,

 

I've got multi-level data (students nested within teachers), and i have some construct scale scores at the student level (level-1) and teacher level (level-2). For reporting purposes, i have to provide correlations among these scale scores, and i'm wondering how to go about this.  I can aggregate the student data (i.e., mean scores) and generate correlations, or i can use the full dataset, where the teacher scores will be replicated c times, where c = the number of students taught by a teacher. 

 

I came across a PDF on the HLM software website that discusses cross-level correlation calculation, but i don't find it to be particularly clear: http://www.ssicentral.com/hlm/help7/howto/How_to_Calculate_cross-level_correlations.pdf

 

Does anyone here have any advice, or experience with calculating these correlations as in the hyperlink above?

 

Thanks in advance,

 

Jason

1 REPLY 1
jsberger
Obsidian | Level 7

Hi All,

So here's what i have developed thus far in response to my question below, using the sample file created using:

data _null_;
set sample;
file "C:\Users\Jason\Desktop\sample.txt";
put teacherid student_id schoolid post_classman_ability post_pck_ability;
file print;
put teacherid student_id schoolid post_classman_ability post_pck_ability;
run;  

 

If i correlate two variables using all available data (including duplicate level-2 values), i get a correlation of -.12783.

 

**correlation between two retaining all data;
proc corr data=sample;
var post_classman_ability post_pck_ability;
run;

 

If i use a mixed model with the student-level variable as the DV and the teacher as the IV, obtaining the var-covariance matrix of fixed effects (which includes an intercept and the post_pck_ability predictor fixed effects), i can then use that covariance matrix to calculate the cross-level correlation as specified in the link in the original post.

 

**model with student-level measure as dv and teacher-level measure as iv;
proc mixed data=tssc_y1 method=ml;
class schoolid;
model post_classman_ability = post_pck_ability/ solution corrb covb;
random intercept/ subject=teacherid type=un;
ods output covb=covb;
run;

 

The IML syntax below attempts to calculate the cross-level correlation, obtaining a value of -.057711.  I'm glad to see the sign in the same direction, but i'm wondering if the decrease from -.12 down to .-05 seems reasonable, of if i'm missing something.

 

**correlation from covariance;
proc iml;
use covb;
read all var {Col1 Col2} into cov_mat[colname=varNames];
print cov_mat;
start Cov2Corr(S);
**grab the variances of each variable;
var_mat=(vecdiag(S))`;
*print var_mat;
**caculate sd by taking square root of product;
prod_sd=sqrt(var_mat[1,1]#var_mat[1,2]);
*print prod_sd;
**divide each element of covariance matrix by the prod_sd, focus on covariance cells;
r_mat=S/prod_sd;
r=r_mat[1,ncol(r_mat)];
return R;
finish;
r=Cov2Corr(cov_mat);

n=861;
t=sqrt(n-2)*sqrt((r*r)/(1-r*r));
p_onetail=1-probt(t,n-2);
p_twotail=(1-probt(abs(t),n-2))*2;
print r p_onetail p_twotail;
quit;

 

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is ANOVA?

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.

Discussion stats
  • 1 reply
  • 1530 views
  • 0 likes
  • 1 in conversation