BookmarkSubscribeRSS Feed
Ruth
Fluorite | Level 6

It is very interesting to identify a problem regarding the PROC LOGISTIC. Hope this can be confirmed and corrected.

For the following data, I used PROC LOGISTIC to run a regression analysis. To check the results, I used the options XBETA which is simply the sum of the coefficients (+intercept). Please see the problem at the bottom.

data work.a;
input y x1 $ x2 $;
datalines;
0 a a
1 a a
1 a b
0 a b
1 b a
0 b a
1 b b
0 b b
1 c a
1 c a
0 c b
1 c b
1 a b
0 a a
1 b a
1 a a
0 c b
0 b b
1 b a
0 c a
;

proc logistic data=work.a outest=work.coeff descending; /*or use ODS: ods output ParameterEstimates=work.coeff*/
class x1 x2;
model y=x1 x2;
output out=work.pred01(drop=_level_) xbeta=beta;
run;


/*Results of paramter estimates*/
                                 Standard          Wald
Parameter      DF    Estimate       Error    Chi-Square    Pr > ChiSq

Intercept       1      0.1612      0.4606        0.1226        0.7263
x1        a     1      0.0806      0.6426        0.0157        0.9002
x1        b     1      0.0806      0.6426        0.0157        0.9002
x2        a     1      0.3852      0.4602        0.7006        0.4026

/*Results of predictions*/
Obs    y    x1    x2      beta        pred

  1    0    a     a      0.62706    0.65182
  2    1    a     a      0.62706    0.65182
  3    1    a     b     -0.14333    0.46423
  4    0    a     b     -0.14333    0.46423
  5    1    b     a      0.62706    0.65182
  6    0    b     a      0.62706    0.65182
  7    1    b     b     -0.14333    0.46423
  8    0    b     b     -0.14333    0.46423
  9    1    c     a      0.38519    0.59512
10    1    c     a      0.38519    0.59512
11    0    c     b     -0.38519    0.40488
12    1    c     b     -0.38519    0.40488
13    1    a     b     -0.14333    0.46423
14    0    a     a      0.62706    0.65182
15    1    b     a      0.62706    0.65182
16    1    a     a      0.62706    0.65182
17    0    c     b     -0.38519    0.40488
18    0    b     b     -0.14333    0.46423
19    1    b     a      0.62706    0.65182
20    0    c     a      0.38519    0.59512
*/

For obs=1, beta is correct which is calculated as: 0.1612+0.0806+0.3852=0.62706. For obs=3, beta is negative? How can this value be negative, based on the fact that all coefficicents are positive (as shown in the part of parameter estimates)! The only way to get this value is: 0.1612+0.0806-0.3852=0.1434. So how do we interpret 0.3852 here? For the variable x2, the default type is b with coefficient 0.

1 REPLY 1
lvm
Rhodochrosite | Level 12 lvm
Rhodochrosite | Level 12

There is no bug. The results are correct. LOGISTIC uses so-called effect parameterization for class variables; this means the last level of each factor has all -1 values. This is different from the GLM-type parameterization (used in MIXED and some other procedures). If you look at the rest of the output, you will find a table called Class Level Information. For x2, you will see that level a gets a 1 for the design variable and level b gets a -1. For getting estimated values, the parameters are multiplied by the design values and then summed. For the third observation, because it corresponds to level b of x2, the estimate it is:

0.1612 + (0.0806*1) + (0.3852*(-1)) = -0.14333.

This can be tricky. There are ways of choosing other effect parameterizations.

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
  • 1 reply
  • 1233 views
  • 0 likes
  • 2 in conversation