Statistical Procedures

Programming the statistical procedures from SAS
BookmarkSubscribeRSS Feed
BeeL
Calcite | Level 5

Hi everyone,

I need some help with analyzing data from a study that examines dependent variables at two different time points across four treatment groups.

 

My dataset is in long format, and looks like this:

SubjectID Group Time Dependent_variable

1 2 Baseline 60
1 2 Post_Intervention 20
2 2 Baseline 23
2 2 Post_Intervention 14
3 3 Baseline 12
3 3 Post_Intervention 10
4 1 Baseline 20
4 1 Post_Intervention 22

I am planning to run a two-factor repeated measures ANOVA and tried the following code. Is this the correct approach? 

 

PROC GLM DATA = dataset;

CLASS group time;

MODEL dependent_variable = group time group*time;

REPEATED time 2;

LSMEANS group*time / PDIFF ADJUST=tukey;

RUN;


Thanks so much!

5 REPLIES 5
Ksharp
Super User
Nope. Since your data is longitidu(repeated measure) data, you should use MIXED model ,not old/obsolete GLM model.

PROC MIXED DATA=dataset;
CLASS SubjectID group time;
MODEL dependent_variable = group time group*time;
REPEATED time /subject=SubjectID ;
LSMEANS group*time / PDIFF ADJUST=tukey;
RUN;
BeeL
Calcite | Level 5

Thanks a lot! 

 

Is there an option to incorporate both normality of residuals and homogeneity of variance tests within the same procedure? I found a suggestion for testing normality of residuals (using QQ plots), but I haven't come across an option for testing homogeneity of variance. 

 

PROC MIXED DATA=dataset;
CLASS SubjectID group time;
MODEL dependent_variable = group time group*time /residual;
REPEATED time /subject=SubjectID ;
LSMEANS group*time / PDIFF ADJUST=tukey;
RUN;

Ksharp
Super User
One of assumption/hypothesis of Mixed Model is normality of residuals/response variable. If this hypothesis was violated,you should use PROC GLIMMIX.

Related to "homogeneity of variance" ,I think Mixed Model essentially take care of it,
Think about it ,why you have to use PROC MIXED ? it is just because one of hypothesis of GLM is "homogeneity of variance". Mixed Model would take into count of the correlation between clusters which is caused by heteroscedasticity(non-homogeneity of variance).

If you want check the RANDOM effect is significant or not, try COVTEST option:
PROC MIXED DATA=dataset COVTEST;
CLASS SubjectID group time;
MODEL dependent_variable = group time group*time /residual;
REPEATED time /subject=SubjectID type=un ;
LSMEANS group*time / PDIFF ADJUST=tukey;
RUN;
BeeL
Calcite | Level 5

Thank you so much! Your input helped me a lot.

SteveDenham
Jade | Level 19

I realize this is late, but this is one situation where some of the options in GLIMMIX come in handy (see the GLIMMIX documentation). You can test for homogeneity of variance using the COVTEST statement in conjunction with using the Group= option in the RANDOM statement. My advice would be to fit the heterogeneous model no matter the result of the test, AS LONG AS you have sufficient data to fit the  number of parameters needed for the covariance structures under consideration and the model converges without messages or errors.

 

SteveDenham

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 1049 views
  • 1 like
  • 3 in conversation