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
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
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;
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
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.