Sunteți pe pagina 1din 8

3/26/2017 Print Preview

Appendix 9.2Logistic Regression Classification with XLMiner

We demonstrate how XLMiner facilitates the construction of a
logistic regression model by using the Optiva Credit Union
problem of classifying customer observations as either a loan
default (Class 1) or no default (Class 0). The following steps and
Figure 9.16 demonstrate this process.

Step 1

In the Data_Partition worksheet, select any cell (such as cell B26) in the range
of data listed below Selected Variables

Step 2

Click the XLMiner Platform tab on the Ribbon

Step 3

5/38
3/26/2017 Print Preview

Click Classify from the Data Mining group

Step 4

Click Logistic Regression

Step 5

In the Logistic Regression – Step 1 of 3 dialog box:

In the Data Source area, confirm that the Worksheet: and Workbook:
entries correspond to the appropriate data (see Figure 9.16)

In the Variables In Input Data box of the Variables area, select Average
Balance, Age, Entrepreneur, Unemployed, Married, Divorced, High
School, and College and click the > button to the left of the Selected
Variables box

Select Loan Default in the Variables in input data box of the Variables
area and click the > button to the left of the Output variable: box

In the Classes in the Output Variable area, enter 2 in the # Classes box,
select 1 from dropdown box next to Specify “Success” class (for Lift
Chart):, and enter 0.5 in the Specify initial cutoff probability for success:
box

Click Next

Step 6

In the Logistic Regression – Step 2 of 3 dialog box:

Click Variable Selection and when the Variable Selection dialog box
appears:

Select the checkbox for Perform variable selection

Set the Maximum size of best subset: box to 8

In the Selection Procedure area, select Best Subsets

Above the Selection Procedure area, set the Number of best subsets:
box to 2

Click OK

Click Next

Step 7

In the Logistic Regression – Step 3 of 3 dialog box:

6/38
3/26/2017 Print Preview

In the Score Test Data area, select the checkboxes for Detailed Report,
Summary Report, and Lift Charts. Leave all other checkboxes unchanged.

Click Finish

Figure 9.16

XLMiner Steps for Logistic Regression

XLMiner provides several options for selecting variables to include in alternative logistic
regression models. Best subsets is the most comprehensive method; it considers every
possible combination of the variables but is typically appropriate only when dealing with fewer
than 10 explanatory variables. When dealing with many variables, best subsets may be too
computationally expensive, as it will require constructing hundreds of alternative models. In
cases with a moderate number of variables, 10 to 20, backward selection is effective at
eliminating the unhelpful variables. Backward elimination begins with all possible variables and
sequentially removes the least useful variable (with respect to statistical significance). When
dealing with more than 20 variables, forward selection is often appropriate, as it identifies the
most helpful variables.

This procedure builds several logistic regression models for consideration. In the LR_Output
worksheet displayed in Figure 9.17, the area titled Regression Model lists the statistical
information on the logistic regression model using all of the selected explanatory variables.
This information corresponds to the logistic regression fit of:

Figure 9.17

XLMiner Logistic Regression Output in LR_Output Worksheet

7/38
3/26/2017 Print Preview

While these coefficients do not have a direct intuitive interpretation, the sign of a coefficient in
the logistic regression is meaningful. For example, the negative coefficient of the Average
Balance variable means that as a customer’s average balance increases, the probability of
default decreases. Similarly, the positive coefficient of the binary Divorced variable means that
a divorced customer is more likely to default than a nondivorced customer. The p value
information reflects the statistical significance of each coefficient. While a logistic regression
model used for predictive purposes should ultimately be judged by its classification error on
the validation and test sets, the p value information can provide some guidance about which
models to evaluate further (i.e., large p values suggest that the corresponding variable may be
less helpful in accurately classifying observations).

