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

How can I get the odds ratio and 95% confidence interval from mixed effect logistic regression in sas?

I am aware that odds ration could be derived by exponentiating the obtained estimate.

 

A sample dataset and code (derived from a prior post)

data herd;
call streaminit(1);
do herd = 1 to 10;
   do testyear = 2005, 2015;
      do Time = 1 to 6;
         eta = -1 + 0.1*herd + 0.5*Time - 2*(testyear=2015);
         mu = logistic(eta);
         mpd = rand("Bernoulli", mu);
         output;
      end;
   end;
end;

proc GLIMMIX data = herd;
   class testyear TIME;
   model MPD = TESTYEAR TIME / s dist=binary;
   RANDOM HERD;
RUN;

Appreciate any advice.

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
/*
You could get CI of estimated parameter,
and EXP() this CI to get CI of ODDS Rario. 
*/

data herd;
call streaminit(1);
do herd = 1 to 10;
   do testyear = 2005, 2015;
      do Time = 1 to 6;
         eta = -1 + 0.1*herd + 0.5*Time - 2*(testyear=2015);
         mu = logistic(eta);
         mpd = rand("Bernoulli", mu);
         output;
      end;
   end;
end;
run;

ods output ParameterEstimates=ParameterEstimates SolutionR=SolutionR;
proc GLIMMIX data = herd;
   class HERD testyear TIME;
   model MPD = TESTYEAR TIME / s dist=binary cl ODDSRATIO;
   RANDOM intercept /cl subject=HERD;
RUN;


data fixed;
 set ParameterEstimates;
 odds_ratio=exp(Estimate);
 lower_odds_ratio=exp(Lower);
 upper_odds_ratio=exp(Upper);
run;
proc print label;run;


data mixed;
 set SolutionR;
 odds_ratio=exp(Estimate);
 lower_odds_ratio=exp(Lower);
 upper_odds_ratio=exp(Upper);
run;
proc print label;run;

View solution in original post

5 REPLIES 5
Ksharp
Super User
/*
You could get CI of estimated parameter,
and EXP() this CI to get CI of ODDS Rario. 
*/

data herd;
call streaminit(1);
do herd = 1 to 10;
   do testyear = 2005, 2015;
      do Time = 1 to 6;
         eta = -1 + 0.1*herd + 0.5*Time - 2*(testyear=2015);
         mu = logistic(eta);
         mpd = rand("Bernoulli", mu);
         output;
      end;
   end;
end;
run;

ods output ParameterEstimates=ParameterEstimates SolutionR=SolutionR;
proc GLIMMIX data = herd;
   class HERD testyear TIME;
   model MPD = TESTYEAR TIME / s dist=binary cl ODDSRATIO;
   RANDOM intercept /cl subject=HERD;
RUN;


data fixed;
 set ParameterEstimates;
 odds_ratio=exp(Estimate);
 lower_odds_ratio=exp(Lower);
 upper_odds_ratio=exp(Upper);
run;
proc print label;run;


data mixed;
 set SolutionR;
 odds_ratio=exp(Estimate);
 lower_odds_ratio=exp(Lower);
 upper_odds_ratio=exp(Upper);
run;
proc print label;run;
mrahouma
Obsidian | Level 7
Thanks a lot. Upvoted and accepted as answer. Would it be possible to explain difference between RANDOM intercept /cl subject=HERD; vs RANDOM HERD; only that I wrote? Appreciate your help and time
Ksharp
Super User
If you need MIXED effect ,you need a variable named SUBJECT . I look at your dataset and think HERD is the SUBJECT. So I wrote:
RANDOM intercept /cl subject=HERD;
and @SteveDenham @lvm @StatDave could give you the exact right syntax as long as you pointed out what you are looking for .
SteveDenham
Jade | Level 19

The two syntax's should give you the same results.  However, for complex designs, the use of the intercept/subject= syntax improves convergence.  See this paper:

https://support.sas.com/resources/papers/proceedings15/SAS1919-2015.pdf 

 

SteveDenham

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
  • 1287 views
  • 6 likes
  • 3 in conversation