BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
SeanLinSAS
Calcite | Level 5

I have a data in structure like below, with subjects (subjid prefixed with clinic id) from different clinics, the subjid is unique across clinics and they are randomly assigned treatment or placebo (fixed effect). There are multiple visits for each subject. 

SUBJIDTRTSTRATACLINICVISITOUTCOME
01-01TS1011

8.9

01-01TS101210.2
01-01TS101314.1
02-03CS20215.4
02-03CS20225.9
02-03CS20238.7
02-04CS10212.3
02-04CS1022.
02-04CS1023

4.5

02-06TS2021

5.8

02-06TS2022

7.9

02-06TS2023

.

 

The goal is to analyze treatment effect on the outcome at each visit given strata as covariates. So a repeated measure is used here: 

PROC MIXED data=data;
    CLASS subjid trt strata visit;
    MODEL outcome = trt strata visit*trt/ DDFM=kr;
    REPEATED visit/ SUBJECT=subjid TYPE=un;
    LSMEANS trt trt*visit/ CL;
RUN;

Now, considering the enrollment is quite unbalanced among clinics, I'd like to take clinic into consideration as well, where the clinic should serve as a random effect since they are just randomly picked. Will it work by simply appending a RANDOM statement on clinic like below?

PROC MIXED data=data;
    CLASS subjid trt strata visit;
    MODEL outcome = trt strata visit*trt/ DDFM=kr;
    REPEATED visit/ SUBJECT=subjid TYPE=un;
    RANDOM clinic;
    LSMEANS trt trt*visit/ CL;
RUN;

 Or does it make sense to put subjid nested within clinic or trt?

PROC MIXED data=data;
    CLASS subjid trt strata visit;
    MODEL outcome = trt strata visit*trt/ DDFM=kr;
    REPEATED visit/ SUBJECT=subjid TYPE=un;
    RANDOM clinic subjid(clinic); /* or RANDOM clinic subjid(trt) */
    LSMEANS trt trt*visit/ CL;
RUN;

By the way, in my real data, where I have 40 clinics with 160 subjects. If both clinic and subjid(clinic) are used in RANDOM statement, SAS will report an error saying run out of memory. Is it due to too many clinics relative to sample size or it just shall not work with both subject and clinic in RANDOM statement?

 

What exactly is the way to take clinic (random effect) into consideration? Please help!

1 ACCEPTED SOLUTION

Accepted Solutions
jiltao
SAS Super FREQ

I would probably make a slight change to your model to make it more numerically efficient:

PROC MIXED data=data;
    CLASS subjid trt strata visit clinic;
    MODEL outcome = trt strata visit*trt/ DDFM=kr;
	RANDOM int / subject=clinic;
    REPEATED visit/ SUBJECT=subjid(clinic) TYPE=un;
    LSMEANS trt trt*visit/ CL;
RUN;

I added CLINIC to the CLASS statement, and used the SUBJECT= option in the RANDOM statement so the model can be processed by subjects, which is more numerically efficient.

When you use the following statement --

RANDOM clinic subjid(clinic); 

the subjid(clinic) random effect is "redundant" to your REPEATED statement in terms of the correlations the two try to model, and therefore is not appropriate.

Hope this helps,

Jill

View solution in original post

5 REPLIES 5
StatsMan
SAS Super FREQ

I'm in favor of your second model, with random clinic effect and repeated measures on the subjects. We see that model quite a lot in interactions with other SAS users. 

Your coding of the subject effect is giving MIXED fits with memory when you include SUBJID(CLINIC) as a random effect. That is trying to fit a 160x40 level interaction. But that is not what you have. Recoding the subject effect so that you have subjects 1,2,3 in clinic A and subjects 1,2,3,4 in clinic B will save you a lot of memory ... and fit the model correctly. By nesting subject within clinic, MIXED will know that subject 2 in clinic A is different from subject 2 in clinic B. Now, in that second model you can use SUBJ(CLINIC) as the SUBJECT= effect on the REPEATED statement and possibly get better behavior out of your DF calculations. 

SeanLinSAS
Calcite | Level 5

By the second model as your favor, I suppose you're talking about the one in the middle but not the last one, right? I try to recode subjid and put it nested within clinic in REPEATED statement, it gives the same result. So SUBJECT=subjid before recoding is the same to SUBJECT = subjid(clinic) after recoding. 

Can I just say that, if subject is uniquely coded across treatment group and clinic, then subjid is not nested within either treatment group or clinic in trial design perspective, and generally we only use nested structure in the setting you described (subjid starts from 1 in each clinic)?

jiltao
SAS Super FREQ

I would probably make a slight change to your model to make it more numerically efficient:

PROC MIXED data=data;
    CLASS subjid trt strata visit clinic;
    MODEL outcome = trt strata visit*trt/ DDFM=kr;
	RANDOM int / subject=clinic;
    REPEATED visit/ SUBJECT=subjid(clinic) TYPE=un;
    LSMEANS trt trt*visit/ CL;
RUN;

I added CLINIC to the CLASS statement, and used the SUBJECT= option in the RANDOM statement so the model can be processed by subjects, which is more numerically efficient.

When you use the following statement --

RANDOM clinic subjid(clinic); 

the subjid(clinic) random effect is "redundant" to your REPEATED statement in terms of the correlations the two try to model, and therefore is not appropriate.

Hope this helps,

Jill

SeanLinSAS
Calcite | Level 5
You're right, I forgot to put clinic in CLASS statement in this post, but I did in my own program. Your code runs much faster and gives the same result as my model in the middle. By the way, in the REPEATED statement, SUBJECT = subjid(clinic) gives the same result as with SUBJECT=subjid, since subjid is unique across clinic. May I suppose you agree with my model in the middle with clinic in CLASS statement, given subjid is unique across clinic?
jiltao
SAS Super FREQ

Yes, specifying subject=subjid or subject=subjid(clinic) would make no statistical difference in your case, but numerically, specifying subject=subjid(clinic) would make the model to be processed by subjects and therefore is more efficient. You must have a common subject in your RANDOM and REPEATED statements in order for the model to be processed by subjects, and that is why nesting here helps -- clicnic is the common subject syntactically.

Thanks,

Jill

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
  • 5 replies
  • 657 views
  • 4 likes
  • 3 in conversation