Date: Thu, 18 Sep 2008 15:27:05 -0500
Reply-To: Robin R High <rhigh@UNMC.EDU>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Robin R High <rhigh@UNMC.EDU>
Subject: Re: Contrast question-different number of degree
In-Reply-To: <402718.59537.qm@web32708.mail.mud.yahoo.com>
Content-Type: text/plain; charset="US-ASCII"
Jane,
It can be enlightening to also run this model with GLM since for a random
effects model it is basically equivalent to MIXED, and GLM prints the
expected mean squares of the contrasts:
proc glm data=one ;
class group subj hr;
model y=group subj(group) hr group*hr /ss3;
contrast "overall 1 VS 2" group 1 -1 / e=subj(group);
contrast "1 vs 2 by hours" group 1 -1 group*hr 1 0 0 0 -1 0 0 0,
group 1 -1 group*hr 0 1 0 0 0 -1 0 0,
group 1 -1 group*hr 0 0 1 0 0 0 -1 0,
group 1 -1 group*hr 0 0 0 1 0 0 0 -1 / e=subj(group);
test h=group e=subj(group);
random subj(group) ;
run; quit;
with expected mean squares:
Contrast Contrast Expected Mean Square
overall 1 VS 2 Var(Error) + 4 Var(subj(group)) +
Q(group,group*hr)
1 vs 2 by hours Var(Error) + Var(subj(group)) + Q(group,group*hr)
indicating both contrasts should be tested by the subj(group) random term
(as the contrast option allows you to specify) thus the need for 42
degrees of freedom;
In MIXED you can specify the actual number for the degrees of freedom as
an option on the CONTRAST statement:
proc mixed data=one;
class group subj hr;
model y=group hr group*hr /s;
contrast "overall 1 VS 2" group 1 -1 ;
contrast "1 vs 2 by hours" group 1 -1 group*hr 1 0 0 0 -1 0 0 0,
group 1 -1 group*hr 0 1 0 0 0 -1 0 0,
group 1 -1 group*hr 0 0 1 0 0 0 -1 0,
group 1 -1 group*hr 0 0 0 1 0 0 0 -1 / df=42;
*random group /subject=subj type=vc;
random subj(group) ;
run;
the df are now 42 for this test in both GLM and MIXED; however the
resulting Fvalue isn't quite the same, and I'm not aware how one can mimic
the e=subj(group) in this situation as with GLM.
[NOTE: I typically prefer the second RANDOM statement above, as the layout
of the first reminds me of random intercepts or coefficients model where a
numerical variable would usually be entered, plus it allows you to enter
method=type3 on the PROC statement (closer to GLM) which isn't allowed
otherwise.]
Robin High
UNMC
jn mao <jn_mao@yahoo.com>
09/18/2008 01:39 PM
Please respond to
jn_mao@yahoo.com
To
Robin R High <rhigh@UNMC.EDU>
cc
SAS-L@LISTSERV.UGA.EDU
Subject
Re: Contrast question-different number of degree
Thanks Robin,
Here is my mixed model code,
proc mixed ;
class group subj hr;
model y=group hr group*hr /s;
contrast "overall 1 VS 2" group 1 -1 ;
contrast "1 vs 2 by hours" group 1 -1 group*hr 1 0 0 0 -1 0 0 0,
group 1 -1 group*hr 0 1 0 0 0 -1 0 0,
group 1 -1 group*hr 0 0 1 0 0 0 -1 0,
group 1 -1 group*hr 0 0 0 1 0 0 0 -1;
random group /subject=subj type=vc;
run;
I wonder why my Den DF is 123, but 41, and my total subject is 44. Any
corrections on my code?
Jane
--- On Thu, 9/18/08, Robin R High <rhigh@UNMC.EDU> wrote:
From: Robin R High <rhigh@UNMC.EDU>
Subject: Re: Contrast question
To: SAS-L@LISTSERV.UGA.EDU
Date: Thursday, September 18, 2008, 12:40 PM
Jane,
It would help to see your code for the MIXED model and example of what
time represents. You can combine the four contrasts into one statement to
get the NumDF=4, but don't see why you particularly want the DenDF=41 when
an ANOVA table shows that degrees of freedom for the error term (with
complete data for all 44 subjects) for the group*hr effect is.
Source DF
group 1
subj(group) 42
hr 3
group*hr 3
hr*subj(group) 126 ***
PROC MIXED nobound;
CLASS group hr subj;
model y = group hr group*hr ;
contrast "1 vs 2" group 1 -1 group*hr 1 0 0 0 -1 0 0 0,
group 1 -1 group*hr 0 1 0 0 0 -1 0 0,
group 1 -1 group*hr 0 0 1 0 0 0 -1 0,
group 1 -1 group*hr 0 0 0 1 0 0 0 -1;
random subj(group);
run;
If necessary, you can change the degrees of freedom for the three fixed
effects with the ddf= option (rather than ddfm=contain is default for
random effects)
And depending on what time is, perhaps a REPEATED statement with ar(1) or
something that takes into account a time related correlation structure
would work better, that is, replace the RANDOM statement with:
REPEATED hr / subject=subj(group) type=AR(1) rcorr;
Robin High
UNMC
jn mao <jn_mao@YAHOO.COM>
Sent by: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
09/18/2008 11:42 AM
Please respond to
jn_mao@yahoo.com
To
SAS-L@LISTSERV.UGA.EDU
cc
Subject
Contrast question
Hello SAS-Ls,I'm trying to compare different of outcome1 between two
groups by each time pointusing mixed model and random method.I have 44
subjects in 2 groups and 4 time point meansurements per subject.My
contrast code is:contrast "overall group1 VS group2" group 1
-1;contrast
"1 vs 2 at 1st hour" group 1 -1 group*hr 1 0 0 0 -1 0 0 0;contrast
"1 vs 2
at 2nd hour" group 1 -1 group*hr 0 1 0 0 0 -1 0 0;contrast "1 vs 2 at
3rd
hour" group 1 -1 group*hr 0 0 1 0 0 0 -1 0;contrast "1 vs 2 at 4th
hour"
group 1 -1 group*hr 0 0 0 1 0 0 0 -1; However, this code gave the contrast
Num DF and Den DF based on total data (Num DF=1, Den DF=123)how could I
code to get NumDF=4, and Den DF=41, or the degree is based on total
subjects? Thanks much! Jane