BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
hanson4022
Calcite | Level 5

I have data that is normally distributed, but has unequal variance. A Welch test shows significant differences between at least one of the treatment groups. However, at this point I haven't been able to find if it's possible to do contrast statements as you would for an equivalent ANOVA with equal variance (code below).

proc glm data =treatmentdata;

class trt ;

model response=trt ;

means  trt /  hovtest=levene welch ;

contrast'1 vs 2' trt -1 1 0 0 0 0  ;

contrast'3 vs 4' trt 0 0 -1 1 0 0  ;

contrast'5 vs 6' trt 0 0 0 0 -1 1  ;

run;

quit;

I have found post hoc tests such as Games-Howell or Tamhane's T2 under the LSmeans statement: SAS/STAT(R) 9.2 User's Guide, Second Edition

However, these are testing all possible treatment combinations, which I don't intend to do. Is this a situation I would just have to resort to multiple Welch t-tests with a corrected alpha, or is there a better way to handle this within the ANOVA framework in SAS that I haven't found ye

1 ACCEPTED SOLUTION

Accepted Solutions
SteveDenham
Jade | Level 19

This is one of the great advantages to PROC GLIMMIX over GLM.

To get heterogeneous variance estimates, use the random statement included below.

proc glimmix data =treatmentdata;

class trt ;

model response=trt ;

random _residual_/group=trt; /* This gives the treatments separate variance estimates  */

covtest 'common variance' homogeneity;  /* This does a likelihood ratio test for homogeneity */

lsmeans trt;

contrast '1 vs 2' trt -1 1 0 0 0 0  ,

             '3 vs 4' trt 0 0 -1 1 0 0  ,

             '5 vs 6' trt 0 0 0 0 -1 1 / adjust=simulate(nsamp=50000 seed=7654321 report); /* Borrowing from 1zmm's code for control of multiple comparisons */

run;

Good luck with these approaches.

Steve Denham

View solution in original post

2 REPLIES 2
1zmm
Quartz | Level 8

I don't know whether the following would work, but you might consider it.

In a DATA step before the PROC GLM paragraph, you might construct three new variables from the TRT that contain the three treatment contrasts of interest to you.  Then, use those three new variables instead of TRT in PROC GLM using the LSMEANS statement with these three new variables and the SIMULATE option to calculate significance probabilities that account for unequal variances among the different treatment groups (recommended by Westfall PH, Tobias RD, Wolfinger RD.  Multiple comparisons and multiple tests using SAS.  Cary, NC:  SAS Institute, Inc., 2011, Chapter 5.2):

    data new_treatmentdata;

        set treatmentdata;

        * Create new variables for the treatment contrasts of interest;

        trt12=0;

        trt34=0;

        trt56=0;

        select;

             when (trt eq 1) trt12=-1;

             when (trt eq 2) trt12=1;

             when (trt eq 3) trt34=-1;

             when (trt eq 4) trt34=1;

             when (trt eq 5) trt56=-1;

             when (trt eq 6) trt56=1;

             otherwise do;

                  trt12=.;  trt34=.;  trt56=.;

             end;

       end;

       output new_treatmentdata;

       label trt12="Contrast treatments 1 and 2";

       label trt34="Contrast treatments 3 and 4";

       label trt56="Contrast treatments 5 and 6";

    run;

    proc glm data=new_treatmentdata;

         class trt12 trt34 trt56;

         model response=trt12 trt34 trt56 / solution;

         means trt12 trt34 trt56 / hovtest=levene welch;

         lsmeans trt12 trt34 trt56 / adjust=simulate(nsamp=50000 seed=7654321 report);

    run;

    quit;

SteveDenham
Jade | Level 19

This is one of the great advantages to PROC GLIMMIX over GLM.

To get heterogeneous variance estimates, use the random statement included below.

proc glimmix data =treatmentdata;

class trt ;

model response=trt ;

random _residual_/group=trt; /* This gives the treatments separate variance estimates  */

covtest 'common variance' homogeneity;  /* This does a likelihood ratio test for homogeneity */

lsmeans trt;

contrast '1 vs 2' trt -1 1 0 0 0 0  ,

             '3 vs 4' trt 0 0 -1 1 0 0  ,

             '5 vs 6' trt 0 0 0 0 -1 1 / adjust=simulate(nsamp=50000 seed=7654321 report); /* Borrowing from 1zmm's code for control of multiple comparisons */

run;

Good luck with these approaches.

Steve Denham

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 2 replies
  • 5355 views
  • 4 likes
  • 3 in conversation