BookmarkSubscribeRSS Feed
Bob291032
Calcite | Level 5
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
14 REPLIES 14
mfisher
Fluorite | Level 6
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
Bob291032
Calcite | Level 5
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
lvm
Rhodochrosite | Level 12 lvm
Rhodochrosite | Level 12
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.
Bob291032
Calcite | Level 5
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?
lvm
Rhodochrosite | Level 12 lvm
Rhodochrosite | Level 12
The article I mentioned gives all the coding for repeated measures using GLM or MIXED.
Bob291032
Calcite | Level 5
EDIT: Missed the PDF, though it was the SAS doc. I will review the PDF and post back.
Bob291032
Calcite | Level 5
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.
statsplank
Calcite | Level 5
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.
Bob291032
Calcite | Level 5
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.
Bob291032
Calcite | Level 5
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.
statsplank
Calcite | Level 5
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.
statsplank
Calcite | Level 5
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
Bob291032
Calcite | Level 5
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
Bob291032
Calcite | Level 5
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!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 14 replies
  • 4679 views
  • 0 likes
  • 4 in conversation