LOGSELECT Procedure
Example 18.2 Modeling Binomial Data
(View the complete code for this example.)
If are independent binary (Bernoulli) random variables with common success probability
, then their sum is a binomial random variable. In other words, a binomial random variable with parameters n and
can be generated as the sum of n Bernoulli(
) random experiments. The LOGSELECT procedure uses a special syntax, the events/trials syntax, to express data in binomial form.
Consider the following data, taken from Cox and Snell (1989, pp. 10–11), of the number of ingots not ready for rolling (r) out of n tested for a number of combinations of heating time and soaking time. If each test is carried out independently and if for a particular combination of heating and soaking time there is a constant probability that the tested ingot is not ready for rolling, then the random variable r follows a binomial distribution, where the success probability
is a function of heating and soaking time.
data Ingots;
input Heat Soak r n @@;
Obsnum= _n_;
datalines;
7 1.0 0 10 14 1.0 0 31 27 1.0 1 56 51 1.0 3 13
7 1.7 0 17 14 1.7 0 43 27 1.7 4 44 51 1.7 0 1
7 2.2 0 7 14 2.2 2 33 27 2.2 0 21 51 2.2 0 1
7 2.8 0 12 14 2.8 0 31 27 2.8 1 22 51 4.0 0 1
7 4.0 0 9 14 4.0 0 19 27 4.0 1 16
;
data mylib.Ingots;
set Ingots;
run;
The following statements show the use of the events/trials syntax to model the binomial response. The events variable in this situation is r (the number of ingots not ready for rolling), and the trials variable is n (the number of ingots that are tested). The dependency of the probability of not being ready for rolling is modeled as a function of heating time, soaking time, and their interaction. The ASSOCIATION option displays ordinal measures of association between the observed responses and the predicted probabilities. The CTABLE option saves statistics to the mylib.Roc data table that are used to evaluate the predictive power of the model. The OUTPUT statement stores the linear predictors and the predicted probabilities in the mylib.Out data table along with the other variables from the input data table.
proc logselect data=mylib.Ingots association ctable(out=mylib.Roc nocounts tpf fpf);
model r/n = Heat Soak Heat*Soak;
output out=mylib.Out xbeta predicted=Pred copyvars=(Heat Soak);
run;
The "Model Information" table shows that the data are modeled as binomially distributed with a logit link function (Output 18.2.1). This is the default link function in the LOGSELECT procedure for binary and binomial data. The procedure estimates the parameters of the model by a Newton-Raphson algorithm.
Output 18.2.1: Model Information and Number of Observations
| Model Information | |
|---|---|
| Data Source | INGOTS |
| Response Variable (Events) | r |
| Response Variable (Trials) | n |
| Distribution | Binomial |
| Link Function | Logit |
| Optimization Technique | Newton-Raphson with Ridging |
| Number of Observations Read | 19 |
|---|---|
| Number of Observations Used | 19 |
| Response Profile | ||
|---|---|---|
| Ordered Value | Binary Outcome | Total Frequency |
| 1 | Event | 12 |
| 2 | Nonevent | 375 |
The second table in Output 18.2.1 shows that all 19 observations in the input data table were used in the analysis and the "Response Profile" table shows that the total number of events and nonevents equals 12 and 387, respectively.
Output 18.2.2 displays the convergence status table for this run. The LOGSELECT procedure satisfies the GCONV= convergence criterion.
Output 18.2.2: Convergence Status
| Convergence criterion (GCONV=1E-8) satisfied. |
Output 18.2.3 displays the "Dimensions" table for the model. The design matrix of the model (the matrix) has four columns, which correspond to the intercept, the
Heat effect, the Soak effect, and the interaction of the Heat and Soak effects. The model is nonsingular because the rank of the crossproducts matrix equals the number of columns in . All parameters are estimable, and all participate in the optimization.
Output 18.2.3: Dimensions in Binomial Logistic Regression
| Dimensions | |
|---|---|
| Columns in Design | 4 |
| Number of Effects | 4 |
| Max Effect Columns | 1 |
| Rank of Design | 4 |
| Parameters in Optimization | 4 |
Output 18.2.4 displays the "Fit Statistics" table for this run. Evaluated at the converged estimates, –2 times the value of the log-likelihood function equals 27.9569. Further fit statistics are also displayed, all of them in "smaller is better" form. The AIC, AICC, and SBC criteria are used to compare non-nested models and to penalize the model fit for the number of observations and parameters. You can use the –2 log-likelihood value to compare nested models by way of a likelihood ratio test.
Output 18.2.4: Fit Statistics
| Fit Statistics | |
|---|---|
| -2 Log Likelihood | 27.95689 |
| AIC (smaller is better) | 35.95689 |
| AICC (smaller is better) | 38.81403 |
| SBC (smaller is better) | 39.73464 |
Output 18.2.5 shows the test of the global hypothesis that the effects jointly do not affect the probability of ingot readiness. You can obtain the chi-square test statistic by comparing the –2 log-likelihood value of the model with covariates to the value in the intercept-only model. The test is significant, with a p-value of 0.0082. One or more of the effects in the model have a significant impact on the probability of ingot readiness.
Output 18.2.5: Null Test
| Testing Global Null Hypothesis: BETA=0 | |||
|---|---|---|---|
| Test | DF | Chi-Square | Pr > ChiSq |
| Likelihood Ratio | 3 | 11.7663 | 0.0082 |
The "Parameter Estimates" table in Output 18.2.6 displays the estimates and standard errors of the model effects.
Output 18.2.6: Parameter Estimates
| Parameter Estimates | |||||
|---|---|---|---|---|---|
| Parameter | DF | Estimate | Standard Error | Chi-Square | Pr > ChiSq |
| Intercept | 1 | -5.990191 | 1.666622 | 12.9183 | 0.0003 |
| Heat | 1 | 0.096339 | 0.047067 | 4.1896 | 0.0407 |
| Soak | 1 | 0.299574 | 0.755068 | 0.1574 | 0.6916 |
| Heat * Soak | 1 | -0.008840 | 0.025319 | 0.1219 | 0.7270 |
Output 18.2.7 displays the "Association Statistics" table, which is produced when you specify the ASSOCIATION option in the PROC LOGSELECT statement. The table contains four measures of association for assessing the predictive ability of a model. For more information, see the section Association Statistics.
Output 18.2.7: Association of Observed Responses and Predicted Probabilities
| Association of Predicted Probabilities and Observed Responses | |
|---|---|
| Concordance Index (AUC) | 0.7706 |
| Somers' D | 0.5411 |
| Gamma | 0.5858 |
| Tau-a | 0.0326 |
| Pairs | 4500 |
| Percent Concordant | 73.2444 |
| Percent Discordant | 19.1333 |
| Percent Tied | 7.6222 |
You can construct the prediction equation of the model from the "Parameter Estimates" table. For example, an observation with Heat equal to 14 and Soak equal to 1.7 has the linear predictor
The probability that an ingot with these characteristics is not ready for rolling is
PROC LOGSELECT computes these linear predictors and probabilities and stores them in the mylib.Out data table. The following PROC PRINT statement produces Output 18.2.8, which shows the probability that an ingot with Heat equal to 14 and Soak equal to 1.7 is not ready for rolling:
proc print data=mylib.Out;
where Heat=14 & Soak=1.7;
run;
Output 18.2.8: Predicted Probability for Heat=14 and Soak=1.7
| Obs | Pred | _XBETA_ | Heat | Soak |
|---|---|---|---|---|
| 1 | 0.012836 | -4.34256 | 14 | 1.7 |
The CTABLE option computes statistics for binary response models (on the basis of classifying observations according to whether their predicted probabilities exceed certain values) and stores the results in the mylib.Roc data table. For more information, see the section Classification Table and ROC Curves. You can use this data table to display the ROC curve by using the SGPLOT procedure as follows:
ods graphics on;
proc sgplot data=mylib.Roc aspect=1 noautolegend;
title 'ROC Curve';
xaxis values=(0 to 1 by 0.25) grid offsetmin=.05 offsetmax=.05;
yaxis values=(0 to 1 by 0.25) grid offsetmin=.05 offsetmax=.05;
lineparm x=0 y=0 slope=1 / lineattrs=(color=ligr);
series x=FPF y=TPF;
inset 'Area under the curve=0.7706' / position=bottomright;
run;
Output 18.2.9: Receiver Operating Characteristics Curve

