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
- /
- SAS Programming
- /
- SAS Procedures
- /
- Can't Figure Out Repeated Measures ANOVA Syntax

Topic Options

- 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
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-19-2011 07:19 PM

Hi SAS Community!

I have done a fair bit of macro programming with SAS and lots of straight-forward analyses, but nothing complex and now I am a overwhelmed. Perhaps you can help? I have an experimental design:

* Treatments: A, B, Sham

* Parameters: just one

* Measurements: baseline, T1 - T4

-> so one parameter measured before and then four times after each intervention

Each subject was exposed to all three treatments (different days) so the treatments and the measurements are repeated. (If that's the correct way to say it).

I want to know whether treatment modulates the parameter and how it relates to time, so I thought a two-way repeated measures ANOVA would do be a nice start, followed by Tukey post-hoc test to see if A and B are dif from each other, or just sham. I suppose I could use Dennet post hoc test instead since sham is involved.

I may also want to do a separate model with an interaction term.

What would be the complete SAS syntax for this? I can structure the data as needed (e.g. wide or stacked) but right now I have it like this:

SubjectID Intervention Timepoint Value

===============================

1 A Base 8

1 A T1 19

1 A T2 12

1 A T3 19

1 A T4 13

1 B Base 13

1 B T1 19

1 B T2 11

1 B T3 10

1 B T4 9

1 Sham Base 2

1 Sham T1 3

1 Sham T2 5

1 Sham T3 3

1 Sham T4 4

2 A Base

...

etc.

I was thinking something like

proc glm

class intervention timepoint;

model value = intervention timepoint;

means group / cldiff tukey;

run;

But this is not repeated measures. And I don't even know if this is right. Can you please advise? I can restructure the data however needed, the main thing is I need to do two-way repeated measure anova on the given experiment design.

Thanks!

-Bob Message was edited by: Bob291032

I have done a fair bit of macro programming with SAS and lots of straight-forward analyses, but nothing complex and now I am a overwhelmed. Perhaps you can help? I have an experimental design:

* Treatments: A, B, Sham

* Parameters: just one

* Measurements: baseline, T1 - T4

-> so one parameter measured before and then four times after each intervention

Each subject was exposed to all three treatments (different days) so the treatments and the measurements are repeated. (If that's the correct way to say it).

I want to know whether treatment modulates the parameter and how it relates to time, so I thought a two-way repeated measures ANOVA would do be a nice start, followed by Tukey post-hoc test to see if A and B are dif from each other, or just sham. I suppose I could use Dennet post hoc test instead since sham is involved.

I may also want to do a separate model with an interaction term.

What would be the complete SAS syntax for this? I can structure the data as needed (e.g. wide or stacked) but right now I have it like this:

SubjectID Intervention Timepoint Value

===============================

1 A Base 8

1 A T1 19

1 A T2 12

1 A T3 19

1 A T4 13

1 B Base 13

1 B T1 19

1 B T2 11

1 B T3 10

1 B T4 9

1 Sham Base 2

1 Sham T1 3

1 Sham T2 5

1 Sham T3 3

1 Sham T4 4

2 A Base

...

etc.

I was thinking something like

proc glm

class intervention timepoint;

model value = intervention timepoint;

means group / cldiff tukey;

run;

But this is not repeated measures. And I don't even know if this is right. Can you please advise? I can restructure the data however needed, the main thing is I need to do two-way repeated measure anova on the given experiment design.

Thanks!

-Bob Message was edited by: Bob291032

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

Posted in reply to Bob291032

03-20-2011 10:02 AM

This page is helpful and should answer your questions, but your code is missing a REPEATED statement:

http://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_glm_sect036....

Regards,

Mark

http://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_glm_sect036....

Regards,

Mark

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

Posted in reply to mfisher

03-20-2011 01:29 PM

Thank you for replying, but that doesn't really address my questions:

What do you think about using a two-way repeated measures ANOVA for the scenario I outlined? I had heard some discussion of using mixed effects models but it was over my head.

What is the syntax for a two-way repeated measures ANOVA? I've ran the code for one-way but I am confused how to to two way. For instance, do I want something like:

Base T1 T2 T3 T4 = intervention

OR

Value = intervention time

Thanks.

-Bob

What do you think about using a two-way repeated measures ANOVA for the scenario I outlined? I had heard some discussion of using mixed effects models but it was over my head.

What is the syntax for a two-way repeated measures ANOVA? I've ran the code for one-way but I am confused how to to two way. For instance, do I want something like:

Base T1 T2 T3 T4 = intervention

OR

Value = intervention time

Thanks.

-Bob

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

Posted in reply to Bob291032

03-20-2011 02:10 PM

The topic of repeated measures is large and complex, and I don't think the discussion forum can really address all the issues that you need to consider (since you admit that you don't know too much about the subject). The approach to repeated measures in GLM is very different from the mixed-model approach (such as in MIXED or GLIMMIX, or even GENMOD). I recommend you read:

http://www.ats.ucla.edu/stat/sas/library/mixedglm.pdf

by Russ Wolfinger and co-author. It is now somewhat out of date (lots of new features in MIXED, etc.), but this may get you started.

http://www.ats.ucla.edu/stat/sas/library/mixedglm.pdf

by Russ Wolfinger and co-author. It is now somewhat out of date (lots of new features in MIXED, etc.), but this may get you started.

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

03-20-2011 02:23 PM

Thanks, LVM. Furtonately, I am working with a post-doc who has deeper understanding of the statistics, I am just doing the programming in SAS and she can help me interpret it all. But you're right, I should narrow this down: what is the syntax for a standard two-way repeated measures ANOVA given the vars named above?

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

Posted in reply to Bob291032

03-21-2011 08:36 AM

The article I mentioned gives all the coding for repeated measures using GLM or MIXED.

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

03-21-2011 10:54 AM

EDIT: Missed the PDF, though it was the SAS doc. I will review the PDF and post back.

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

Posted in reply to Bob291032

03-23-2011 12:04 AM

So I read the paper and was able to generate repeated measures anova using the following code:

title 'Treatment A v. Sham';

proc glm data=expdata;

class intervention;

model base T1 T2 T3 T4 = intervention / nouni;

repeated timepoint 5;

where intervention IN ( 0 1 );

run;

I'm still playing with this, but now I feel like I am in the movie*Inception*... We need to go deeper! Next thing is to get tukey post-hoc tests to see which timepoints are significant compared to baseline.

title 'Treatment A v. Sham';

proc glm data=expdata;

class intervention;

model base T1 T2 T3 T4 = intervention / nouni;

repeated timepoint 5;

where intervention IN ( 0 1 );

run;

I'm still playing with this, but now I feel like I am in the movie

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

Posted in reply to Bob291032

03-23-2011 10:08 AM

Hi Bob,

From your code I see you chose to do the multivariate analysis. I am not very familiar with proc glm usage for the repeated measurements analysis and was wondering how did you account for the fact that all treatments were tested on the same individual (individual is a blocking factor in your design). In proc mixed I would probably include random SubjectID; statement.

From your code I see you chose to do the multivariate analysis. I am not very familiar with proc glm usage for the repeated measurements analysis and was wondering how did you account for the fact that all treatments were tested on the same individual (individual is a blocking factor in your design). In proc mixed I would probably include random SubjectID; statement.

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

Posted in reply to statsplank

03-23-2011 01:22 PM

Hi statsplank,

Good question, can you demonstrate that with proc mixed code? One thing that concerned me with the proc glm was that the sphericity test was significant, indicating my data did not have type h variance-covariance matrix. Seeing how you would do this setup with proc mixed would be very helpful, thank you.

-B.

Good question, can you demonstrate that with proc mixed code? One thing that concerned me with the proc glm was that the sphericity test was significant, indicating my data did not have type h variance-covariance matrix. Seeing how you would do this setup with proc mixed would be very helpful, thank you.

-B.

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

Posted in reply to Bob291032

03-25-2011 03:41 PM

I've also tried with PROC MIXED. I had to restructure the data into a long form (each row represents one measurement of one experiment i.e.

subjectID | value | intervention | time

==========================

1 12 A Base

1 10 A T1

1 13 A T2

...

20 15 S T4

**proc mixed;**

class intervention time;

model value = time intervention time*intervention;

random int / subject = subjectID type=CS;

where ( intervention = 0 OR intervention = 1 );

run;

Does this properly take into consideration that the same subject is going through each intervention AND timepoint? i.e. is this an appropriate way to model the repeated-measures problem in the OP? Statsplank sounds like you think my previous proc GLM attempt was faulty.

subjectID | value | intervention | time

==========================

1 12 A Base

1 10 A T1

1 13 A T2

...

20 15 S T4

class intervention time;

model value = time intervention time*intervention;

random int / subject = subjectID type=CS;

where ( intervention = 0 OR intervention = 1 );

run;

Does this properly take into consideration that the same subject is going through each intervention AND timepoint? i.e. is this an appropriate way to model the repeated-measures problem in the OP? Statsplank sounds like you think my previous proc GLM attempt was faulty.

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

Posted in reply to Bob291032

03-28-2011 11:26 AM

Hi Bob,

Given the "long" data set with one record per outcome value, I would try to run the proc mixed as follows:

proc mixed;

class intervention time;

model value = time intervention time*intervention;

repeated time / subject=subjectID type=AR(1);

random int / subject=subjectID;

run;

I put type=AR(1) since you have sequential time points. You may want to specify different covariance structure.

Given the "long" data set with one record per outcome value, I would try to run the proc mixed as follows:

proc mixed;

class intervention time;

model value = time intervention time*intervention;

repeated time / subject=subjectID type=AR(1);

random int / subject=subjectID;

run;

I put type=AR(1) since you have sequential time points. You may want to specify different covariance structure.

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

Posted in reply to Bob291032

03-20-2011 10:53 PM

Hi Bob,

In your design, are Base, T1-T4 the same time points for treatments A, B, and Sham? Or the times are treatment specific (15 different time points):

Base_a

Base_b

Base_sham

T1_a

T1_b

T1_sham

T2_a

T2_b

T2_sham

... Message was edited by: statsplank

In your design, are Base, T1-T4 the same time points for treatments A, B, and Sham? Or the times are treatment specific (15 different time points):

Base_a

Base_b

Base_sham

T1_a

T1_b

T1_sham

T2_a

T2_b

T2_sham

... Message was edited by: statsplank

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

Posted in reply to statsplank

03-21-2011 02:11 AM

Hi statsplank,

Subjects were brought back three separate days, each day receiving a different treatment and having each day their measurements were taken at baseline, t1-t4. So I think the answer to your question is 'yes'. Every subject has five measures for treatment a on day 1, five for treatment b on day 2,and five on day3 for sham. Thank you for helping me!

-Bob

Subjects were brought back three separate days, each day receiving a different treatment and having each day their measurements were taken at baseline, t1-t4. So I think the answer to your question is 'yes'. Every subject has five measures for treatment a on day 1, five for treatment b on day 2,and five on day3 for sham. Thank you for helping me!

-Bob

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

Posted in reply to Bob291032

03-25-2011 04:27 PM

Also, I may be doing something wrong with the ANOVA - it says that the intervention is not significant but the timepoint is! I ran within-intervention paired t-tests comparing the measured value at any given timepoint v. baseline (i.e. what I would want a post-hoc test to do after anova) and I had the expected results: for each of my parameters, intervention A shows a significant change at each time point following baseline, intervention B and Sham do not (i.e. A has a significant effect). Obviously I can't just do 20+ paired t-tests without severe multiple testing type i errors but my point is that *all * parameters are significantly changed from baseline in the same direction for *all* time points for intervention A but not for sham or intervention B so a proper anova would have to show a significant treatment effect, yet I am not getting that. I am obviously doing something wrong with the repeated measures ANOVA.

I could really use some expertise on the syntax of a repeated measures ANOVA (each subject repeated for each time point for each intervention) given my problem description. Thanks!

I could really use some expertise on the syntax of a repeated measures ANOVA (each subject repeated for each time point for each intervention) given my problem description. Thanks!