LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (April 2011, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 28 Apr 2011 08:38:54 -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: Difference in parameter estimation LSMEANS and ESTIMATE
              statement with covariate adjustments
Comments: To: Ray Harvey <Rharvey3015@GMAIL.COM>
In-Reply-To:  <201104280257.p3RK2plG026516@waikiki.cc.uga.edu>
Content-Type: text/plain; charset="US-ASCII"

Ray,

The difference is ESTIMATE statements without the covariate included evaluate the estimates at the covariate = 0; LSMEANS evaluate the "estimates" at the mean of the covariate by default. Unfortunately, GENMOD LSMEANS doesn't have the at= option, but if you run the analogous GLIMMIX code, you'll see the LSMEANS and ESTIMATES match:

ods select estimates lsmeans;

proc glimmix data=sample; class grp study_yr ID; model admits= grp study_yr grp*study_yr randnum / link=log d=p; RANDOM study_yr / subject=id type=cs residual; lsmeans grp*study_yr / at randnum=0;

Estimate 'Control Stdy Yr1' intercept 1 grp 1 0 study_yr 1 0 0 grp*study_yr 1 0 0 0 0 0; Estimate 'Control Stdy Yr2' intercept 1 grp 1 0 study_yr 0 1 0 grp*study_yr 0 1 0 0 0 0; Estimate 'Control Stdy Yr3' intercept 1 grp 1 0 study_yr 0 0 1 grp*study_yr 0 0 1 0 0 0;

Estimate 'Intervention Stdy Yr1' intercept 1 grp 0 1 study_yr 1 0 0 grp*study_yr 0 0 0 1 0 0; Estimate 'Intervention Stdy Yr2' intercept 1 grp 0 1 study_yr 0 1 0 grp*study_yr 0 0 0 0 1 0; Estimate 'Intervention Stdy Yr3' intercept 1 grp 0 1 study_yr 0 0 1 grp*study_yr 0 0 0 0 0 1; run;

Robin High UNMC

From: Ray Harvey <Rharvey3015@GMAIL.COM> To: SAS-L@LISTSERV.UGA.EDU Date: 04/27/2011 10:00 PM Subject: Difference in parameter estimation LSMEANS and ESTIMATE statement with covariate adjustments Sent by: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>

Hi Ryan, I found the issue. I had a covariate in my original code. Parameter estimation is different when using ESTIMATE and LSMEANS. I do recall this and will need to return to the documentation. Below is sample code that will generate the issue. If you remove the covariate (randnum) the parameter estimates using LSMEANS and ESTIMATE statements will agree. However, if we adjust the model they no longer provide similiar parameter estimates.

DATA ONE; DO i = 1 to 2000; /* Step through the loop 800 times */ ID = int((RANUNI(153795) *1000)); x=ceil(ranuni(0)*10); y=ceil(ranuni(0)*100); randnum=ranuni(333573); drop i;/* Generate a random number between 1 and 10 */ OUTPUT; /* Add the number to the data set */ END; RUN; proc sort data=one; by randnum; run; proc plan seed=392083397; factors k=250 ordered condition=3 i=1 of 1 / noprint; treatments merge=3 of 2000 perm; output out=plan(rename=condition=study_yr) merge nvals=(1 to 2000) random; run;

data sample; merge one plan; grp=mod(y,2)=0; /*Remainder when x is divided by d; MOD(10,3) = 1.*/ admits=ceil(randnum*12); keep id admits randnum study_yr grp; run;

ods output estimates = est;

proc genmod data=sample; class grp study_yr ID; model admits= grp study_yr randnum grp*study_yr/ link=log type3 d=p; repeated sub=id / type=exch;

lsmeans grp*study_yr;

Estimate 'Control Stdy Yr1' intercept 1 grp 1 0 study_yr 1 0 0 grp*study_yr 1 0 0 0 0 0; Estimate 'Control Stdy Yr2' intercept 1 grp 1 0 study_yr 0 1 0 grp*study_yr 0 1 0 0 0 0; Estimate 'Control Stdy Yr3' intercept 1 grp 1 0 study_yr 0 0 1 grp*study_yr 0 0 1 0 0 0;

Estimate 'Intervention Stdy Yr1' intercept 1 grp 0 1 study_yr 1 0 0 grp*study_yr 0 0 0 1 0 0; Estimate 'Intervention Stdy Yr2' intercept 1 grp 0 1 study_yr 0 1 0 grp*study_yr 0 0 0 0 1 0; Estimate 'Intervention Stdy Yr3' intercept 1 grp 0 1 study_yr 0 0 1 grp*study_yr 0 0 0 0 0 1;

run;


Back to: Top of message | Previous page | Main SAS-L page