Programming the statistical procedures from SAS

ANOVA: Performing contrasts when you have unequal variance?

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 13
Accepted Solution

ANOVA: Performing contrasts when you have unequal variance?

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


Accepted Solutions
Solution
‎02-04-2013 09:09 AM
Respected Advisor
Posts: 2,655

Re: ANOVA: Performing contrasts when you have unequal variance?

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


All Replies
Regular Contributor
Posts: 152

Re: ANOVA: Performing contrasts when you have unequal variance?

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;

Solution
‎02-04-2013 09:09 AM
Respected Advisor
Posts: 2,655

Re: ANOVA: Performing contrasts when you have unequal variance?

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

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 1598 views
  • 4 likes
  • 3 in conversation