<?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: How to calculate the correlation when dealing with repeated measures in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-calculate-the-correlation-when-dealing-with-repeated/m-p/308997#M16355</link>
    <description>&lt;P&gt;In order to treat day as a repeated effect, you need to include it in the model statement. &amp;nbsp;What happens with something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods graphics on;
PROC mixed DATA=test method=reml  plots(maxpoints=none);
Class subject day (ref=first) hour (ref=first);
MODEL prot_day = proportion_protein|hour|day / solution ddfm=kr ;
Random prot_hour /type=un subject=subject v vcorr;
Repeated day / type=un subject=hour(subject) r rcorr;&lt;BR /&gt;lsmeans proportion_protein|hour|day/cl;
run;
ods graphics off;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Not quite sure about this, because I think you will have a LOT of values for prot_hour, and fitting an unstructured covariance structure may lead to convergence or estimation problems.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, this approach assumes that hour is not a repeated measure on a subject, which is probably not a good assumption. &amp;nbsp;You may need to recast day and hour into a single time variable, if you want to fully capture the repeated nature of the design. &amp;nbsp;Alternatively, you might consider day as a random effect, and look at marginal effects over day for proportion protein and hour.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Steve Denham&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 03 Nov 2016 12:55:41 GMT</pubDate>
    <dc:creator>SteveDenham</dc:creator>
    <dc:date>2016-11-03T12:55:41Z</dc:date>
    <item>
      <title>How to calculate the correlation when dealing with repeated measures</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-calculate-the-correlation-when-dealing-with-repeated/m-p/308701#M16342</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to assess the relationship between time of day of (protein) intake and overall (protein) intake. Therefore, I want to calculate corelations between the proportion ingested during each hour of the day and the total amount ingested over the entire day. In the end I would like to create a graph such as the one shown in the attachment. In this example,&amp;nbsp;however, time is divided into categories, whereas I want to handle time as a continuous variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The difficulty is that I am working with repeated measures (2 observations per participant). I do not know exactly how to handle&amp;nbsp;this in my syntax.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My data looks as follows. So, for each participant I have 48 records (24&amp;nbsp;hours for each day). Since I want to correlate the proportion of&amp;nbsp;protein ingested during each hour of the day, I created the variable (proportion_protein), by dividing protein_hour by protein_day and multiplying it by 100.&lt;/P&gt;&lt;PRE&gt;data test1;
input subject:12. day:12. hours:12. protein_day:12. protein_hour:12. proportion_protein:12.;
datalines;
1   1  8 99   0   0
1   1  9 99  11  11
1   1 10 99   0   0 
...
...
...
750 2 22 56   0   0
750 2 23 56 0.8 1.5
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've thought about the following syntax (adapted from: &lt;A href="http://www2.sas.com/proceedings/sugi29/198-29.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi29/198-29.pdf&lt;/A&gt;). However I do not know if I am correct. Do I have to add both proportion_protein and hour into the model, or is this not needed? I have the feeling that if I do not do it, SAS won't know which proportions belong to which hours of the day.&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;ods&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;graphics&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;on&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;PROC&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;mixed&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;DATA&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=test &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;method&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=reml &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;covtest&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; plots(maxpoints=none); &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;Class&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; subject day (ref=first) hour (ref=first);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;MODEL&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; prot_day = proportion_protein hour proportion_protein*hour / &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;solution&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;ddfm&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;=kr ;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;Random&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; prot_hour /&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;type&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;=un &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;subject&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;=subject&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;v&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;vcorr&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;Repeated&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; day / &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;type&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;=un &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;subject&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;=hour(subject) &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;r&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;rcorr&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;ods&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;graphics&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;off&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After running this syntax, log says the following:&lt;/P&gt;&lt;P&gt;NOTE: Convergence criteria met.&lt;/P&gt;&lt;P&gt;NOTE: PROCEDURE MIXED used (Total process time):&lt;/P&gt;&lt;P&gt;real time 9.96 seconds&lt;/P&gt;&lt;P&gt;cpu time 9.82 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do not exacly know if this is the outcome I needed. Also no graphics are shown. Is it even possible to translate this data into&amp;nbsp;a graph as the one shown in the attachement. Or is this not possible? Can someone maybe help me with this? Many thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/13102i2635572798BC773E/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="Correlation.png" title="Correlation.png" /&gt;</description>
      <pubDate>Wed, 02 Nov 2016 10:22:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-calculate-the-correlation-when-dealing-with-repeated/m-p/308701#M16342</guid>
      <dc:creator>teuni</dc:creator>
      <dc:date>2016-11-02T10:22:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the correlation when dealing with repeated measures</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-calculate-the-correlation-when-dealing-with-repeated/m-p/308997#M16355</link>
      <description>&lt;P&gt;In order to treat day as a repeated effect, you need to include it in the model statement. &amp;nbsp;What happens with something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods graphics on;
PROC mixed DATA=test method=reml  plots(maxpoints=none);
Class subject day (ref=first) hour (ref=first);
MODEL prot_day = proportion_protein|hour|day / solution ddfm=kr ;
Random prot_hour /type=un subject=subject v vcorr;
Repeated day / type=un subject=hour(subject) r rcorr;&lt;BR /&gt;lsmeans proportion_protein|hour|day/cl;
run;
ods graphics off;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Not quite sure about this, because I think you will have a LOT of values for prot_hour, and fitting an unstructured covariance structure may lead to convergence or estimation problems.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, this approach assumes that hour is not a repeated measure on a subject, which is probably not a good assumption. &amp;nbsp;You may need to recast day and hour into a single time variable, if you want to fully capture the repeated nature of the design. &amp;nbsp;Alternatively, you might consider day as a random effect, and look at marginal effects over day for proportion protein and hour.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Steve Denham&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2016 12:55:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-calculate-the-correlation-when-dealing-with-repeated/m-p/308997#M16355</guid>
      <dc:creator>SteveDenham</dc:creator>
      <dc:date>2016-11-03T12:55:41Z</dc:date>
    </item>
  </channel>
</rss>

