BookmarkSubscribeRSS Feed
mona4u
Lapis Lazuli | Level 10

/*I'm creating this model and I have a question about the random statemnt if I'm comparing left eye to rigt ey is this random statement should be
good or should I create differnt random statemnt in differnt model to serve that porpuse */
*ex: random visit/ residual subject=usubjid type=cs;

proc glimmix data=analysisplots=studentpanel;
class sex usubjid eye visit ;
model aval= visit|eye age sex / ddfm=kr s;
random intercept / subject=usubjid ;
random eye/ residual subject=usubjid (visit ) type=cs;
lsmeans eye*visit / alpha=0.05 cl ;
/*comapre visit to their baseline */
LSMeans eye*visit/ slicediff=eye slicedifftype=control( 'Left' 'Baseline') alpha=0.05 cl ;
/*compare right eye and left eye at diffrent visits */
LSMeans eye*visit/ slicediff=visit slicedifftype=control( 'Left' 'Baseline') alpha=0.05 cl ;
run;

4 REPLIES 4
Rick_SAS
SAS Super FREQ

I don't think most people would classify Eye=('Left' 'Right') as a random effect. It seems like a fixed effect because there are only two possibilities and we want to make predictions and comparisons between these levels.

 

A random effect would be something like a hospital or a doctor. A random effect indicates that there are many possible levels that are not present in the sample. We try to make inferences based on the levels that we have observed.

 

If you think that Eye should be a random effect, please describe the experiment that produced the data.

StatsMan
SAS Super FREQ

Your RANDOM statements in your GLIMMIX code make your subject variable a random effect. That is probably what you want. @Rick_SAS is correct - eye would not usually be a random effect since it has 2 levels of interest and you have not taken a random sample of levels of eye. You supposedly have a random sample of subjects, though. 

 

Your first RANDOM statement:

random intercept / subject=usubjid;

correlates all the measurements taken from the same level of USUBJID. 

 

The second RANDOM statement might need some tweaking. Are you attempting to further correlate the observations from each eye within a subject over time? If so, try:

random visit / residual subject=eye(usubjid) type=ar(1);

That RANDOM statement will correlate the observations from the same eye within a subject using an AR(1) structure. You can try TYPE=CS, but you may have trouble fitting that compound symmetry structure on top of the CS structure you have implied with the first RANDOM statement (the default G-side structure gives you a common correlation among the observations from the same subject). 

SteveDenham
Jade | Level 19

Given all that has been presented by @StatsMan and @Rick_SAS, I believe that you can model Left Eye and Right Eye as repeated measures on the individual. In this case 'eye' is a fixed effect just as 'visit' is, but you have a chance to capture within subject variation for both of these. Here is the code you propose:

 

proc glimmix data=analysis plots=studentpanel;
class sex usubjid eye visit ;
model aval= visit|eye age sex / ddfm=kr s;
random intercept / subject=usubjid ;
random eye/ residual subject=usubjid (visit ) type=cs;
lsmeans eye*visit / alpha=0.05 cl ;
/*comapre visit to their baseline */
LSMeans eye*visit/ slicediff=eye slicedifftype=control( 'Left' 'Baseline') alpha=0.05 cl ;
/*compare right eye and left eye at diffrent visits */
LSMeans eye*visit/ slicediff=visit slicedifftype=control( 'Left' 'Baseline') alpha=0.05 cl ;
run;

Adding one more RANDOM residual statement would accomplish what I think you want:

 

proc glimmix data=analysisplots=studentpanel;
class sex usubjid eye visit ;
model aval= visit|eye age sex / ddfm=kr s;
random intercept / subject=usubjid ;
RANDOM VISIT/RESIDUAL SUBJECT=USUBJID TYPE=AR(1);
random eye/ residual subject=usubjid (visit ) type=cs;
lsmeans eye*visit / alpha=0.05 cl ;
/*comapre visit to their baseline */
LSMeans eye*visit/ slicediff=eye slicedifftype=control( 'Left' 'Baseline') alpha=0.05 cl ;
/*compare right eye and left eye at diffrent visits */
LSMeans eye*visit/ slicediff=visit slicedifftype=control( 'Left' 'Baseline') alpha=0.05 cl ;
run;

I will say this though. We have had more success treating eye as a fixed effect (as pointed out by @StatsMan and @Rick_SAS ), which avoids a LOT of failure to converge and G matrix non-positive definite issues. Something like this:

 

proc glimmix data=ansdata_&n.  ;     
            nloptions  maxiter = 5000 ;
            class &grp_no. &time. &animal. eyen;
            model &value. = &grp_no.|&time.|eyen / ddfm=BW;
            random &time. / type = &cov. subject=eyen(&animal.);
            %if "&cov." = "SP(POW)(T)" %then %do;
                random intercept / subject=eyen(&animal.);
            %end;   

Note that the macro variable &grp_no. may include sex as in your code, but that there is an opportunity to include interactions that may not be apparent in your model.

 

SteveDenham

 

 

 

Ksharp
Super User
Kudos!
Thumbs Up!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 500 views
  • 6 likes
  • 5 in conversation