Programming the statistical procedures from SAS

interaction when using proc logistic for data analysis

Reply
N/A
Posts: 1

interaction when using proc logistic for data analysis

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

Frequent Contributor
Posts: 140

Re: interaction when using proc logistic for data analysis

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;

Respected Advisor
Posts: 4,606

Re: interaction when using proc logistic for data analysis

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
Ask a Question
Discussion stats
  • 2 replies
  • 158 views
  • 6 likes
  • 3 in conversation