turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- Analytics
- /
- Stat Procs
- /
- How to calculate the correlation when dealing with...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-02-2016 04:36 AM - edited 11-02-2016 06:22 AM

Dear all,

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, however, time is divided into categories, whereas I want to handle time as a continuous variable.

The difficulty is that I am working with repeated measures (2 observations per participant). I do not know exactly how to handle this in my syntax.

My data looks as follows. So, for each participant I have 48 records (24 hours for each day). Since I want to correlate the proportion of 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.

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;

I've thought about the following syntax (adapted from: http://www2.sas.com/proceedings/sugi29/198-29.pdf). 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.

ods graphics on;

**PROC** **mixed** DATA=test method=reml covtest plots(maxpoints=none);

Class subject day (ref=first) hour (ref=first);

MODEL prot_day = proportion_protein hour proportion_protein*hour / solution ddfm=kr ;

Random prot_hour /type=un subject=subject v vcorr;

Repeated day / type=un subject=hour(subject) r rcorr;

**run**;

ods graphics off;

After running this syntax, log says the following:

NOTE: Convergence criteria met.

NOTE: PROCEDURE MIXED used (Total process time):

real time 9.96 seconds

cpu time 9.82 seconds

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 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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-03-2016 08:55 AM

In order to treat day as a repeated effect, you need to include it in the model statement. What happens with something like:

```
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;
```

lsmeans proportion_protein|hour|day/cl;
run;
ods graphics off;

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.

Also, this approach assumes that hour is not a repeated measure on a subject, which is probably not a good assumption. 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. Alternatively, you might consider day as a random effect, and look at marginal effects over day for proportion protein and hour.

Steve Denham