Programming the statistical procedures from SAS

Interaction terms in proc logistic; output does not give odds ratio

Accepted Solution Solved
Reply
Regular Contributor
Posts: 173
Accepted Solution

Interaction terms in proc logistic; output does not give odds ratio

Hi,

i am trying to use the interaction terms (gender*income) in proc logistic, and the program looks like below,

proc logistic data =library.nismicathcabg4 descending ;

class  gender  (ref= first) dm dmcx htn_c  aids alcohol ANEMDEF arth race1(ref=first)  income (ref=first) hosp_location h_contrl(ref=first) hosp_teach bldloss chf chrnlung coag depress drug hypothy liver lymph lytes mets neuro obese para perivasc psych pulmcirc renlfail tumor 

ulcer valve wghtloss cararrhythmia /param=ref;

model  died=  age female  dm dmcx  htn_c  aids alcohol ANEMDEF arth race1 zipinc_qrtl hosp_location h_contrl hosp_teach  TOTAL_DISC bldloss chf chrnlung coag depress drug hypothy liver lymph lytes mets neuro obese para perivasc psych pulmcirc renlfail tumor ulcer valve wghtloss cararrhythmia gender*income;

weight discwt;

title 'Logi Reg interaction in-hosp mortality vs gender in overall patients using "where" option with RACE ';

run;

quit;

But the output doesnot give me the odds ratio and CI levels,

It shows only the significance level.

I am wondering what i should do to get the Odds ratio and CI.

Thanks,

Ashwini

Interaction terms Odds ratio using proc glimmix


Accepted Solutions
Solution
‎07-06-2017 10:11 AM
Valued Guide
Valued Guide
Posts: 684

Interaction terms in proc logistic; output does not give odds ratio

This usage note is very helpful regarding odds ratios for interactions. Starting in SAS 9.2, several nice features have been added to LOGISTIC.

http://support.sas.com/kb/24/455.html

View solution in original post


All Replies
Super User
Posts: 18,549

Interaction terms in proc logistic; output does not give odds ratio

Check the docs, I think it has an example

From the docs:

"If you need to compute odds ratios for an effect involved in interactions or nestings, or using some other parameterization, then you should specify an ODDSRATIO statement for that effect."

Regular Contributor
Posts: 173

Interaction terms in proc logistic; output does not give odds ratio

Thanks Reeza,  but I have been looking up online about using the ODDSratio statement but havenot found anything so far.

Not sure where exactly to include the ODDS ratio statement in the model.

Any idea?

Thanks a lot!

Contributor
Posts: 67

Interaction terms in proc logistic; output does not give odds ratio

Hello,

I was working on a project like this last week. The same problem happened to me! If my memory serves me correct, you should have a data step above the proc logistic step in which you define the interaction terms. So I think if you did something like this, it would work:

Data= library.interaction; set library.nismicathcabg4;

gender_income=gender*income; run;

Proc logistic data=library.interaction;

Class gender income [and other variables] gender_income;

Model died = gender income [and other variables] gender_income;run;

This is the exact code I used for mine, and it gave me odds ratios (below). Hope this helps!

DATA CTS.interaction; set CTS.smokedrop;

gender_parentsmokes= gender*parentsmokes;

gender_sport= gender*sport;

gender_white= gender*ethnic_white;

gender_age=gender*age;

age_parentsmokes= AGE*PARENTSMOKES;

age_white= AGE*ETHNIC_WHITE;

age_sport= AGE*SPORT;

run;

/*VANI GOT AGE*BFGF AGE*RACE RD*BFGF*/

proc logistic data=CTS.interaction desc;

class PARENTSMOKES(DESCENDING) GENDER(DESCENDING) SPORT(DESCENDING) ethnic_white(DESCENDING)

gender_parentsmokes(DESCENDING)   gender_sport(DESCENDING) gender_white(DESCENDING);

model CIGMONTHS =  ETHNIC AGE PARENTSMOKES GENDER SPORT SMOKE ethnic_white

gender_parentsmokes gender_sport gender_white gender_age

age_parentsmokes  age_white age_sport /lackfit;

run;

Regular Contributor
Posts: 173

Interaction terms in proc logistic; output does not give odds ratio

