Wednesday, August 25, 2010

main effect of a continous variable

In both proc mixed and glimmix (see the code example below), the "Solution for Fixed Effects" generated by option /SOLUTION for the continous variable 'binary' does not estimate the main/marginal effect when the value of binary changes from 0 to 1. It is because of the interaction term between binary and visit. To find the main/marginal effect, we can code the variable 'binary' as a class/categorical variable and find this LSMEANS.

The parameter estimates of  'binary', in both cases, actually equal to estimate of 'effect of one additional genotype at week 12' respectively. This is because SAS use the last level as the reference to code dummy variables. We can also confirm that when we set the variable 'binary' as a class variable and request LSMEANS binary*visit /diff slice=visit.


Five post-base visits and the variable binary equals to 0 or 1.

title "continous genotype";
proc mixed data=dsin;
class subject visit;
MODEL y_continuous = baseline binary visit binary*visit /DDFM = KR S;
REPEATED visit /SUBJECT = subject TYPE = UN;
estimate 'effect of one additional genotype at week 12' binary 1 binary*visit 0 0 0 0 1;
run;

title "continous binary";

Proc glimmix data= dsin IC=Q;
NLoptions maxiter=200 tech=nrridg;
Class subject visit;
model y_categorical = baseline binary visit binary*visit / dist=bin link=logit ddfm=kenwardroger s;
random visit/subject=subject type=un residual;
estimate 'effect of one additional genotype at week 12' binary 1 binary*visit 0 0 0 0 1;
run;


title "categorical genotype";
proc mixed data=hamd3;
class subject visit binary;
MODEL y = baseline binary visit binary*visit /DDFM = KR S;
REPEATED visit /SUBJECT = subject TYPE = UN;
lsmeans binary binary*visit/diff slice=visit;
run;

title "categorical binary";
Proc glimmix data= hamd3 IC=Q;
NLoptions maxiter=200 tech=nrridg;
Class subject binary visit;
model y_categorical= baseline binary visit binary*visit / dist=bin link=logit ddfm=kenwardroger s;
random visit/subject=subject type=un residual;
lsmeans binary binary*visit / ilink cl diff slice=visit;
run;

No comments: