<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: MIXED Multilevel Cross-Level Correlation in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/MIXED-Multilevel-Cross-Level-Correlation/m-p/434847#M22932</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;So here's what i have developed thus far in response to my question below, using the sample file created using:&lt;/P&gt;
&lt;P&gt;data _null_;&lt;BR /&gt; set sample;&lt;BR /&gt; file "C:\Users\Jason\Desktop\sample.txt";&lt;BR /&gt; put teacherid student_id schoolid post_classman_ability post_pck_ability;&lt;BR /&gt; file print;&lt;BR /&gt; put teacherid student_id schoolid post_classman_ability post_pck_ability;&lt;BR /&gt; run;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If i correlate two variables using all available data (including duplicate level-2 values), i get a correlation of -.12783.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;**correlation between two retaining all data;&lt;BR /&gt;proc corr data=sample;&lt;BR /&gt; var post_classman_ability post_pck_ability;&lt;BR /&gt; run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;**model with student-level measure as dv and teacher-level measure as iv;&lt;BR /&gt;proc mixed data=tssc_y1 method=ml;&lt;BR /&gt; class schoolid;&lt;BR /&gt; model post_classman_ability = post_pck_ability/ solution corrb covb;&lt;BR /&gt; random intercept/ subject=teacherid type=un;&lt;BR /&gt; ods output covb=covb;&lt;BR /&gt; run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The IML syntax below attempts to calculate the cross-level correlation, obtaining a value of -.057711.&amp;nbsp; 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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;**correlation from covariance;&lt;BR /&gt;proc iml;&lt;BR /&gt; use covb;&lt;BR /&gt; read all var {Col1 Col2} into cov_mat[colname=varNames];&lt;BR /&gt; print cov_mat;&lt;BR /&gt; start Cov2Corr(S);&lt;BR /&gt; **grab the variances of each variable;&lt;BR /&gt; var_mat=(vecdiag(S))`;&lt;BR /&gt; *print var_mat;&lt;BR /&gt; **caculate sd by taking square root of product;&lt;BR /&gt; prod_sd=sqrt(var_mat[1,1]#var_mat[1,2]);&lt;BR /&gt; *print prod_sd;&lt;BR /&gt; **divide each element of covariance matrix by the prod_sd, focus on covariance cells;&lt;BR /&gt; r_mat=S/prod_sd;&lt;BR /&gt; r=r_mat[1,ncol(r_mat)];&lt;BR /&gt; return R;&lt;BR /&gt; finish;&lt;BR /&gt; r=Cov2Corr(cov_mat);&lt;/P&gt;
&lt;P&gt;n=861;&lt;BR /&gt; t=sqrt(n-2)*sqrt((r*r)/(1-r*r));&lt;BR /&gt; p_onetail=1-probt(t,n-2);&lt;BR /&gt; p_twotail=(1-probt(abs(t),n-2))*2;&lt;BR /&gt;print r p_onetail p_twotail;&lt;BR /&gt; quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 07 Feb 2018 13:46:17 GMT</pubDate>
    <dc:creator>jsberger</dc:creator>
    <dc:date>2018-02-07T13:46:17Z</dc:date>
    <item>
      <title>MIXED Multilevel Cross-Level Correlation</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/MIXED-Multilevel-Cross-Level-Correlation/m-p/434444#M22902</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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.&amp;nbsp; 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.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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:&amp;nbsp;&lt;A href="http://www.ssicentral.com/hlm/help7/howto/How_to_Calculate_cross-level_correlations.pdf" target="_self"&gt;http://www.ssicentral.com/hlm/help7/howto/How_to_Calculate_cross-level_correlations.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does anyone here have any advice, or experience with calculating these correlations as in the hyperlink above?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jason&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2018 01:55:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/MIXED-Multilevel-Cross-Level-Correlation/m-p/434444#M22902</guid>
      <dc:creator>jsberger</dc:creator>
      <dc:date>2018-02-06T01:55:48Z</dc:date>
    </item>
    <item>
      <title>Re: MIXED Multilevel Cross-Level Correlation</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/MIXED-Multilevel-Cross-Level-Correlation/m-p/434847#M22932</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;So here's what i have developed thus far in response to my question below, using the sample file created using:&lt;/P&gt;
&lt;P&gt;data _null_;&lt;BR /&gt; set sample;&lt;BR /&gt; file "C:\Users\Jason\Desktop\sample.txt";&lt;BR /&gt; put teacherid student_id schoolid post_classman_ability post_pck_ability;&lt;BR /&gt; file print;&lt;BR /&gt; put teacherid student_id schoolid post_classman_ability post_pck_ability;&lt;BR /&gt; run;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If i correlate two variables using all available data (including duplicate level-2 values), i get a correlation of -.12783.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;**correlation between two retaining all data;&lt;BR /&gt;proc corr data=sample;&lt;BR /&gt; var post_classman_ability post_pck_ability;&lt;BR /&gt; run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;**model with student-level measure as dv and teacher-level measure as iv;&lt;BR /&gt;proc mixed data=tssc_y1 method=ml;&lt;BR /&gt; class schoolid;&lt;BR /&gt; model post_classman_ability = post_pck_ability/ solution corrb covb;&lt;BR /&gt; random intercept/ subject=teacherid type=un;&lt;BR /&gt; ods output covb=covb;&lt;BR /&gt; run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The IML syntax below attempts to calculate the cross-level correlation, obtaining a value of -.057711.&amp;nbsp; 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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;**correlation from covariance;&lt;BR /&gt;proc iml;&lt;BR /&gt; use covb;&lt;BR /&gt; read all var {Col1 Col2} into cov_mat[colname=varNames];&lt;BR /&gt; print cov_mat;&lt;BR /&gt; start Cov2Corr(S);&lt;BR /&gt; **grab the variances of each variable;&lt;BR /&gt; var_mat=(vecdiag(S))`;&lt;BR /&gt; *print var_mat;&lt;BR /&gt; **caculate sd by taking square root of product;&lt;BR /&gt; prod_sd=sqrt(var_mat[1,1]#var_mat[1,2]);&lt;BR /&gt; *print prod_sd;&lt;BR /&gt; **divide each element of covariance matrix by the prod_sd, focus on covariance cells;&lt;BR /&gt; r_mat=S/prod_sd;&lt;BR /&gt; r=r_mat[1,ncol(r_mat)];&lt;BR /&gt; return R;&lt;BR /&gt; finish;&lt;BR /&gt; r=Cov2Corr(cov_mat);&lt;/P&gt;
&lt;P&gt;n=861;&lt;BR /&gt; t=sqrt(n-2)*sqrt((r*r)/(1-r*r));&lt;BR /&gt; p_onetail=1-probt(t,n-2);&lt;BR /&gt; p_twotail=(1-probt(abs(t),n-2))*2;&lt;BR /&gt;print r p_onetail p_twotail;&lt;BR /&gt; quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2018 13:46:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/MIXED-Multilevel-Cross-Level-Correlation/m-p/434847#M22932</guid>
      <dc:creator>jsberger</dc:creator>
      <dc:date>2018-02-07T13:46:17Z</dc:date>
    </item>
  </channel>
</rss>

