BookmarkSubscribeRSS Feed
ZhiyingYou
Calcite | Level 5

Hi all,

I have a question about interaction when using proc logistic for data analysis.   I have a binary outcome death(0/1) and two binary predictors, MIHP(0/1) and black(0/1).  I ran the following codes.  To fit a logistic model with interaction between MIHP and black, I do go with two ways as follows.  I expect to see exactly the same results in the output of the two ways, but I do not.  Can anyone explain why?

Way#1: adding MIHP|black to the right hand side of the model statement

Way#2: first creating interaction variablein interact=MIHP*black, then adding MIHP, black, and interact to the rightside of the model statement

The two ways provide excatly the same model fit statistics (AIC, SC, and -2LogL), but the MLE of the parameters are not the same.

Why this happens? Which is the correct one? Or they should be used differently?

Thanks for the help,

Zhiying

2 REPLIES 2
plf515
Lapis Lazuli | Level 10

Can you give more detail? Possibly the data?  When I tried this on a toy example, I got the same results for both models:

data junk;

input var1  var2  DV $ count;

interact = var1*var2;

datalines;

0  0 0 100

0  0 1  50

0  1 0  25

0  1 1  75

1  0 0  100

1 0  1  10

1 1 0  10

1 1 1 90

;

proc logistic data = junk;

  model DV = var1 var2 interact;

  freq count;

run;

proc logistic data = junk;

  model DV = var1|var2;

  freq count;

run;

PGStats
Opal | Level 21

The differences you get are most likely due to differences in parameterisations. Not the same interaction levels are estimated in both fits. Look as this simple example:

data cars;

length ab ba $4;

set sashelp.cars;

a = cylinders <= 4;

b = drivetrain = "Front";

cheap = MSRP <= 30000;

ab = cats("a",a,"b",b);

ba = cats("b",b,"a",a);

run;

title "a|b";

proc logistic data=cars;

class a b;

model cheap = a|b;

ods output parameterEstimates=a_b;

run;

title "a b ab";

proc logistic data=cars;

class a b ab;

model cheap = a b ab;

ods output parameterEstimates=ab;

run;

title "a b ba";

proc logistic data=cars;

class a b ba;

model cheap = a b ba;

ods output parameterEstimates=ba;

run;

data parmEstimates;

length model classVal0 classVal1 $4;

set a_b ab ba indsname=ds;

model = scan(ds,2,".");

where DF > 0;

run;

title "Parameter estimates for the three parameterisations";

proc print data=parmEstimates noobs; run;

Check which levels of a and b are estimated in each model.

PG

PG

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 2 replies
  • 1164 views
  • 6 likes
  • 3 in conversation