Multinomial-Trial Syntax for Grouped Binary Data
You can perform the same analysis by using the multinomial-trial syntax. First you need to compute the number of ingots that are ready for rolling, a:
data mylib.Ingots2;
set Ingots;
a = n - r;
run;
Then you specify the event variable, followed by the nonevent variable, in the MODEL statement:
proc logselect data=mylib.Ingots2 association ctable(out=mylib.Roc nocounts tpf fpf);
model r a = Heat Soak Heat*Soak;
output out=mylib.Out xbeta predicted=Pred copyvars=(Heat Soak);
run;
The only difference from the preceding results is that in this case the "Model Information" table shown in Output 18.2.10 displays the event and nonevent variables.
Output 18.2.10: Model Information
| Model Information | |
|---|---|
| Data Source | INGOTS2 |
| Response Variable (Events) | r |
| Response Variable (Nonevents) | a |
| Distribution | Binomial |
| Link Function | Logit |
| Optimization Technique | Newton-Raphson with Ridging |
Single-Trial Syntax for Binary Data
Binomial data are a form of grouped binary data in which "successes" in the underlying Bernoulli trials are totaled. You can thus unwind data for which you use the events/trials syntax and fit these data by using techniques for binary data.
The following DATA step expands the Ingots data table, which contains 12 events in 387 trials, into a data table that has 387 observations:
data mylib.Ingots_binary;
set Ingots;
do i=1 to n;
if i <= r then y=1; else y = 0;
output;
end;
run;
The following statements fit the model that contains the Heat effect, the Soak effect, and their interaction to the data table. The event=’1’ response-variable option in the MODEL statement ensures that the LOGSELECT procedure models the probability that the variable y takes the value 1.
proc logselect data=mylib.Ingots_binary;
model y(event='1') = Heat Soak Heat*Soak;
run;
Output 18.2.11 displays the "Model Information," "Number of Observations," and "Response Profile" tables. The data are now modeled as binary (Bernoulli distributed) with a logit link function. The "Response Profile" table shows that the binary response breaks down into 375 observations where y=0 and 12 observations where y=1.
Output 18.2.11: Model Information in Binary Model
| Model Information | |
|---|---|
| Data Source | INGOTS_BINARY |
| Response Variable | y |
| Distribution | Binary |
| Link Function | Logit |
| Optimization Technique | Newton-Raphson with Ridging |
| Number of Observations Read | 387 |
|---|---|
| Number of Observations Used | 387 |
| Response Profile | ||
|---|---|---|
| Ordered Value | y | Total Frequency |
| 1 | 0 | 375 |
| 2 | 1 | 12 |
| Probability modeled is y = 1. |
Output 18.2.12 displays the result of the test of the global null hypothesis and the parameter estimates. These results match those in Output 18.2.5 and Output 18.2.6.
Output 18.2.12: Null Test and Parameter Estimates
| Testing Global Null Hypothesis: BETA=0 | |||
|---|---|---|---|
| Test | DF | Chi-Square | Pr > ChiSq |
| Likelihood Ratio | 3 | 11.7663 | 0.0082 |
| Parameter Estimates | |||||
|---|---|---|---|---|---|
| Parameter | DF | Estimate | Standard Error | Chi-Square | Pr > ChiSq |
| Intercept | 1 | -5.990191 | 1.666622 | 12.9183 | 0.0003 |
| Heat | 1 | 0.096339 | 0.047067 | 4.1896 | 0.0407 |
| Soak | 1 | 0.299574 | 0.755068 | 0.1574 | 0.6916 |
| Heat * Soak | 1 | -0.008840 | 0.025319 | 0.1219 | 0.7270 |