DATA Step, Macro, Functions and more

Using contrast in proc logistic

Reply
Occasional Contributor
Posts: 13

Using contrast in proc logistic

I want to use contrast in proc logistic, but I don’t seem to clearly understand where the numbers in the contrast statement come from.

My model include:

  • Region: variable with 3 categories (1-Sud; 2-GAE; 3-GAO)
  • Land access: variable with 2 categories (‘NO’; ‘Wi’)
  • Season: variable with 2 categories (Spring; Summer)
  • AND my dependent variable IDE: with 3 categories

I want to do contrast for the interaction between season and land access; and a second contrast statement for the interaction between region and season:

My model (without the contrast) is:

proc logistic data = results2;

Class Land_acces (param=ref ref='Non')

region (param=ref ref='1-Sud')

season (param=ref ref='spring') / param=ref order=internal; 

model IDE_groupe(event='A - Peu ou pas de faim dans le ménage')=

season

Land_acces

region

Land_acces * season

region * season/ expb;

format season saison.;

run;

 image.png

  • Should I use this table (I got after running the code for proc logistic) to write the contrast statement?
  • What should I write in the contrast statement to have a table like this:

Region*season

Land_acces*season

 image.png

contrast 'region = 1-Sud season summer vs spring' region*season ……………… / estimate = exp ;

 contrast 'region = 2-GAE season summer vs spring' region*season ……………… / estimate = exp;

 contrast 'region = 3-GAO season summer vs spring' region*season ………………/ estimate = exp;

 

 contrast ' Land_acces = Non season summer vs spring' Land_acces*season ……………… / estimate = exp;

 contrast ' Land_acces = Wi season summer vs spring' Land_acces* season ………………/ estimate = exp;

Respected Advisor
Posts: 2,649

Re: Using contrast in proc logistic

There's no point in using a CONTRAST statement to compare one level to another level. You can use the LSMEANS statements to compare the means of interest.

 

CONTRAST statement would be useful if you want to compare some non-trivial linear combinations of the means levels; such as the average of groups 2 and 3, with the average of group 1.

--
Paige Miller
Occasional Contributor
Posts: 13

Re: Using contrast in proc logistic

Posted in reply to PaigeMiller

proc Logistic data=results2;

         class region season terres_acces;

         model IDE_groupe = region season

terres_acces

terres_acces * season

region * season / cl ;

lsmeans region*season / oddsratio ilink cl pdiff;

lsmeans terres_acces*season / oddsratio cl pdiff;

format season saison.;

run;

I used this code and I got this table:

It doesn’t include all the levels for the 2 variables: for region, I only got 1-Sud, 2-GAE and not 3-GAO (I think it did a comparison with that level of the variable though I want it to be compared separately).

image.png

I used Lsmeans with proc glimmix and it worked very well but it was for another dependent variable with 2 categories; proc glimmix didn’t work well for me with a dependent variable with 3 categories.

   proc glimmix data=results2;

         class region

season

terres_acces;

         model MDD_W_5 = region season

terres_acces

terres_acces * season

region * season/ or dist=binary;

lsmeans region*season / slicediff=region oddsratio ilink cl pdiff;

lsmeans terres_acces*season / slicediff=terres_acces oddsratio cl pdiff;

format season saison.;

run;

This is what I got with proc Glimmix for the dependant variable with 2 categories: (I want to find results for my new dependent variable presents in a similar way!!)

image.png

Respected Advisor
Posts: 2,649

Re: Using contrast in proc logistic

LSMEANS is very generic, it doesn't care if the dependent variable has 2 levels or 3 levels, it will work, why don't you try it?

--
Paige Miller
Super User
Posts: 22,844

Re: Using contrast in proc logistic

Can you use an ODDSRATIO statement instead? I find those much easier to navigate.

Ask a Question
Discussion stats
  • 4 replies
  • 56 views
  • 3 likes
  • 3 in conversation