Logistic Regression Practical part- 5

SAS Analytics Logistic Regression- Case Study & Practical
13 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$69.99
List Price:  $99.99
You save:  $30
€65.51
List Price:  €93.59
You save:  €28.07
£56.31
List Price:  £80.45
You save:  £24.13
CA$95.76
List Price:  CA$136.81
You save:  CA$41.04
A$107.69
List Price:  A$153.85
You save:  A$46.15
S$95.27
List Price:  S$136.10
You save:  S$40.83
HK$548.21
List Price:  HK$783.19
You save:  HK$234.98
CHF 63.99
List Price:  CHF 91.41
You save:  CHF 27.42
NOK kr766.70
List Price:  NOK kr1,095.33
You save:  NOK kr328.63
DKK kr488.53
List Price:  DKK kr697.93
You save:  DKK kr209.40
NZ$117.93
List Price:  NZ$168.49
You save:  NZ$50.55
د.إ257.06
List Price:  د.إ367.25
You save:  د.إ110.18
৳7,672.34
List Price:  ৳10,960.96
You save:  ৳3,288.61
₹5,831.54
List Price:  ₹8,331.14
You save:  ₹2,499.59
RM334.37
List Price:  RM477.70
You save:  RM143.32
₦88,222.39
List Price:  ₦126,037.39
You save:  ₦37,815
₨19,408.82
List Price:  ₨27,728.08
You save:  ₨8,319.25
฿2,591.14
List Price:  ฿3,701.79
You save:  ฿1,110.65
₺2,276.07
List Price:  ₺3,251.67
You save:  ₺975.60
B$359.20
List Price:  B$513.17
You save:  B$153.96
R1,339.40
List Price:  R1,913.51
You save:  R574.11
Лв128.12
List Price:  Лв183.04
You save:  Лв54.91
₩96,245.98
List Price:  ₩137,500.16
You save:  ₩41,254.17
₪263.24
List Price:  ₪376.08
You save:  ₪112.83
₱4,030.89
List Price:  ₱5,758.67
You save:  ₱1,727.77
¥10,844
List Price:  ¥15,492.10
You save:  ¥4,648.09
MX$1,188.01
List Price:  MX$1,697.24
You save:  MX$509.22
QR253.94
List Price:  QR362.79
You save:  QR108.84
P970.94
List Price:  P1,387.12
You save:  P416.17
KSh9,413.65
List Price:  KSh13,448.65
You save:  KSh4,035
E£3,350.77
List Price:  E£4,787.02
You save:  E£1,436.25
ብር3,964.81
List Price:  ብር5,664.26
You save:  ብር1,699.44
Kz58,437.56
List Price:  Kz83,485.81
You save:  Kz25,048.25
CLP$66,749.46
List Price:  CLP$95,360.46
You save:  CLP$28,611
CN¥507.15
List Price:  CN¥724.53
You save:  CN¥217.38
RD$4,131.55
List Price:  RD$5,902.47
You save:  RD$1,770.91
DA9,407.33
List Price:  DA13,439.62
You save:  DA4,032.28
FJ$160.49
List Price:  FJ$229.29
You save:  FJ$68.79
Q543.50
List Price:  Q776.47
You save:  Q232.96
GY$14,625.47
List Price:  GY$20,894.43
You save:  GY$6,268.95
ISK kr9,845.49
List Price:  ISK kr14,065.59
You save:  ISK kr4,220.10
DH706.45
List Price:  DH1,009.26
You save:  DH302.80
L1,245.82
List Price:  L1,779.82
You save:  L534
ден4,030.78
List Price:  ден5,758.50
You save:  ден1,727.72
MOP$564.26
List Price:  MOP$806.12
You save:  MOP$241.86
N$1,339.20
List Price:  N$1,913.23
You save:  N$574.02
C$2,563.14
List Price:  C$3,661.78
You save:  C$1,098.64
रु9,324.38
List Price:  रु13,321.12
You save:  रु3,996.73
S/257.63
List Price:  S/368.06
You save:  S/110.42
K264.67
List Price:  K378.12
You save:  K113.45
SAR262.51
List Price:  SAR375.03
You save:  SAR112.52
ZK1,801.79
List Price:  ZK2,574.10
You save:  ZK772.30
L325.94
List Price:  L465.65
You save:  L139.71
Kč1,653.47
List Price:  Kč2,362.20
You save:  Kč708.73
Ft25,766.18
List Price:  Ft36,810.41
You save:  Ft11,044.22
SEK kr760.51
List Price:  SEK kr1,086.49
You save:  SEK kr325.98
ARS$61,084.05
List Price:  ARS$87,266.68
You save:  ARS$26,182.62
Bs481.20
List Price:  Bs687.45
You save:  Bs206.25
COP$273,176.37
List Price:  COP$390,268.69
You save:  COP$117,092.31
₡35,080.64
List Price:  ₡50,117.34
You save:  ₡15,036.70
L1,718.72
List Price:  L2,455.43
You save:  L736.70
₲516,687.24
List Price:  ₲738,156.27
You save:  ₲221,469.03
$U2,685.15
List Price:  $U3,836.09
You save:  $U1,150.94
zł283.11
List Price:  zł404.46
You save:  zł121.35
Already have an account? Log In

