LOGSELECT Procedure
Example 18.5 Odds Ratios
(View the complete code for this example.)
title 'Example 5: Odds Ratios';
data mylib.getStarted;
input C$ y x1-x10;
datalines;
D 0 10.2 6 1.6 38 15 2.4 20 0.8 8.5 3.9
F 1 12.2 6 2.6 42 61 1.5 10 0.6 8.5 0.7
D 1 7.7 1 2.1 38 61 1 90 0.6 7.5 5.2
J 1 10.9 7 3.5 46 42 0.3 0 0.2 6 3.6
E 0 17.3 6 3.8 26 47 0.9 10 0.4 1.5 4.7
A 0 18.7 4 1.8 2 34 1.7 80 1 9.5 2.2
B 0 7.2 1 0.3 48 61 1.1 10 0.8 3.5 4
D 0 0.1 3 2.4 0 65 1.6 70 0.8 3.5 0.7
H 1 2.4 4 0.7 38 22 0.2 20 0 3 4.2
J 0 15.6 7 1.4 0 98 0.3 0 1 5 5.2
J 0 11.1 3 2.4 42 55 2.2 60 0.6 4.5 0.7
F 0 4 6 0.9 4 36 2.1 30 0.8 9 4.6
A 0 6.2 2 1.8 14 79 1.1 70 0.2 0 5.1
H 0 3.7 3 0.8 12 66 1.3 40 0.4 0.5 3.3
A 1 9.2 3 2.3 48 51 2.3 50 0 6 5.4
G 0 14 3 2 18 12 2.2 0 0 3 3.4
E 1 19.5 6 3.7 26 81 0.1 30 0.6 5 4.8
C 0 11 3 2.8 38 9 1.7 50 0.8 6.5 0.9
I 0 15.3 7 2.2 20 98 2.7 100 0.4 7 0.8
H 1 7.4 4 0.5 28 65 1.3 60 0.2 9.5 5.4
F 0 11.4 2 1.4 42 12 2.4 10 0.4 1 4.5
C 1 19.4 1 0.4 42 4 2.4 10 0 6.5 0.1
G 0 5.9 4 2.6 12 57 0.8 50 0.4 2 5.8
G 1 15.8 6 3.7 34 8 1.3 90 0.6 2.5 5.7
I 0 10 3 1.9 16 80 3 90 0.4 9.5 1.9
E 0 15.7 1 2.7 32 25 1.7 20 0.2 8.5 6
G 0 11 5 2.9 48 53 0.1 50 1 3.5 1.2
J 1 16.8 0 0.9 14 86 1.4 40 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3 14 92 0.5 40 0.4 7.5 5
B 0 4.7 4 0.9 14 99 2.4 80 1 0.5 0.7
I 1 7.5 4 2.1 20 79 0.4 40 0.4 2.5 0.7
C 0 6.1 0 1.4 38 18 2.3 60 0.8 4.5 0.7
C 0 18.3 1 1 26 98 2.7 20 1 8.5 0.5
F 0 16.4 7 1.2 32 94 2.9 40 0.4 5.5 2.1
I 0 9.4 2 2.3 32 42 0.2 70 0.4 8.5 0.3
F 1 17.9 4 1.3 32 42 2 40 0.2 1 5.4
H 0 14.9 3 1.6 36 74 2.6 60 0.2 1 2.3
C 0 12.7 0 2.6 0 88 1.1 80 0.8 0.5 2.1
F 0 5.4 4 1.5 2 1 1.8 70 0.4 5.5 3.6
J 1 12.1 4 1.8 20 59 1.3 60 0.4 3 3.8
;
data mylib.Cheese;
do Additive = 1 to 4;
input y1-y9;
output;
end;
datalines;
0 0 1 7 8 8 19 8 1
6 9 12 11 7 6 1 0 0
1 1 6 8 23 7 5 1 0
0 0 0 1 3 7 14 16 11
;
This example uses data that are examined in the section Getting Started: LOGSELECT Procedure and in Example 18.4 to demonstrate how you can use the ODDSRATIO statement to produce and customize odds ratios.
In the following code, the ODDSRATIO statement is specified with no options to produce odds ratios for all the main effects as shown in Output 18.5.1:
proc logselect data=mylib.getStarted;
model y(event='1') = x2 x5;
oddsratio;
run;
Output 18.5.1: Odds Ratios or Main-Effects Model
| Example 5: Odds Ratios |
| Odds Ratios | |||||
|---|---|---|---|---|---|
| Description | Estimate | 95% Wald Confidence Limits | p-Value | Percent Change | |
| x2 | 1.233 | 0.999 | 1.521 | 0.0507 | 23.31 |
| x5 | 1.002 | 0.987 | 1.016 | 0.8381 | 0.15 |
From Output 18.5.1, a subject whose X2 value is one unit larger (than its current value) has 1.233 times the odds of having a Y = 1 response, and a subject whose X5 value is one unit larger has 1.002 times the odds.
If your model has interactions, then the odds ratio computations depend on the values of the interacting variables. The following code produces odds ratios for the main effects, but because of interactions, these odds ratios depend on the values of the interacting variables as displayed in Output 18.5.2:
proc logselect data=mylib.getStarted;
model y(event='1') = x2|x5;
oddsratio;
run;
Output 18.5.2: Odds Ratios with Interactions
| Example 5: Odds Ratios |
| Odds Ratios | |||||
|---|---|---|---|---|---|
| Description | Estimate | 95% Wald Confidence Limits | p-Value | Percent Change | |
| x2 at x5=49.6 | 1.302 | 1.033 | 1.641 | 0.0252 | 30.24 |
| x5 at x2=3.41 | 1.004 | 0.989 | 1.020 | 0.5843 | 0.44 |
The odds ratios shown in Output 18.5.2 are computed at the mean values of the interacting variables as computed from the data used to fit the model. You can change these values by specifying an AT option for each individual odds ratio, as follows. The output is shown in Output 18.5.3.
proc logselect data=mylib.getStarted;
model y(event='1') = x2|x5;
oddsratio x2(at(x5=1)) x5(at(x2=3));
run;
Output 18.5.3: Odds Ratios with the AT Option
| Example 5: Odds Ratios |
| Odds Ratios | |||||
|---|---|---|---|---|---|
| Description | Estimate | 95% Wald Confidence Limits | p-Value | Percent Change | |
| x2 at x5=1 | 1.925 | 1.160 | 3.193 | 0.0112 | 92.48 |
| x5 at x2=3 | 1.008 | 0.991 | 1.025 | 0.3648 | 0.77 |
Alternatively, you can obtain the same results shown in Output 18.5.3 by specifying the following AT global option:
proc logselect data=mylib.getStarted;
model y(event='1') = x2|x5;
oddsratio x2 x5 / at(x5=1 x2=3);
run;
When odds ratios are computed for continuous variables, by default the odds ratio compares the odds computed at the mean of the continuous variable to the odds computed one unit higher than the mean. However, it might be more interesting to compare larger differences; for example, if you are comparing ages, a 10-year difference might be more interesting than a 1-year difference. You can customize the odds ratios accordingly by specifying the desired unit difference as an individual option or as a global option. In the following code, the global options set the units for X2 to 2 and 3 and for X5 to 4. However, the individual odds ratio unit option for X2 overrides the global option value and sets the units for X2 to 5.
proc logselect data=mylib.getStarted;
model y(event='1') = x2|x5;
oddsratio x2(unit=5) x5 / unit(x2=2 3 x5=4);
run;
Output 18.5.4: Odds Ratios with the UNIT Option
| Example 5: Odds Ratios |
| Odds Ratios | |||||
|---|---|---|---|---|---|
| Description | Estimate | 95% Wald Confidence Limits | p-Value | Percent Change | |
| x2 units=5 at x5=49.6 | 3.747 | 1.179 | 11.911 | 0.0252 | 274.72 |
| x5 units=4 at x2=3.41 | 1.018 | 0.956 | 1.084 | 0.5843 | 1.77 |
When odds ratios are computed for classification variables, by default the odds ratio compares the odds computed at each level of the classification variable to the odds computed at the reference level. For example, consider the ordinal response data from Example 18.4. The following program displays the default odds ratios in Output 18.5.5:
proc logselect data=mylib.Cheese;
class Additive(ref='4') / param=ref;
model y1-y9=Additive;
oddsratio;
run;
Output 18.5.5: Odds Ratios for Ordinal Response Model
| Example 5: Odds Ratios |
| Odds Ratios | |||||
|---|---|---|---|---|---|
| Description | Estimate | 95% Wald Confidence Limits | p-Value | Percent Change | |
| Additive 1 vs 4 | 5.017 | 2.380 | 10.577 | <.0001 | 401.68 |
| Additive 2 vs 4 | 143.257 | 56.277 | 364.671 | <.0001 | 14225.70 |
| Additive 3 vs 4 | 27.735 | 12.133 | 63.399 | <.0001 | 2673.47 |
From the first line in Output 18.5.5, subjects who eat cheese with Additive = 1 have 5.017 times the odds to dislike it (Y1 end of the scale ) than to like it (Y9 end of the scale) than subjects who eat cheese with Additive = 4.
By default, the odds ratios shown in Output 18.5.5 compare each level of Additive to its reference level, Additive = 4. Output 18.5.6 compares all pairs of Additive levels by specifying the DIFF=ALL global option in the following program:
proc logselect data=mylib.Cheese;
class Additive(ref='4') / param=ref;
model y1-y9=Additive;
oddsratio / diff=all;
run;
Output 18.5.6: Odds Ratios with the DIFF=ALL Option
| Example 5: Odds Ratios |
| Odds Ratios | |||||
|---|---|---|---|---|---|
| Description | Estimate | 95% Wald Confidence Limits | p-Value | Percent Change | |
| Additive 1 vs 2 | 0.035 | 0.015 | 0.081 | <.0001 | -96.50 |
| Additive 1 vs 3 | 0.181 | 0.087 | 0.375 | <.0001 | -81.91 |
| Additive 2 vs 3 | 5.165 | 2.475 | 10.778 | <.0001 | 416.53 |
| Additive 1 vs 4 | 5.017 | 2.380 | 10.577 | <.0001 | 401.68 |
| Additive 2 vs 4 | 143.257 | 56.277 | 364.671 | <.0001 | 14225.70 |
| Additive 3 vs 4 | 27.735 | 12.133 | 63.399 | <.0001 | 2673.47 |