Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Analytics
- /
- Stat Procs
- /
- Specify Pairwise Comparisons Using PROC GLM

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

🔒 This topic is **solved** and **locked**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 04-14-2021 04:43 PM
(2291 views)

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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;
```

6 REPLIES 6

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

This online resource might be useful:

https://people.stat.sc.edu/habing/courses/516cmsup3.pdf

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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;
```

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

**Available on demand!**

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

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.