thanks for your reply with the above example.

It does work but I am not sure how to read the results. The gender variable has 2 (0= male 1= female) levels and the income has 4 level,(coded 1 to 4 for income strata)  so basically both are categorical varibales.

The 3 Odds ratio show as gender_income= 1 vs 4, 2 vs 4 and 3 vs 4. it is not showing the cateogry coded as "0" in the new gender*income variable. The new gender _icnome variable has 45 categories, (0,1,2,3,4)

Any ideas?

Super User
Posts: 18,549

Interaction terms in proc logistic; output does not give odds ratio

It's a 'statement' not an option in the model.

If you check the docs you'll see it has its own line and you set how you want it to look.

In general you can't get odds ratio for the variables in an interaction term anyways unless you consider the levels of the other variable.

so for your model

add the lines for your variables that are in the interaction terms:

*Other model statements go before;

oddsratio gender;

oddsration income;

run;

Solution
‎07-06-2017 10:11 AM
Valued Guide
Valued Guide
Posts: 684

Interaction terms in proc logistic; output does not give odds ratio

This usage note is very helpful regarding odds ratios for interactions. Starting in SAS 9.2, several nice features have been added to LOGISTIC.

http://support.sas.com/kb/24/455.html

Regular Contributor
Posts: 173

Interaction terms in proc logistic; output does not give odds ratio

I used following SAS procedure. to get the OR for interaction term,.

I have never used the proc glimmix before. I am attaching the output in the original post.

WIll appreciate if some one could let me know if it is the correct output and how to interprete it.

proc glimmix data =library.nismicathcabg4  ; */ridging=absolute not needed*/;

class   female dm dmcx htn_c  aids alcohol ANEMDEF arth race1   ZIPINC_QRTL hosp_location h_contrl hosp_teach

bldloss chf chrnlung coag depress drug hypothy liver lymph lytes mets neuro obese para perivasc psych pulmcirc renlfail tumor 

ulcer valve wghtloss cararrhythmia ;

model  died=  age female  dm dmcx htn_c  aids alcohol ANEMDEF arth race1 zipinc_qrtl hosp_location h_contrl hosp_teach  TOTAL_DISC

bldloss chf chrnlung coag depress drug hypothy liver lymph lytes mets neuro obese para perivasc psych pulmcirc renlfail tumor

ulcer valve wghtloss cararrhythmia female*ZIPINC_QRTL/dist=binary;

lsmeans female*ZIPINC_QRTL/ slicediff=female oddsratio cl;

weight discwt;

title 'Logi Reg interaction in-hosp mortality vs gender in overall patients using "where" option with RACE ';

run;

quit;

Regular Contributor
Posts: 173

Interaction terms in proc logistic; output does not give odds ratio

what option do i use in proc glimmix to model the probabilty that Died=1?

in proc logistic i used 'desceding ' option.. it doesnot work in proc glimmix.

The GLIMMIX procedure is modeling the probability that DIED='0: Did not die in hospital'.
Regular Contributor
Posts: 173

Interaction terms in proc logistic; output does not give odds ratio

thanks Reea, but I wonder when you mention docs, what are you exactly referring to?

Valued Guide
Valued Guide
Posts: 684

Interaction terms in proc logistic; output does not give odds ratio

I get the impression that you did not follow the links within the site I told you about. Example 3 gives you many details on using LOGISTIC for odds ratios with interactions. You don't need GLIMMIX.

http://support.sas.com/kb/24/447.html#ex3

The other docs would be the User's Guide for LOGISTIC that describes the ODDSRATIO statement.

Regular Contributor
Posts: 173

Interaction terms in proc logistic; output does not give odds ratio

Thanks for the above link. I read all of it and only a small part made sense to me, may be because I dont have a good mathematical background. Bases on that documentation;I came up with these code for my data anayses, using contrast stament and oddsratio stament in prc logistic.

I would like to make sure, if it looks correct.

I want to see the interaction between gender (variable female)  and underwent any cardiac procedure (variable annyproc1) and looking at the outcome= inhospital mortality/(variable died)

Proc logistic data=library.nismicathcabg4 descending ;

