Date: Thu, 1 Mar 2007 13:54:07 -0900
Reply-To: Daniel Rizzolo <rizzolod@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Daniel Rizzolo <rizzolod@HOTMAIL.COM>
Subject: Re: Help with ESTIMATE statement in GENMOD
In-Reply-To: <Pine.A41.4.02.10703011521160.68126-100000@unlunix.unl.edu>
Content-Type: text/plain; format=flowed
Robin,
Thank you, your reply is a huge help to me.
Take care,
DJR
>From: Robin High <robinh@unlserve.unl.edu>
>To: DJR <rizzolod@HOTMAIL.COM>
>CC: SAS-L@LISTSERV.UGA.EDU
>Subject: Re: Help with ESTIMATE statement in GENMOD
>Date: Thu, 1 Mar 2007 15:55:01 -0600 (CST)
>
>
>
> > I am fitting this model in PROC GENMOD:
> >
> > response = TYPE temp temp*temp TYPE*temp TYPE*temp*temp;
> >
> > In which TYPE is a 3 level categorical variable and temp is a continuous
> > variable.
> >
> > I’m trying to construct a macro that will estimate the response at
>values
> > of temp ranging from 1 to 25 while adjusting for the effect of type (I
> > want to plot 1 line of mean temp at temps 1 to 25 adjusted for the
>effect
> > of TYPE).
> >
> > I think I understand how to do this in a model without the quadratic
>trend
> > in temp and the interaction with TYPE, for example in the model:
> >
> > response = TYPE temp;
> >
> > I believe the code would look like this:
> >
> > %macro temp;
> > %do temp=1 %to 25;
> > proc genmod data=test;
> > class TYPE;
> > model response = TYPE temp / dist-b link=logit;
> > estimate '&temp adjusted for TYPE'
> > intercept 1
> > TYPE 0.33 0.33 0.33
> > temp &temp
> > ;
> > run;
> > %end;
> > %mend (temp);
> > %temp;
> >
> > What I do not understand is how to adjust for the TYPE*temp and
> > TYPE*temp*temp interactions. Is it possible to do this with the ESTIMATE
> > statement?
>
>* assuming they are necessary, you can do it
> very tediously, though it is possible to write a macro to do so;
>* you can also place them in an external file called estim.sas and at the
> usual location of the estimate statements, enter,
>
>%INCLUDE 'c:\sas\estim.sas';
>
>
>ods output estimate =est;
>ods exclude estimate;
>
>proc genmod data=test;
>CLASS TYPE;
>model response = TYPE temp temp*temp TYPE*temp TYPE*temp*temp
> / dist=binomial link=logit;
>
>estimate 'temp=1 at TYPE 1'
> intercept 1 TYPE 1 0 0 temp 1 temp*temp 1 TYPE*temp 1 0 0 TYPE*temp*temp
>1 0 0;
>estimate 'temp=1 at TYPE 2'
> intercept 1 TYPE 1 0 0 temp 1 temp*temp 1 TYPE*temp 0 1 0 TYPE*temp*temp
>0 1 0;
>estimate 'temp=1 at TYPE 3'
> intercept 1 TYPE 1 0 0 temp 1 temp*temp 1 TYPE*temp 0 0 1 TYPE*temp*temp
>0 0 1;
>
>estimate 'temp=2 at TYPE 1'
> intercept 1 TYPE 1 0 0 temp 2 temp*temp 4 TYPE*temp 2 0 0 TYPE*temp*temp
>4 0 0;
>estimate 'temp=2 at TYPE 2'
> intercept 1 TYPE 1 0 0 temp 2 temp*temp 4 TYPE*temp 0 2 0 TYPE*temp*temp
>0 4 0;
>estimate 'temp=2 at TYPE 3'
> intercept 1 TYPE 1 0 0 temp 2 temp*temp 4 TYPE*temp 0 0 2 TYPE*temp*temp
>0 0 4;
>
>* etc. .... ;
>
>run;
>
>
>* can extract info from output dataset;
>
>proc print data=est; run;
>
>The statements with the at option
>
> LSMEANS type / at (temp)=(1);
> LSMEANS type / at (temp)=(2);
> LSMEANS type / at (temp)=(3);
> etc...
>
>that would do this type of estimation in PROC MIXED aren't available in
>GENMOD, though I believe you can do it for binomial data with GLIMMIX.
>
>Also further note (and I'm not sure how this impacts what the previous
>commands do), that the LSMEANS in GENMOD computes estimates at the means
>of the covariate values in the dataset, which implies you need to compute
>the mean of both temp and temp_squared=temp*temp and enter those on the
>estimate statement to get the equivalent results for the LSMEANS:
>
>E.G if temp has an average in the dataset of 11.911 you need to compute a
>new variable that is temp^squared (it's average could be 162.2667) and
>enter that average on the ESTIMATE statement:
>
>estimate 'temp=11.911 at TYPE 1' intercept 1 TYPE 1 0 0 temp 11.9111
>temp*temp 162.2667;
>estimate 'temp=11.911 at TYPE 2' intercept 1 TYPE 0 1 0 temp 11.9111
>temp*temp 162.2667;
>estimate 'temp=11.911 at TYPE 3' intercept 1 TYPE 0 0 1 temp 11.9111
>temp*temp 162.2667;
>
>to get the results to match:
>
>LSMEANS type;
>
>Robin High
>
>
_________________________________________________________________
Mortgage rates as low as 4.625% - Refinance $150,000 loan for $579 a month.
Intro*Terms
https://www2.nextag.com/goto.jsp?product=100000035&url=%2fst.jsp&tm=y&search=mortgage_text_links_88_h27f6&disc=y&vers=743&s=4056&p=5117
|