Logistic Regression: Till now we have tried to understand theory behind logistic regression. In this section we would cover implementation of Logistic Regression in R i.e. commands and packages required for Logistic regression.
We will try to predict probability of default/Non-Default using Logistic Regression. In the following sections we would look into the basics commands and packages of R.
Step 1. Set up a working library. Setting up a working directory makes life very easy. We can refer to any file saved in working library without mentioning location again and again
Step 2: Import the data set into R-Studio using following commands.
Step 3. : Install the package required for Logistic regression. We would install “caTools” for Logistic regression.
Step4: Our data set has 5 variables but for analysis we would use just last three variables. So we would select last tree variable using following commands.
Step 5. Build Logistic Regression Model using following commands
Step 6. Predicting the regression output
Step 7. Creating a confusion matrix to evaluate the result