Class female  (ref= first) dm dmcx htn_c  aids alcohol ANEMDEF arth race1(ref=first)   ZIPINC_QRTL(ref=first) hosp_location h_contrl(ref=first) hosp_teach bldloss chf chrnlung coag depress drug hypothy liver lymph lytes mets neuro obese para perivasc psych pulmcirc renlfail tumor anyproc1 ulcer valve wghtloss cararrhythmia  /param=ref;

Model died = age  dm dmcx htn_c  aids alcohol ANEMDEF arth race1 zipinc_qrtl hosp_location h_contrl hosp_teach  TOTAL_DISC bldloss chf chrnlung coag depress drug hypothy liver lymph lytes mets neuro obese para perivasc psych pulmcirc renlfail   tumor ulcer valve wghtloss cararrhythmia anyproc1 female (anyproc1 )/expb ;

contrast 'female 1 vs 0 in anyproc1'

female (anyproc1 ) 1 0 -1 000/estimate=both;

weight discwt;

title 'Logi Reg interaction between anyproc vs gender in overall patients using "where" option with RACE ';

run;

Proc logistic data=library.nismicathcabg4 descending ;

Class female  (ref= first) dm dmcx htn_c  aids alcohol ANEMDEF arth race1(ref=first)   ZIPINC_QRTL(ref=first) hosp_location h_contrl(ref=first) hosp_teach bldloss chf chrnlung coag depress drug hypothy liver lymph lytes mets neuro obese para perivasc psych pulmcirc renlfail tumor anyproc1 ulcer valve wghtloss cararrhythmia  /param=ref;

Model died = age female  dm dmcx htn_c  aids alcohol ANEMDEF arth race1 zipinc_qrtl hosp_location h_contrl hosp_teach  TOTAL_DISC bldloss chf chrnlung coag depress drug hypothy liver lymph lytes mets neuro obese para perivasc psych pulmcirc renlfail  anyproc1 tumor ulcer valve wghtloss cararrhythmia  ;

oddsratio female / at(anyproc='1');

weight discwt;

title 'Logi Reg interaction between anyproc vs gender in overall patients using "where" option with RACE ';

run;

from the contrast statement:

I could find  on this link what do 1 0 -1 000/ mean from following statement,

contrast 'female 1 vs 0 in anyproc1'

female (anyproc1 ) 1 0 -1 000/estimate=both;

Appreciate your resposne,

Thanks,

Regular Contributor
Posts: 173

Interaction terms in proc logistic; output does not give odds ratio

Also after running the modelw ith oddsratio statement, I didn't find the "p value/ the significance level", in the output, It does show the ods ratio but not the p value/ .

Where should i look for the p value?

I am attaching the output to the original post.

Thanks

Valued Guide
Valued Guide
Posts: 684

Interaction terms in proc logistic; output does not give odds ratio

You do not get a p value with the ODDSRATIO statement. If the confidence interval does not include 1, then the effect is significant.You can get the p value from the contrast or estimate statement. If you set up the contrast statement correctly, then the odds ratio output should be the same as the contrast output (for the row corresponding to type=EXP).

The numbers in the contrast statement are the coefficients that multiple the estimated effects to give the desired contrast. Since you don't recognize these, you must be new to the use of contrast and estimate statements. You would have to do quite a bit of reading in the logistic, or genmod, or glm procedures to get comfortable with these. I don't know how many levels there are for anyproc1, and the specific order of the one you are interested in.

Regular Contributor
Posts: 173

Interaction terms in proc logistic; output does not give odds ratio

Thank for confirming that the Odds ratio is the value corresponding to type=EXP.

Yes, that is right, i never worked with interactions before, will try to spend some time understanding those numbers.

the interaction variables i am using are all binary coded as 0 and 1.

Variable female coded as (0= male , 1= female)

Variable anyproc1 coded as (0= no, 1= yes)

Variable noproc1 coded as (0= no, 1= yes)

I want to check the interactions between women*anyproc1=1(women who underwent any procedure) , women*noproc1=1, and  men*noproc1=1 as compared to men*anyproc=1.

How should I go about this?

How do i inlcude all 3 interactions terms in the model and compare them with the ref (men*anyproc=1)?

Appreciate any help.

Thanks,

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 36 replies
  • 10086 views
  • 0 likes
  • 4 in conversation