Transcript

We were doing the practical session of logistic regression in SAS software we were using a data set related to credit risk analytics where we were building a model for Y equals to one that is a dependent variable is calculating probability for Y equals to one or probability of an event which denotes that is in our model collaborative i equals to event denotes that the customer will not be a loan default and y equals to zero denotes that is the probability of a non event customer will be a loan default. So probability Bibles to this customer will not be a loan department therefore loan can be given to the customer and probability by equals to zero his customer will be a loan default that is loan cannot be given to the customer. So we have done stepwise selection on our model to select the significant independent variables that can be used for the further action Since we have selected we have obtained 14 significant independent variables out of the 30 independent variables that are there in the data set.

The significant independent variables that are selected are check account duration history, save account, new card education character meal, single other instrument installment amount used car for and rent. So, these significant variables that are included in the model they are included with the help of residual chi square test that is which of the independent variables should be included in our model is decided by a suitable chi square test where they each notice now hypothesis the model does not require any more variables and each one is the model requires more variables. We have also done hashman lecture Goodness of Fit Test where we have got the p value greater than 0.05 that is we have accepted the null hypothesis for our model to the null hypothesis for our for hospital MC Goodness of Fit Test is h notice the model is a good treat and each one is models not a good fit so far our model the model is a good fit.

We have also obtained the table for odds ratio estimates the table for analysis of maximum likelihood estimates that is maximum likelihood estimation technique is used to estimate the parameters. We have also been the table for percentage of concordance discordance and tight pairs, the higher the percentage of concordance better is the model because less is a miss classification for the model we have also generated the classification table for every level of probability from zero to one with a gap of 0.01. And we have got different measures of classification table at every level of probability from zero to one with a gap of 0.01. That is, we got the correctly classified events the correctly classified non events the incorrectly classified events the incorrectly classified non events, we have got the total percentage correctly classified the sensitivity and specificity the false positive for the false negative for a classification table for every level of priority from zero to one with a gap of 0.01.

We have created a data set called result where we have predicted the probability for Y equals to one that is for each of the customer we have predicted the probability for Y equals to event that is probability of giving the loan to the customer. So this fake depravity is displayed in a data set called result. So this is my result data set where I've got the estimated probability for each of each and every customer poll I applied for the loan. This is estimated probability for an event that is probability of giving the loan to each of the customer, then we have set up a cutoff probability level in order to convert this estimated probability to a binary variable taking values zero or one saying that if the estimated probability or if the created probability is greater than the cutoff probability level, which we have set as point five, then the value of status is equal to one orders this value of status is equal to zero.

So the status variable is created in another data set called pred result, which is a duplicate data set of results. So the status variable is created beside the variable of estimated probabilities, so for every value of probability there is a value of status, saying that the estimated probability is greater than point five which is the cutoff priority level. The status value is one otherwise it is zero. When we say that Estimated probability is greater than point five that means that the estimated probability for giving room to the particular customer is greater than point five, then we say the status is one that means that the customer who has the estimated probability greater than point five in there is more chance that loan will be given to that customer. Therefore, the status is one because one is an event until a customer has got estimated probability less than point five that is less than the cutoff level that we have decided over here as point A we can change the current average level according to our choice if the estimated revenue is less than point five then we say the status is zero that is there is less chance that the customer will let me get a low.

Here one denotes an event and zero denotes a non event. Now, we are going to measure the accuracy of a model that we have built. In order to measure the accuracy of the model we will be doing up we will be generating a confusion matrix for our model. So in this video, we will be generating the confusion matrix for our model. To measure the accuracy of the model and also to measure the different measures of confusion matrix, so let's start we are going to use the procedure called proc freak. It's a frequency procedure, roughly beta equals to Fred underscore result.

This is the duplicate data set, which was already created inside work containing the relative gravity and the status variable. That is a binary variable taking value 01. This confusion matrix will be bound between the observed values and the predicted values. So in my pred underscore result, my observed values is the response variable and my predicted values is the status variable. So I'm going to execute the frequency procedure on the data set read underscore result between response and the status variable measure the accuracy of the model ROC freak data equal to print underscore reserved. Then we only use the keyword table to specify Variables responses may observe to be able containing observed value we are doing cross frequency table therefore, we are using start showing cross frequency status is the predicted variable both are binary variables response and status that is taking values 01 we do not want row percent in column percent which comes by default in frequency here we have written or we have used the keyword noro local then here running you're using the run statement.