In addition to fitting the logistic regression model with all the selected explanatory variables,
XLMiner also provides summary measures on models with combinations of the variables. The
Variable Selection area in Figure 9.17 lists
. To sort
through these models, typically there is a preference for models with fewer coefficients (cells
D92 through D107) and with a Mallow’s   statistic value (cells F92 through F107) that is
small and near the number of coefficients in the model. RSS stands for residual sum of
squares and computes the sum of squared deviations between the predicted probability of
success and the actual value (1 or 0). Models with a smaller RSS are preferred, but as more
variables are added, the additional decrease in RSS is not as large.

After identifying one or more models for further analysis, we can then evaluate each of them
with respect to how well they classify the observations in the validation set. Evaluating the
models listed in Figure 9.17, we see that there appear to be several similar models. For
example, the model in row 94 with 2 coefficients (the constant and the variable
AverageBalance) may be a good candidate for closer examination.

Clicking on Choose Subset in cell C94 of the LR_Output worksheet activates the XLMiner
procedure to refit the logistic regression model with explanatory variable AverageBalance. The

8/38
3/26/2017 Print Preview

following steps and Figure 9.18 explain how to construct this logistic regression model and use
it to predict the loan default probability of 30 new customers.

Step 1

Click on Choose Subset in cell C94 of LR_Output worksheet

Step 2

In the Logistic Regression – Step 1 of 3 dialog box, click Next >

Step 3

In the Logistic Regression – Step 2 of 3 dialog box, click Next

Step 4

In the Logistic Regression – Step 3 of 3 dialog box:

In the Score Test Data area, select the checkboxes for Detailed Report,
Summary Report, Lift Charts; leave all other checkboxes unchanged

In the Score New Data area, select In worksheet

When the Match Variables in the New Range dialog box appears:

In the Data Source area, select the worksheet name New Data To Predict
from the pulldown menu next to Worksheet; enter $A$1:$J$31 in the Data
Range: box

In the Variables area, select the checkbox for First Row Contains Headers
and click Match By Name

Click OK

Click Finish

Figure 9.18

XLMiner Steps for Refitting the Logistic Regression Model and Predicting New Data

9/38
3/26/2017 Print Preview

The preceding steps produce a worksheet titled LR_Output1 that lists the classification
confusion matrices for the logistic regression model with AverageBalance as the explanatory
variable. Figure 9.19 displays the classification confusion matrices for the validation and test
sets. Using the cutoff value of 0.5, we observe that the logistic regression model has a Class 1
error rate of 18.38% and a Class 0 error rate of 56.64% on the validation data; on the test set,
the Class 1 error rate is 19.11% and the Class 0 error rate is 56.88%. Optiva can expect a
Class 1 error rate of approximately 19% and a Class 0 error rate of approximately of 57%
when using this model on new customer observations.

10/38
3/26/2017 Print Preview

Figure 9.19

Classification Error for Logistic Regression Model in LR_Output Worksheet

The preceding steps also produce a worksheet titled LR_NewScore1 that lists the logistic
regression model’s classification of the 30 new customer observations in the
NewDataToPredict worksheet. Figure 9.20 displays the estimated probability of Class 1
membership (loan default) and the classification using the cutoff value of 0.5. For example, the
first observation has an estimated probability of 0.4135 for defaulting on a loan. Based on the
cutoff value of 0.5, we predict that this observation is Class 0 or a nondefaulter on a loan.

Figure 9.20

Classification of 30 New Customer Observations (LR_Newscore Worksheet)

11/38
3/26/2017 Print Preview

Notes + Comments

1. Other XLMiner alternatives for selecting variables in a regression model include
stepwise selection and sequential replacement. Stepwise selection starts with
no variables, but at each step considers both the insertion and removal of a
variable based on the F­statistics FIN and FOUT, respectively. To prevent
cycling,  , with typical values of 6.5 and 3, respectively. Sequential
replacement considers models with a fixed number of values by inserting a new
variable whenever one is removed.

2. XLMiner provides functionality for multiple linear regression that greatly
enhances the basic regression capabilities provided by Excel’s Data Analysis
Toolpak. The Multiple Linear Regression procedure is listed under Prediction
in the Data Mining group on the XLMiner Ribbon. This functionality is described
in the appendix to Chapter 7.

12/38

S-ar putea să vă placă și