BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Caetreviop543
Obsidian | Level 7

I am trying to run a mixed effect logistic model using proc glimmix with two random intercepts. Some background on the data, doctors and clinics were randomized to receive an intervention, so both doctors, clinics and patients have multiple visits. The goal is to determine whether doctors prescribing decreases over time, rather than patient level effects.

 

This original model execution by a different analyst in R derived two random intercepts for doctor and clinic, but I can’t find a straightforward way to do this in SAS. I am having trouble distinguishing between ‘random’, ‘repeat’ and ‘subject’ in proc glimmix. I’ve tried a few things, but the only model that worked was:

 

proc glimmix data=mydata method=quad;
class doctor clinic intervention (ref=‘0’) control (ref=‘0’);
model prescription (event =‘1’)=intervention time control intervention*time control*time intervention*control/solution link=logit dist=binary;
random intercept/subject=doctor(clinic) type=un;
run;

 

This gives me only one intercept for doctor(clinic), whereas the same model in R provides a random intercept for both doctor and clinic. The coefficients are also different. Both model variables have the exact same counts and structure. Below is the code in R:

 

Model <- glmer(prescription ~ intervention + time + control + intervention:time + control:time + intervention:control + (1|doctor) + (1|provid), data=mydata, family=binomial(link=logit), nAGQ=1, control=glmerControl(calc.derivs=FALSE))

 

Is there a way to get the random intercepts for both doctor and clinic in SAS?  Is there a reason why the results between SAS and R are inconsistent? I also tried the code below, but received an error that ‘Estimation by quadrature is available only if the data can be processed by subjects’:

 

proc glimmix data=mydata method=quad;
class doctor clinic intervention (ref=‘0’) control (ref=‘0’);
model prescription (event =‘1’)=intervention time control intervention*time control*time intervention*control/solution link=logit dist=binary;
random intercept/subject=doctor type=un;
random intercept/subject=clinic type=un;
run;
1 ACCEPTED SOLUTION

Accepted Solutions
SteveDenham
Jade | Level 19

Try this RANDOM statement (just one statement)

 

random intercept doctor/subject=clinic type=un;

The only caveat I have here is that there are going to be a lot of covariance parameters to estimate with type=un.  You may have to discard the type= option, and just get the variance components for clinic and clinic*doctor (which is the same as doctor within clinic).  This will be the only way to keep method=quad.  If you are willing to use pseudo-likelihoods you might consider:

 

random doctor clinic/solution:

SteveDenham

 

View solution in original post

3 REPLIES 3
SteveDenham
Jade | Level 19

Try this RANDOM statement (just one statement)

 

random intercept doctor/subject=clinic type=un;

The only caveat I have here is that there are going to be a lot of covariance parameters to estimate with type=un.  You may have to discard the type= option, and just get the variance components for clinic and clinic*doctor (which is the same as doctor within clinic).  This will be the only way to keep method=quad.  If you are willing to use pseudo-likelihoods you might consider:

 

random doctor clinic/solution:

SteveDenham

 

Caetreviop543
Obsidian | Level 7

The first one worked. Thank you!

sld
Rhodochrosite | Level 12 sld
Rhodochrosite | Level 12

I post here the same response as to your other posting: we would benefit from knowing more about your study design. Actually, we need to know more about your study design. Channeling Sherlock Holmes:

 

“Data!data!data!" he cried impatiently. "I can't make bricks without clay.”

Arthur Conan Doyle, The Adventure of the Copper Beeches

 

One aspect, in particular: are doctors nested within each clinic (i.e., a given doctor belongs to only one clinic), or are doctors crossed with clinics (i.e., a given doctor practices at multiple clinics)?

 

The R code specifies doctors crossed with clinics and thus produces a variance among doctors and a variance among clinic (i.e., two "random intercepts"). This is fine IF it is consistent with the design--which we do not yet know. You certainly can do the equivalent in SAS.

 

Your SAS code specifies doctors as being nesting within clinics.

 

Two different design concepts, so two different models, so different results. The actual study design determines the statistical model and that should be our guide.

 

I hope this helps move you forward. But I will note that you are in some rather deep waters, beyond what can be adequately addressed in this forum; is there a statistician at your institution that you can consult with? If so, seek their help.

 

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
  • 3 replies
  • 1108 views
  • 0 likes
  • 3 in conversation