So, before I execute the code Let me explain the code we have used. The frequency procedure on our data set read underscore result which is containing the observed variable response and status variable that is we have set up a cutoff probability level and converted estimated probability to a status variable. So, If the estimated revenue is greater than point five then one that is in status equals to one otherwise status equals to zero and this response here is one because we are building a model for Y equals to one to view and form the confusion matrix between response and status. So, we have specified that in the table statement response dot status that is across frequency table, we have written neuro local because we are only concerned with the frequency, we do not mean the row percentage column percent. So we have used the key words no row and no call and then run.

So let's run this code. So see this is my confusion matrix. Here response 01 is the observed value is zero and observed value as one this is predicted value status is my predicted variable where I've converted the estimator private into status that is mean predicted variable which is also taking values 01 Also by new variable. So, this 155 145 7628 these are frequency, the first value for every sale is frequency and the next value is frequency present. The 00 155 and 55 means there are cases where the observed value is zero and the predicted value is zero. So, there are 55 such cases Okay.

Next, there are 145 cases where observed value is zero and the Patriot values one there are 72 such cases where the observed value is one and the predicted value is zero and there are 620 such cases where the observed value is one and the predicted value is one. So, my total number of observations is thousand. Now, we will be using this confusion matrix to measure the accuracy of the model and to calculate the different measures different other measures or confusion matrix so that we have to do it manually. So, I have taken this confusion matrix in an Excel file. This is the same confusion matrix which I shown you in the recipe word. So, my response variable is observed variable my status variable is the predicted variable the different measures of confusion matrix that we're going to measure is first is accuracy of the model that is percentage correctly classified that is equal to correctly classified events plus correctly classify eight known events by total number of observations.

So correctly classified into hundred if you do you can convert into percentage that is correctly classified events but plus political estimate non events by total number of observations in 200. Here correctly plus vt lenses one one lead 628 cases where it is observed also as one as well as expected also as one 620 plus 155 in 206 28 plus 150, a Beethoven number observation 6200. So, he Haven't converted into percentage I've just done the total that is one plus 620 divided by thousand that is around zero point 73 which is around 17.3%. So, the accuracy is good. Next is correctly classified evens that is 628 This is also called true positive, there are 628 cases correctly classified non events there is 00 there are 150 cases it is also called True negative. Next is incorrectly classified events.

This is 01 this case that is observed a zero and predicted as one is also called false positive indirect interest rate evens and incorrectly classified nonhumans is one zero that is 72 cases there in the literacy rate non humans are also called false negative. Next is sensitivity sensitivity is also called true positive rate. That is it is the ratio of correctly classified events by total observed events. So, correctly classified even says 628 by total observed events, total observed events this 628 by 700 This is my total observed events this is total observed events and this is the correct classmate events sensitivities ratio apparently was it was the total opposite events that is 28 by seven 700. specificity is correctly classified known events by total observed known events. So, correctly classified non events is 155 155 by total observed non events is 300 that is 51% that is 0.51 false positive rate is the ratio of incorrectly classified events by total predicted events.

So, incorrectly classified events is 145 by total predicted events. So, my peg to events is this 3773 cannot be 33 and false negative rate is incorrect classified non events by total predicted known events. So, in Korea classified known events are 145. So, encrypted password non events a 72 that is 72 by total credit non you insist to 27 that is 72 by 227 that is around 31% that is 0.3. So, these are the different measures of confusion matrix that we have to calculate once we get the confusion matrix in in SAS we will be getting to the confusion matrix and then we in order to calculate the accuracy of the model we have to calculate these measures since the accuracy of the model 73% which is quite good. Now, we will be learning this we will be learning to hear in this video.

So, before I move to the next video, let me recap the concepts that we have done in this in this videos we have done step by selection to select the significant variables we have created, generated classification table for every level of private from zero to one with a cap of 0.01. We have predicted probability for Y equals to one we have set up the cutoff probability level converted the predicted probability to a binary variable named status and we have formed the confusion matrix between the observed variable and the predicted variable we call the odds ratio estimates table we got the analysis of maximum likelihood estimates table we have used residual chi square test for selecting significant variables. We also did Hashmi lm shortness of test which has concluded that our model is a good fit. Now in an upcoming video we will be doing time series analysis the practical session or regression is over in our upcoming video.

We'll be starting this time series analysis Goodbye. Thank you see you for the next video.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.