In a logistic or probit model for a binary response, the signs of the parameter estimates might seem to be backward if you model the probability of the wrong response level. The LOGISTIC, GENMOD, GLIMMIX, and other procedures in SAS® 9 and the LOGSELECT, GENSELECT and other procedures in SAS® Viya® document the level it models (for binary responses), the order of levels (for ordinal responses), or the reference level (for nominal responses) in the SAS log and/or below the Response Profile table in the displayed results. For binary and ordinal response models, switching the modeled level or the ordering of the levels is reflected in the model by the parameter estimates switching signs. It also causes odds ratio estimates in a logistic model to be inverted as described in this note.
The following discusses the ways that you can explicitly set the modeled response level, order of levels, or reference level. These are illustrated using the LOGISTIC and LOGSELECT procedures, but other procedures offer many of the same options. Since most procedures can analyze both raw data (each observation contains the response from an individual unit) or aggregated data (one or more observations summarize the responses from multiple units), the analysis of both forms is discussed.
You should explicitly specify the response level you want to model by using the EVENT= response option in the MODEL statement. For example, if your response variable, Y, has values 0 and 1 in your data and you want to model the probability of level 1, then specify the EVENT="1" response variable option as below. If your response variable has a format associated with it, specify the formatted value of the desired level in the EVENT= option.
proc logistic; model y(event="1") = your-model-effects; run;
If the data are in aggregated form with a variable containing the number of events observed and a variable containing the total number (events and nonevents), then use the events/trials response syntax. Since the event and nonevent counts are clear with this syntax, the EVENT= option is not needed or supported. For example, if the variable R contains the number of events and variable N contains the total, then you can specify:
proc logistic; model r/n = your-model-effects; run;
In addition to events/trials syntax, PROC LOGSELECT supports additional syntax for aggregated data called multinomial syntax. This syntax can be used when you have a variable containing the number of events and a variable containing the number of nonevents. For example, if the variable True contains the number of events and variable False contains the number of nonevents, then specify both variables in the response side of the MODEL statement. Note that the event counts variable is specified first.
proc logselect; model True False = your-model-effects; run;
Correct results depend on the preserving the natural ordering of your response variable's levels – either logically increasing or decreasing. Be sure to examine the Response Profile table to verify that the order of the response levels shown is strictly increasing or decreasing. In the Response Profile table, the response levels are associated with Ordered Values 1, 2, 3, ... and the modeling procedures always model the probabilities of response levels associated with lower Ordered Values. But you can control which response levels are associated with the Ordered Values.
You can use the DESCENDING and/or ORDER= response option to set the response level ordering. Consider a response variable Y that has values "lo ", "med", and "hi ". The following statements use the default alphanumeric ordering of the levels.
proc logistic; model y = your-model-effects; run;
This order is not logically increasing or decreasing and cannot produce meaningful results.
If the first occurrences of the levels in the data set are in a logical order, increasing or decreasing, add the ORDER=DATA response variable option to preserve that order. Suppose the levels appear in the order "lo ", "med", and "hi " in the data.
proc logistic; model y(order=data) = your-model-effects; run;
The resulting analysis models the probability of lower response levels since they are associated with the lower Ordered Values.
If the preference is to model higher response levels, you can add the DESCENDING option to reverse the above ordering of the response levels relative to the Ordered Values. Doing so changes the signs on the parameter estimates.
proc logistic; model y(order=data descending) = your-model-effects; run;
Aggregated ordinal data summarize the responses from multiple units (such as a group) in one or more observations and can appear in either a wide or a tall form. In the wide form, a group's responses appear in one observation and there is a variable for each response level containing the number of occurrences of that level in the group. In the tall form, a group has one observation per response level with a single variable indicating the response level and a second variable containing the number of occurrences of that level. This second count variable is used in the FREQ statement.
Examples of both wide and tall forms are shown below. SAS 9 procedures, such as LOGISTIC and GENMOD, can analyze only the tall form. Data in wide form must be transformed into tall form as shown below. PROC LOGSELECT in SAS Viya can handle both tall and wide forms. With either form, response level ordering must be controlled to produce meaningful results.
data wide; input x lo med hi; datalines; 1 85 10 5 2 70 20 10 3 62 25 13 4 55 20 25 5 30 32 38 ; data tall; set wide; keep y x f; y='lo '; f=lo; output; y='med'; f=med; output; y='hi '; f=hi; output; run;
The following statements analyze the TALL data. Use the FREQ statement to identify the count variable. To control level order, use the ORDER= and DESCENDING options as above. Reversing the order of the levels switches the signs on the parameter estimates. In PROC LOGSELECT in SAS Viya, the ORDER= option additionally allows you to list the levels in the desired order. In the example below, PROC LOGSELECT is run after starting a CAS session and creating a CAS libref called SASCAS1.
proc logistic data=tall; freq f; model y(order=data) = x; run; data sascas1.tall; set tall; run; proc logselect data=sascas1.tall; freq f; model y(order='lo' 'med' 'hi') = x; run;
PROC LOGSELECT can handle the wide data form directly by using multinomial syntax. The levels are ordered as listed so that you model the probabilities of levels earlier in the list. The ORDER= and DESCENDING options are not available with the multinomial syntax.
data sascas1.wide; set wide; run; proc logselect data=sascas1.wide; model lo med hi = x; run;
When you specify the LINK=GLOGIT option in the MODEL statement (available in several SAS 9 and SAS Viya procedures), the procedure fits a generalized logit model which is appropriate for a response with unordered levels. For this model, the specification of the reference level of the logits is important rather than the order of the response levels in the Response Profile table.
Use the REF= response option to identify the response level that you want as the reference (denominator) level in each of the logits that are modeled. For example, if nominal response Y has levels 1, 2, 3 and level 1 is considered the reference level, then specify:
proc logistic; model y(ref='1') = your-model-effects / link=glogit; run;
This will model the following generalized logits:
log(p2/p1) log(p3/p1)
where p1, p2, and p3 are the probabilities of Y=1, Y=2, and Y=3. Note that the probability for reference level 1 (p1) appears in the denominator of both logits.
As with ordinal data, nominal response data can be in wide or tall forms as shown above. Suppose the response levels are "red ", "green", and "blue " and "red " is considered the reference level. These statements fit the nominal model.
proc logistic; freq f; model y(ref="red") = your-model-effects / link=glogit; run;
The wide data form can be analyzed by PROC LOGSELECT using multinomial syntax. The level specified last in the response variable list is treated as the reference level for the logits.
proc logselect; model green blue red = your-model-effects / link=glogit; run;