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

Hello,

Is there a way to specify which pairwise comparisons you want to look at, so that I can apply a Bonferroni adjustment using PROC GLM?

Example:

Factor A has 6 levels

Outcome variable is continuous

Thus we use an ANOVA model Y = mu + tau1 + tau2 + tau3 + tau4 + tau5 + tau6 + epsilon.

I am interested in whether there is a significant difference of mean in levels 1 and 2, levels 3 and 5, and level 1 and 6. Thus I am testing the null hypotheses mu1 = mu2, mu3 = mu5, and mu1 = mu6. Since this isn't all pairwise comparisons, I want to apply Bonferroni adjustment in place of Tukey adjustment. However, I don't want it to adjust for all comparisons since I don't care about that. Can SAS accommodate this? Or is splitting the alpha the way to go?

 

1 ACCEPTED SOLUTION

Accepted Solutions
jiltao
SAS Super FREQ

What you are asking for might not be done in PROC GLM --- In some other procedures that can also fit your ANOVA model, like PROC MIXED or PROC GENMOD, you might use the LSMESTIMATE statement with the ADJUST= option to get what you want; or use the ESTIMATE statement with the ADJUST=BON in procedures like PROC GLIMMIX or PROC GENMOD to get what you want. But PROC GLM does not have the LSMESTIMATE statement, and for the ESTIMATE statement in PROC GLM, ADJUST= option is not supported. Below is a sample syntax --

proc mixed data=yourdata;
class A;
model y=A;
lsmestimate A 'level 1 vs 2' 1 -1 0 0 0 0,
              'level 3 vs 5' 0 0 1 0 -1 0,        ,
              'level 1 vs 6' 1 0 0 0 0 -1/adjust=bon;     ,
run;

Another approach if you prefer fitting your model in PROC GLM, is to use the STORE statement in PROC GLM then use PROC PLM to do the multiple comparisons you want. For example,

proc glm data=yourdata;
class A;
model y=A;
store glmout;
run;

proc plm restore=glmout;
lsmestimate A 'level 1 vs 2' 1 -1 0 0 0 0,
              'level 3 vs 5' 0 0 1 0 -1 0,        ,
              'level 1 vs 6' 1 0 0 0 0 -1/adjust=bon;        ,
run;

 

View solution in original post

6 REPLIES 6
gcjfernandez
SAS Employee
You can use write specific contrasts for desired comparison and adjust the P-values based on Bonferroni method by considering the number of pairwise comparisons:
This online resource might be useful:
https://people.stat.sc.edu/habing/courses/516cmsup3.pdf
jiltao
SAS Super FREQ

What you are asking for might not be done in PROC GLM --- In some other procedures that can also fit your ANOVA model, like PROC MIXED or PROC GENMOD, you might use the LSMESTIMATE statement with the ADJUST= option to get what you want; or use the ESTIMATE statement with the ADJUST=BON in procedures like PROC GLIMMIX or PROC GENMOD to get what you want. But PROC GLM does not have the LSMESTIMATE statement, and for the ESTIMATE statement in PROC GLM, ADJUST= option is not supported. Below is a sample syntax --

proc mixed data=yourdata;
class A;
model y=A;
lsmestimate A 'level 1 vs 2' 1 -1 0 0 0 0,
              'level 3 vs 5' 0 0 1 0 -1 0,        ,
              'level 1 vs 6' 1 0 0 0 0 -1/adjust=bon;     ,
run;

Another approach if you prefer fitting your model in PROC GLM, is to use the STORE statement in PROC GLM then use PROC PLM to do the multiple comparisons you want. For example,

proc glm data=yourdata;
class A;
model y=A;
store glmout;
run;

proc plm restore=glmout;
lsmestimate A 'level 1 vs 2' 1 -1 0 0 0 0,
              'level 3 vs 5' 0 0 1 0 -1 0,        ,
              'level 1 vs 6' 1 0 0 0 0 -1/adjust=bon;        ,
run;

 

SteveDenham
Jade | Level 19

Thanks @jiltao for pointing out the error with my code, and even better, posting a solution that did use PROC GLM.  I wish I could mark your reply as correct.

 

SteveDenham

SteveDenham
Jade | Level 19

You should look into using the LSMESTIMATE statement.  You can do multiple comparisons and apply a Bonferroni correction (amongst many correction types).  Something like this may be what you are looking for:

(But keep in mind that PROC GLM does not support the LSMESTIMATE statement.  For a better set of code, see the response by @jiltao in this thread.)

proc glm data=yourdata;
class factor_A;
model y=factor_A;
lsmeans factor_A;
lsmestimate factor_A 'One vs two'   1 -1 0 0 0 0,
              'Three vs five' 0 0 1 0 -1 0,        ,
              'One vs six' 1 0 0 0 0 -1/adjust=bon;     ,
run;

Hope this helps.

 

SteveDenham

 

jiltao
SAS Super FREQ

Just wanted to point out that the LSMESTIMATE statement is not available in PROC GLM. Please refer to my previous post for alternative approaches.

amarikow57
Obsidian | Level 7

Yes. Thank you! I'm not sure how to change accepted solution, though. 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 6 replies
  • 2277 views
  • 7 likes
  • 4 in conversation