Date: Fri, 19 Oct 2007 08:47:46 -0700
Reply-To: Robin High <robinh@UOREGON.EDU>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Robin High <robinh@UOREGON.EDU>
Subject: Re: help with an estimate statement in GENMOD
In-Reply-To: A<200710190041.l9IJ8lol000646@malibu.cc.uga.edu>
Content-Type: text/plain; charset="iso-8859-1"
Daniel,
The estimate statement does not compute an overall average in GENMOD with a time*stage term. The one you entered (below) does match the LSMEANS.
One alternative is to run the analysis with GLIMMIX (available from SAS as an add-on procedure) and enter the LSMEANS statement with at (time)=(2) or whatever number you want for time
PROC GLIMMIX DATA=one;
CLASS stage;
MODEL y = stage time stage*time ... / DIST=binomial LINK=logit ;
LSMEANS drug / AT (time)=(2);
RUN;
This should provide the standard error that seems to elude computation with GENMOD. The averaging process doesn't seem to work the same with covariates interacting with the classification factor as it does with classification variables alone.
And I would prefer to see an ESTIMATE statement with a divisor:
ESTIMATE 'average STAGE' int 3 STAGE 1 1 1 / DIVISOR=3;
Rather than the 0.333 entries.
And one final question, does the inclusion of time as an explanatory variable imply you should be doing a repeated measures with an ar(1) covariance structure? (For which GLIMMIX would likely be a good choice.)
Robin
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of DJR
Sent: Thursday, October 18, 2007 5:41 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: help with an estimate statement in GENMOD
From: Daniel Rizzolo [mailto:rizzolod@hotmail.com]
Sent: Thursday, October 18, 2007 3:58 PM
To: Robin High; sas-l@listserv.uga.edu
Subject: RE: help with an estimate statement in GENMOD
Robin,
Thanks for your reply to my posting. I have a few follow-up questions:
1) how can you calculate a standard error around the response value averaged
across the 3 stages when you do the calculation by hand?
2) if you can use the estimate statement to calculate adjusted estimates for
a 3-level categorical variable included in a model as a main effect by using
0.33 as the coefficient in the estimate statement, e.g.:
class STAGE;
model y= STAGE / dist=b link=logit;
estimate 'average STAGE' int 1 STAGE 0.33 0.33 0.33;/*this estimate should
be equivalent to an LSMEAN statement for STAGE*/
Could you not do the same for the interaction between the categorical
variable and a continuous variable, i.e:
to average the time*STAGE effect, multiply the value of time by the value
needed to average the STAGE effect (0.33 for a 3-level variable), e.g, for
time = 4, then to average the effect in an estimate statement insert the
value of 4*0.33 in the estimate statement?
I believe I have done this before for other data and checked the values from
the estimate statement against those calculated from the model's beta
coefficients and they agreed.
Thanks again for your input on this. Go Ducks?
DJR
> Subject: RE: help with an estimate statement in GENMOD
> Date: Thu, 18 Oct 2007 09:30:10 -0700
> From: robinh@uoregon.edu
> To: rizzolod@HOTMAIL.COM; SAS-L@LISTSERV.UGA.EDU
>
> DJR,
>
> When you enter a model statement in GENMOD like this:
>
> model Y = time time*time time*STAGE time*time*STAGE / dist=B link=logit LRCI;
>
> an Estimate statement needs to have the actual value of time "squared"
with a time*time term such as:
>
> ESTIMATE 'stage 1, time 2' int 1 time 2 time*time 4 time*stage 2 0 0
time*time*stage 4 0 0 ;
>
> ESTIMATE 'stage 2, time 2' int 1 time 2 time*time 4 time*stage 0 2 0
time*time*stage 0 4 0 ;
>
> ESTIMATE 'stage 3, time 2' int 1 time 2 time*time 4 time*stage 0 0 2
time*time*stage 0 0 4 ;
>
> If you save these values in a dataset and average them, it will give you
an average logit at time 2 across the three stages, which then you can
convert to the average predicted response at time=2 with
>
> prd_time_2 = exp(avg_logit)/ (1 + exp(avg_logit)) ;
>
> assuming you are modeling Prob(Y=1). You can check these individual
estimates match the xbeta term produced by the obstats option on the MODEL
statement, although if the file is big, be sure to look at it with ODS as
well, something like:
>
> ODS OUTPUT ESTIMATES=est OBSTATS=obst;
> ODS EXCLUDE estimates obstats;
>
> PROC GENMOD
> MODEL Y = ... / DIST=b link=logit lrci obstats;
> ESTIMATE ' ' ... ;
> Run;
>
> Proc print data=est; run;
> Proc print data=obst; where time=2; run;
>
> This approach is analogous to the LSMEANS statement from MIXED with a
continuous response, such as:
>
> LSMEANS stage / at (time)=(2);
>
> Which isn't available in GENMOD.
>
>
> Robin High
> University of Oregon
>
>
>
>
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of DJR
> Sent: Wednesday, October 17, 2007 11:00 AM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: help with an estimate statement in GENMOD
>
> Hello SAS-L subscribers:
>
> I am trying to output an estimate from a generalized linear model fit in SAS
> GENMOD. The model relates the binary response to a continuous variable
> (time, in minutes: 1,2,...,60) and a categorical variable with 3 levels
> (STAGE, listed in a class statement). The specific model of interest is:
>
> model Y = time time*time time*STAGE time*time*STAGE / dist=B link=logit LRCI;
>
> My goal is get an estimate of the response over a range of times with the
> STAGE effects averaged-out. I am using an estimate statement to attempt
> this. For example, at time=1, I have written the estimate statement as
follows:
>
> estimate ââ'¬Å"time=1ââ'¬ï¿½ intercept 1
> time 1
> time*time 1
> time*STAGE 0.33 0.33 0.33
> time*time*STAGE 0.33 0.33 0.33;
>
> for time=2:
>
> estimate ââ'¬Å"time=2ââ'¬ï¿½ intercept 1
> time 2
> time*time 4
> time*STAGE 0.66 0.66 0.66
> time*time*STAGE 1.33 1.33 1.33;
>
> and I repeat this across the range of times I am interested in. I get the
> estimates that I am after, except for the value of time=1, which gives ââ'¬Å"no
> est.ââ'¬ï¿½ I have used this code with similar data before. Because, the code
> works (or seems to work) for other values of time, I suspected it was a
> problem with the dataset, but I checked it and found no errors. Is this
> approach to averaging out the stage effect correct (i.e., the coefficient in
> the estimate statement being set to the value of time*time*0.333), and if
> so, what might the problem at the of value time=1 be?
> Thanks for the help.
> DJR