How to set up contrast statement for subgroup comparison in SAS glm

791 views
Skip to first unread message

Fred

unread,
Mar 23, 2010, 11:45:17 PM3/23/10
to MedStats
Hi Everyone,

I am running an unbalanced two-way analysis of variance using "proc
glm"
Both two factors contain 2 levels. say A, B and 1, 2.

I wanna do a subgroup comparison, say. whether change between 1 and 2
in A is different from change between 1 and 2 in B.

I think "contrast" statement in "proc glm" can do this, cannot it?

And is there anyone can tell me how to set up the contrast for this
comparison?

Thanks

Fred

unread,
Mar 24, 2010, 5:20:14 AM3/24/10
to MedStats
More explicitly ,

The outcome variable is the vitamin D level, and two factors are
season(winter or summer) and supplement(yes or no)

the unbalanced two-way analysis of variance I used in SAS glm is

proc glm;
class season supplement;
model level = season supplement season*supplement;
lsmeans season*supplement/pdiff=all adjust=tukey;
contrast "a vs b" season*supplement 1 -1 -1 1;
run;
quit;

I set the contrast as we wanna compare (mu(yes winter)-mu(yes-summer)
- (mu(no winter)-mu(no summer));
ie. whether difference between winter and summer in supplement is
different from difference between winter and summer in supplement no
group.

So the contrast i use is the coefficient before the equation above.

This is just my personal thoughts. Please let me know whether it is
correct.

Thanks so much.

Fred

Bruce Weaver

unread,
Mar 24, 2010, 8:36:00 AM3/24/10
to MedStats


Why do you need anything beyond the F-test on the interaction between
the two variables? It tests the null hypothesis that the effect of
one variable is the same across all levels of the other variable.

--
Bruce Weaver
bwe...@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/Home
"When all else fails, RTFM."

Lachenbruch, Peter

unread,
Mar 24, 2010, 12:09:05 PM3/24/10
to meds...@googlegroups.com
A couple of things:
1. "wanna" should be "want to"
2. Why do you need contrasts? Isn't the main effect of A what you want? Or do you want to compare the main effect of A with that of B, and that would be the interaction of A and B. the unbalanced nature may mean you need to look at specific contrasts but that is spelled out in basic ANOVA texts.

Tony

Peter A. Lachenbruch
Department of Public Health
Oregon State University
Corvallis, OR 97330
Phone: 541-737-3832
FAX: 541-737-4001

Hi Everyone,

Thanks

--
To post a new thread to MedStats, send email to MedS...@googlegroups.com .
MedStats' home page is http://groups.google.com/group/MedStats .
Rules: http://groups.google.com/group/MedStats/web/medstats-rules

To unsubscribe from this group, send email to medstats+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.

Fred

unread,
Mar 24, 2010, 12:24:39 PM3/24/10
to MedStats
The interaction effect does not provide the subgroup comparison. Even
the turkey adjustment in SAS, it only provides the pair wise
comparison between the interaction effect.


What i want to test is the null hypothesis of equal "treatment effect"
in the two subgroups.
In my example, whether treatment effect between summer and winter with
supplement is different from treatment effect between summer and
winter without supplements. ie. whether MU(supp yes summer) - MU(supp
yes winter) differs MU(supp NO summer)-MU(supp No winter)

On Mar 25, 3:09 am, "Lachenbruch, Peter"

John Sorkin

unread,
Mar 24, 2010, 12:39:17 PM3/24/10
to jianyun...@gmail.com, meds...@googlegroups.com
In brief you need to set up a contrast giving the affect of level 1 for factor A, and second giving the affect of level 2 for factor A. Compute the difference of the two contrasts. Follow the same the same strategy for factor B. The difference of the two differences will give you your desired result.
John
John Sorkin
Chief Biostatistics and Informatics
Univ. of Maryland School of Medicine
Division of Gerontology and Geriatric Medicine
JSo...@grecc.umaryland.edu
-----Original Message-----
From: Fred <jianyun...@gmail.com>
To: MedStats <meds...@googlegroups.com>

Sent: 3/24/2010 12:24:39 PM
Subject: Re: {MEDSTATS} How to set up contrast statement for subgroup comparison in SAS glm

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.

Bruce Weaver

unread,
Mar 24, 2010, 12:41:35 PM3/24/10
to MedStats
Fred, what is the null hypothesis for the interaction term in a 2x2
ANOVA?

Fred

unread,
Mar 24, 2010, 1:19:44 PM3/24/10
to MedStats
OH.. I am so sorry. I was confused when I studied subgroup comparison
alone and interaction effect in ANOVA.

I think it is clear now.

Thanks

Reply all
Reply to author
Forward
0 new messages