Package used

library(readxl)
Telco <- read_excel("C:/Users/DELL/Desktop/DA/Data.xlsx", 
    sheet = "Main")
View(Telco)
library(ggplot2)
library(ggpie)
library(dplyr)
library(tidyverse)
library(corrplot)
library(lmtest)
library(patchwork)
library(caTools)
library(sjPlot)
library(car)
library(caret)
library(stargazer)
library(rpart)
library(rpart.plot)

Process

Telecom customer churn is a dataset that contains information about customers of a telecommunications company and whether they have churned (i.e., stopped using the company’s services) or stayed. Main services include: Phone service and Internet service

  1. Business Understanding
  2. Data Understanding
  3. Dealing with data: Split dataset, remove duplicate values and solve missing values
  4. Modelling: Logistic regression and decision tree
  5. Visualize data: Dashboard

Introduction

Data dictionary
Variables Data type
Gender Qualitative data
Age group Qualitative data
Married Qualitative data
Number of Dependents Quantitative data
Number of Referrals Quantitative data
Tenure in Months Quantitative data
Offer Qualitative data
Phone Service Qualitative data
Avg Monthly Long Distance Charges Quantitative data
Multiple Lines Quantitative data
Internet Service Qualitative data
Internet Type Qualitative data
Avg Monthly GB Download Quantitative data
Online Security Qualitative data
Online Backup Qualitative data
Device Protection Plan Qualitative data
Premium Tech Support Qualitative data
Streaming TV Qualitative data
Streaming Movies Qualitative data
Streaming Music Qualitative data
Unlimited Data Qualitative data
Contract Qualitative data
Paperless Billing Qualitative data
Payment Method Qualitative data
Monthly Charge Quantitative data
Total Charges Quantitative data
Total Refunds Quantitative data
Total Extra Data Charges Quantitative data
Total Long Distance Charges Quantitative data
Total Revenue Quantitative data
Customer Status Qualitative data

Overview

  • Eliminating duplicate values
sum(duplicated(Telco))
## [1] 0

Telco dataset with no duplicate values refers to a collection of data where each entry is unique, and there are no repetitions or duplicates within the dataset.

  • Dealing with missing values
sapply(Telco, function(x) sum(is.na(x)))
##                            Gender                            Cus ID 
##                                 0                                 0 
##                               Age                         Age Group 
##                                 0                                 0 
##                           Married              Number of Dependents 
##                                 0                                 0 
##               Number of Referrals                  Tenure in Months 
##                                 0                                 0 
##                             Offer                     Phone Service 
##                                 0                                 0 
## Avg Monthly Long Distance Charges                    Multiple Lines 
##                               682                               682 
##                  Internet Service                     Internet Type 
##                                 0                              1526 
##           Avg Monthly GB Download                   Online Security 
##                              1526                              1526 
##                     Online Backup            Device Protection Plan 
##                              1526                              1526 
##              Premium Tech Support                      Streaming TV 
##                              1526                              1526 
##                  Streaming Movies                   Streaming Music 
##                              1526                              1526 
##                    Unlimited Data                          Contract 
##                              1526                                 0 
##                 Paperless Billing                    Payment Method 
##                                 0                                 0 
##                    Monthly Charge                     Total Charges 
##                                 0                                 0 
##                     Total Refunds          Total Extra Data Charges 
##                                 0                                 0 
##       Total Long Distance Charges                     Total Revenue 
##                                 0                                 0 
##                   Customer Status 
##                                 0

In the dataset, there are 682 responses where respondents indicated “No” for Phone service and 1526 responses where they indicated “No” for Internet service, resulting in missing values for both dimensions. This substantial number of missing values underscores a significant portion of the population that does not use phone or Internet services.

Thus, author decides to use only observations that do not have missing values of Phone service in Telco dataset

  • Dataset
telco_use_phone = Telco[complete.cases(Telco$`Multiple Lines`), -c(13:23)]

#Churn
telco_use_phone$Churn = case_when( 
  telco_use_phone$`Customer Status`== "Churned" ~ "Yes", 
  TRUE ~ "No")

Descriptive statistics

Univariate analysis

  • Summary statistics
summary(telco_use_phone)
##     Gender             Cus ID               Age         Age Group        
##  Length:6361        Length:6361        Min.   :19.00   Length:6361       
##  Class :character   Class :character   1st Qu.:32.00   Class :character  
##  Mode  :character   Mode  :character   Median :46.00   Mode  :character  
##                                        Mean   :46.56                     
##                                        3rd Qu.:60.00                     
##                                        Max.   :80.00                     
##    Married          Number of Dependents Number of Referrals Tenure in Months
##  Length:6361        Min.   :0.0000       Min.   : 0.000      Min.   : 1.00   
##  Class :character   1st Qu.:0.0000       1st Qu.: 0.000      1st Qu.: 9.00   
##  Mode  :character   Median :0.0000       Median : 0.000      Median :29.00   
##                     Mean   :0.4655       Mean   : 1.962      Mean   :32.45   
##                     3rd Qu.:0.0000       3rd Qu.: 3.000      3rd Qu.:56.00   
##                     Max.   :8.0000       Max.   :11.000      Max.   :72.00   
##     Offer           Phone Service      Avg Monthly Long Distance Charges
##  Length:6361        Length:6361        Min.   : 1.01                    
##  Class :character   Class :character   1st Qu.:13.05                    
##  Mode  :character   Mode  :character   Median :25.69                    
##                                        Mean   :25.42                    
##                                        3rd Qu.:37.68                    
##                                        Max.   :49.99                    
##  Multiple Lines       Contract         Paperless Billing  Payment Method    
##  Length:6361        Length:6361        Length:6361        Length:6361       
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##                                                                             
##                                                                             
##                                                                             
##  Monthly Charge   Total Charges    Total Refunds    Total Extra Data Charges
##  Min.   :-10.00   Min.   :  18.8   Min.   : 0.000   Min.   :  0.000         
##  1st Qu.: 26.10   1st Qu.: 414.1   1st Qu.: 0.000   1st Qu.:  0.000         
##  Median : 74.40   Median :1417.9   Median : 0.000   Median :  0.000         
##  Mean   : 65.99   Mean   :2364.3   Mean   : 1.979   Mean   :  6.609         
##  3rd Qu.: 91.00   3rd Qu.:4024.2   3rd Qu.: 0.000   3rd Qu.:  0.000         
##  Max.   :118.75   Max.   :8684.8   Max.   :49.790   Max.   :150.000         
##  Total Long Distance Charges Total Revenue      Customer Status   
##  Min.   :   1.13             Min.   :   21.36   Length:6361       
##  1st Qu.: 133.40             1st Qu.:  671.88   Class :character  
##  Median : 509.21             Median : 2284.19   Mode  :character  
##  Mean   : 829.41             Mean   : 3198.35                     
##  3rd Qu.:1320.57             3rd Qu.: 5248.80                     
##  Max.   :3564.72             Max.   :11979.34                     
##     Churn          
##  Length:6361       
##  Class :character  
##  Mode  :character  
##                    
##                    
## 
sapply(telco_use_phone, function(x) sd(x))
##                            Gender                            Cus ID 
##                                NA                                NA 
##                               Age                         Age Group 
##                        16.7364133                                NA 
##                           Married              Number of Dependents 
##                                NA                         0.9541926 
##               Number of Referrals                  Tenure in Months 
##                         3.0033168                        24.5793233 
##                             Offer                     Phone Service 
##                                NA                                NA 
## Avg Monthly Long Distance Charges                    Multiple Lines 
##                        14.2003736                                NA 
##                          Contract                 Paperless Billing 
##                                NA                                NA 
##                    Payment Method                    Monthly Charge 
##                                NA                        31.6452802 
##                     Total Charges                     Total Refunds 
##                      2328.3895348                         7.9318419 
##          Total Extra Data Charges       Total Long Distance Charges 
##                        24.7431988                       852.6875468 
##                     Total Revenue                   Customer Status 
##                      2935.8093142                                NA 
##                             Churn 
##                                NA
telco_use_phone = subset(telco_use_phone,`Monthly Charge` > 1)

To ensure accuracy in analyses, author removes rows with negative values in the Monthly Charge because negative values in this variable may indicate errors in billing data, which could be wrong statistical analyses and interpretations from the dataset.

  • Demographic

  • Customer segments

  • Quantitative data

Multivariate analysis

  • Customer segments
by(telco_use_phone$`Total Revenue`,telco_use_phone$Offer,summary)
## telco_use_phone$Offer: None
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    21.4   626.1  2219.5  3088.4  4877.6 11688.9 
## ------------------------------------------------------------ 
## telco_use_phone$Offer: Offer A
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    1579    5941    7783    7345    9167   11979 
## ------------------------------------------------------------ 
## telco_use_phone$Offer: Offer B
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   820.9  3870.9  5492.9  5357.1  6789.2 10184.5 
## ------------------------------------------------------------ 
## telco_use_phone$Offer: Offer C
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   454.1  2197.3  2971.3  2940.6  3804.3  6027.6 
## ------------------------------------------------------------ 
## telco_use_phone$Offer: Offer D
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   212.8   895.3  1305.2  1373.0  1817.0  3273.1 
## ------------------------------------------------------------ 
## telco_use_phone$Offer: Offer E
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   21.36   99.17  222.60  323.40  467.51 1351.16
by(telco_use_phone$`Total Revenue`,telco_use_phone$Contract,summary)
## telco_use_phone$Contract: Month-to-Month
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
##    21.36   237.17   965.13  1813.78  2669.70 10718.96 
## ------------------------------------------------------------ 
## telco_use_phone$Contract: One Year
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
##    43.06  1796.75  3893.90  4234.19  6533.20 11355.87 
## ------------------------------------------------------------ 
## telco_use_phone$Contract: Two Year
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
##    50.44  2263.29  4690.34  5016.92  7700.41 11979.34

  • Yield analysis

  • Scatter plot

  • Churn analysis

Correlation

Modeling

Function

  • Logistic model

\[ p=P(y=1)=\frac{\epsilon^{\beta_1 + \beta_2*X_2 + ... + \beta_n*X_n}}{1+\epsilon^{\beta_1 + \beta_2*X_2 + ... + \beta_n*X_n}} \]

  • Logit form

\[ ln(\frac{p}{1-p}) = \beta_1 + \beta_2*X_2 + \beta_3*X_3 + ... + \beta_n*X_n \]

When \(X_j\) changes 1 unit => odd ratio \(\frac{p}{1-p}\) changes \(\epsilon^{\beta_j}\) times

Logistic regression

  • Split data
telco_use_phone = mutate(telco_use_phone, 
                        Churn = ifelse(Churn == "Yes", 1, 0))
telco_use_phone$Churn_text = ifelse(telco_use_phone$Churn == 0, 
                                   "Stayed","Churned")
set.seed(2610)
split = sample.split(telco_use_phone$Churn,SplitRatio = 0.8)
train = subset(telco_use_phone, split == TRUE)
test  = subset(telco_use_phone, split == FALSE)

train1 = train[,c(1,4:9,11:16,21,23)]
train2 = train[,c(1,4:9,11:16,21,24)]
test1 = test[,c(1,4:9,11:16,21,23)]
test2 = test[,c(1,4:9,11:16,21,24)]
  • Logistic regression model
md = glm(Churn ~ . , data = train1, family = "binomial")

md1 =glm(Churn ~. -Offer, data = train1, family = "binomial")

md2 =glm(Churn ~. -Offer - `Avg Monthly Long Distance Charges`, data = train1, family = "binomial")

summary(md)
## 
## Call:
## glm(formula = Churn ~ ., family = "binomial", data = train1)
## 
## Coefficients:
##                                       Estimate Std. Error z value Pr(>|z|)    
## (Intercept)                         -1.635e+00  2.458e-01  -6.651 2.91e-11 ***
## GenderMale                          -2.643e-02  8.391e-02  -0.315 0.752761    
## `Age Group`30 - 59                   1.350e-01  1.134e-01   1.191 0.233808    
## `Age Group`60 - 89                   4.901e-01  1.282e-01   3.824 0.000132 ***
## MarriedYes                           1.542e+00  1.271e-01  12.131  < 2e-16 ***
## `Number of Dependents`              -6.239e-01  7.286e-02  -8.563  < 2e-16 ***
## `Number of Referrals`               -5.228e-01  3.904e-02 -13.391  < 2e-16 ***
## `Tenure in Months`                  -4.823e-02  9.490e-03  -5.082 3.74e-07 ***
## OfferOffer A                         6.082e-01  2.878e-01   2.113 0.034581 *  
## OfferOffer B                        -1.997e-01  1.839e-01  -1.086 0.277489    
## OfferOffer C                        -1.722e-01  1.809e-01  -0.952 0.341125    
## OfferOffer D                        -5.030e-01  1.455e-01  -3.458 0.000544 ***
## OfferOffer E                         3.870e-01  1.272e-01   3.042 0.002352 ** 
## `Avg Monthly Long Distance Charges` -2.657e-03  3.428e-03  -0.775 0.438231    
## `Multiple Lines`Yes                  2.041e-01  1.002e-01   2.037 0.041610 *  
## ContractOne Year                    -1.426e+00  1.329e-01 -10.729  < 2e-16 ***
## ContractTwo Year                    -2.699e+00  2.120e-01 -12.729  < 2e-16 ***
## `Paperless Billing`Yes               3.019e-01  9.611e-02   3.141 0.001682 ** 
## `Payment Method`Credit Card         -4.275e-01  9.737e-02  -4.390 1.13e-05 ***
## `Payment Method`Mailed Check         4.705e-01  1.802e-01   2.611 0.009025 ** 
## `Monthly Charge`                     2.583e-02  2.532e-03  10.202  < 2e-16 ***
## `Total Revenue`                      1.564e-04  7.896e-05   1.981 0.047572 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 5809.2  on 5000  degrees of freedom
## Residual deviance: 3519.5  on 4979  degrees of freedom
## AIC: 3563.5
## 
## Number of Fisher Scoring iterations: 7
summary(md1)
## 
## Call:
## glm(formula = Churn ~ . - Offer, family = "binomial", data = train1)
## 
## Coefficients:
##                                       Estimate Std. Error z value Pr(>|z|)    
## (Intercept)                         -1.371e+00  2.349e-01  -5.836 5.35e-09 ***
## GenderMale                          -4.149e-02  8.325e-02  -0.498 0.618224    
## `Age Group`30 - 59                   1.229e-01  1.125e-01   1.093 0.274428    
## `Age Group`60 - 89                   4.826e-01  1.271e-01   3.797 0.000146 ***
## MarriedYes                           1.549e+00  1.271e-01  12.186  < 2e-16 ***
## `Number of Dependents`              -6.289e-01  7.252e-02  -8.672  < 2e-16 ***
## `Number of Referrals`               -5.261e-01  3.907e-02 -13.466  < 2e-16 ***
## `Tenure in Months`                  -6.158e-02  9.368e-03  -6.573 4.93e-11 ***
## `Avg Monthly Long Distance Charges` -4.555e-03  3.381e-03  -1.347 0.177929    
## `Multiple Lines`Yes                  1.716e-01  9.885e-02   1.736 0.082477 .  
## ContractOne Year                    -1.416e+00  1.318e-01 -10.743  < 2e-16 ***
## ContractTwo Year                    -2.517e+00  2.017e-01 -12.479  < 2e-16 ***
## `Paperless Billing`Yes               3.079e-01  9.549e-02   3.225 0.001261 ** 
## `Payment Method`Credit Card         -4.346e-01  9.685e-02  -4.488 7.20e-06 ***
## `Payment Method`Mailed Check         4.576e-01  1.777e-01   2.576 0.009996 ** 
## `Monthly Charge`                     2.375e-02  2.466e-03   9.629  < 2e-16 ***
## `Total Revenue`                      2.585e-04  7.801e-05   3.314 0.000921 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 5809.2  on 5000  degrees of freedom
## Residual deviance: 3554.0  on 4984  degrees of freedom
## AIC: 3588
## 
## Number of Fisher Scoring iterations: 7
summary(md2)
## 
## Call:
## glm(formula = Churn ~ . - Offer - `Avg Monthly Long Distance Charges`, 
##     family = "binomial", data = train1)
## 
## Coefficients:
##                                Estimate Std. Error z value Pr(>|z|)    
## (Intercept)                  -1.542e+00  1.985e-01  -7.770 7.86e-15 ***
## GenderMale                   -4.144e-02  8.326e-02  -0.498 0.618708    
## `Age Group`30 - 59            1.279e-01  1.124e-01   1.138 0.255070    
## `Age Group`60 - 89            4.853e-01  1.271e-01   3.818 0.000135 ***
## MarriedYes                    1.553e+00  1.270e-01  12.223  < 2e-16 ***
## `Number of Dependents`       -6.281e-01  7.248e-02  -8.666  < 2e-16 ***
## `Number of Referrals`        -5.270e-01  3.903e-02 -13.502  < 2e-16 ***
## `Tenure in Months`           -5.577e-02  8.258e-03  -6.754 1.44e-11 ***
## `Multiple Lines`Yes           1.748e-01  9.875e-02   1.770 0.076758 .  
## ContractOne Year             -1.416e+00  1.315e-01 -10.766  < 2e-16 ***
## ContractTwo Year             -2.503e+00  2.009e-01 -12.459  < 2e-16 ***
## `Paperless Billing`Yes        3.084e-01  9.545e-02   3.231 0.001234 ** 
## `Payment Method`Credit Card  -4.338e-01  9.682e-02  -4.480 7.46e-06 ***
## `Payment Method`Mailed Check  4.627e-01  1.775e-01   2.606 0.009151 ** 
## `Monthly Charge`              2.443e-02  2.421e-03  10.088  < 2e-16 ***
## `Total Revenue`               2.063e-04  6.741e-05   3.060 0.002212 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 5809.2  on 5000  degrees of freedom
## Residual deviance: 3555.8  on 4985  degrees of freedom
## AIC: 3587.8
## 
## Number of Fisher Scoring iterations: 7
## 
## ====================================================================
##                                           Dependent variable:       
##                                     --------------------------------
##                                                  Churn              
##                                        (1)        (2)        (3)    
## --------------------------------------------------------------------
## GenderMale                            -0.026     -0.041     -0.041  
##                                      (0.084)    (0.083)    (0.083)  
##                                                                     
## `Age Group`30 - 59                    0.135      0.123      0.128   
##                                      (0.113)    (0.112)    (0.112)  
##                                                                     
## `Age Group`60 - 89                   0.490***   0.483***   0.485*** 
##                                      (0.128)    (0.127)    (0.127)  
##                                                                     
## MarriedYes                           1.542***   1.549***   1.553*** 
##                                      (0.127)    (0.127)    (0.127)  
##                                                                     
## `Number of Dependents`              -0.624***  -0.629***  -0.628*** 
##                                      (0.073)    (0.073)    (0.072)  
##                                                                     
## `Number of Referrals`               -0.523***  -0.526***  -0.527*** 
##                                      (0.039)    (0.039)    (0.039)  
##                                                                     
## `Tenure in Months`                  -0.048***  -0.062***  -0.056*** 
##                                      (0.009)    (0.009)    (0.008)  
##                                                                     
## OfferOffer A                         0.608**                        
##                                      (0.288)                        
##                                                                     
## OfferOffer B                          -0.200                        
##                                      (0.184)                        
##                                                                     
## OfferOffer C                          -0.172                        
##                                      (0.181)                        
##                                                                     
## OfferOffer D                        -0.503***                       
##                                      (0.145)                        
##                                                                     
## OfferOffer E                         0.387***                       
##                                      (0.127)                        
##                                                                     
## `Avg Monthly Long Distance Charges`   -0.003     -0.005             
##                                      (0.003)    (0.003)             
##                                                                     
## `Multiple Lines`Yes                  0.204**     0.172*     0.175*  
##                                      (0.100)    (0.099)    (0.099)  
##                                                                     
## ContractOne Year                    -1.426***  -1.416***  -1.416*** 
##                                      (0.133)    (0.132)    (0.132)  
##                                                                     
## ContractTwo Year                    -2.699***  -2.517***  -2.503*** 
##                                      (0.212)    (0.202)    (0.201)  
##                                                                     
## `Paperless Billing`Yes               0.302***   0.308***   0.308*** 
##                                      (0.096)    (0.095)    (0.095)  
##                                                                     
## `Payment Method`Credit Card         -0.428***  -0.435***  -0.434*** 
##                                      (0.097)    (0.097)    (0.097)  
##                                                                     
## `Payment Method`Mailed Check         0.470***   0.458***   0.463*** 
##                                      (0.180)    (0.178)    (0.178)  
##                                                                     
## `Monthly Charge`                     0.026***   0.024***   0.024*** 
##                                      (0.003)    (0.002)    (0.002)  
##                                                                     
## `Total Revenue`                      0.0002**  0.0003***  0.0002*** 
##                                      (0.0001)   (0.0001)   (0.0001) 
##                                                                     
## Constant                            -1.635***  -1.371***  -1.542*** 
##                                      (0.246)    (0.235)    (0.198)  
##                                                                     
## --------------------------------------------------------------------
## Observations                          5,001      5,001      5,001   
## Log Likelihood                      -1,759.768 -1,776.990 -1,777.898
## Akaike Inf. Crit.                   3,563.537  3,587.980  3,587.795 
## ====================================================================
## Note:                                    *p<0.1; **p<0.05; ***p<0.01
  • Best model
anova(md,md1,test = "LR")
## Analysis of Deviance Table
## 
## Model 1: Churn ~ Gender + `Age Group` + Married + `Number of Dependents` + 
##     `Number of Referrals` + `Tenure in Months` + Offer + `Avg Monthly Long Distance Charges` + 
##     `Multiple Lines` + Contract + `Paperless Billing` + `Payment Method` + 
##     `Monthly Charge` + `Total Revenue`
## Model 2: Churn ~ (Gender + `Age Group` + Married + `Number of Dependents` + 
##     `Number of Referrals` + `Tenure in Months` + Offer + `Avg Monthly Long Distance Charges` + 
##     `Multiple Lines` + Contract + `Paperless Billing` + `Payment Method` + 
##     `Monthly Charge` + `Total Revenue`) - Offer
##   Resid. Df Resid. Dev Df Deviance  Pr(>Chi)    
## 1      4979     3519.5                          
## 2      4984     3554.0 -5  -34.443 1.943e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(md1,md2,test = "LR")
## Analysis of Deviance Table
## 
## Model 1: Churn ~ (Gender + `Age Group` + Married + `Number of Dependents` + 
##     `Number of Referrals` + `Tenure in Months` + Offer + `Avg Monthly Long Distance Charges` + 
##     `Multiple Lines` + Contract + `Paperless Billing` + `Payment Method` + 
##     `Monthly Charge` + `Total Revenue`) - Offer
## Model 2: Churn ~ (Gender + `Age Group` + Married + `Number of Dependents` + 
##     `Number of Referrals` + `Tenure in Months` + Offer + `Avg Monthly Long Distance Charges` + 
##     `Multiple Lines` + Contract + `Paperless Billing` + `Payment Method` + 
##     `Monthly Charge` + `Total Revenue`) - Offer - `Avg Monthly Long Distance Charges`
##   Resid. Df Resid. Dev Df Deviance Pr(>Chi)
## 1      4984     3554.0                     
## 2      4985     3555.8 -1   -1.815   0.1779

=> Choose model 1

  • Coefficients results
exp(coef(md1))
##                         (Intercept)                          GenderMale 
##                           0.2539304                           0.9593585 
##                  `Age Group`30 - 59                  `Age Group`60 - 89 
##                           1.1307787                           1.6203157 
##                          MarriedYes              `Number of Dependents` 
##                           4.7045677                           0.5331835 
##               `Number of Referrals`                  `Tenure in Months` 
##                           0.5909016                           0.9402811 
## `Avg Monthly Long Distance Charges`                 `Multiple Lines`Yes 
##                           0.9954556                           1.1872621 
##                    ContractOne Year                    ContractTwo Year 
##                           0.2426864                           0.0807266 
##              `Paperless Billing`Yes         `Payment Method`Credit Card 
##                           1.3606103                           0.6475098 
##        `Payment Method`Mailed Check                    `Monthly Charge` 
##                           1.5803468                           1.0240335 
##                     `Total Revenue` 
##                           1.0002585
  • Plot coefficients

  • Prediction
pr1 = predict(md1, test1, type = "response")
predicted = round(pr1)
tbl1 = table(Prediction = predicted, Actual = test1$Churn)
confusionMatrix(tbl1, positive = "1", mode = "everything")
## Confusion Matrix and Statistics
## 
##           Actual
## Prediction   0   1
##          0 828 111
##          1  88 224
##                                           
##                Accuracy : 0.8409          
##                  95% CI : (0.8195, 0.8608)
##     No Information Rate : 0.7322          
##     P-Value [Acc > NIR] : <2e-16          
##                                           
##                   Kappa : 0.5853          
##                                           
##  Mcnemar's Test P-Value : 0.1189          
##                                           
##             Sensitivity : 0.6687          
##             Specificity : 0.9039          
##          Pos Pred Value : 0.7179          
##          Neg Pred Value : 0.8818          
##               Precision : 0.7179          
##                  Recall : 0.6687          
##                      F1 : 0.6924          
##              Prevalence : 0.2678          
##          Detection Rate : 0.1791          
##    Detection Prevalence : 0.2494          
##       Balanced Accuracy : 0.7863          
##                                           
##        'Positive' Class : 1               
## 

Decision tree

  • Decision tree plot
dtr = rpart(Churn_text ~ ., data = train2, method = "class")

Initially, probability of stay decision is 0.73, first sample size divides into 51% and 49%. In layer 2, probability of stay decision is 0.54, 51% out of first sample size continues to divide into 32% and 19%.

  • Prediction
pr2 = predict(dtr, test2, type = "class") 
tbl2= table(Prediction = pr2, Actual = test2$Churn_text)
confusionMatrix(tbl2, positive = "Churned", mode = "everything")
## Confusion Matrix and Statistics
## 
##           Actual
## Prediction Churned Stayed
##    Churned     178     48
##    Stayed      157    868
##                                           
##                Accuracy : 0.8361          
##                  95% CI : (0.8144, 0.8562)
##     No Information Rate : 0.7322          
##     P-Value [Acc > NIR] : < 2.2e-16       
##                                           
##                   Kappa : 0.534           
##                                           
##  Mcnemar's Test P-Value : 4.591e-14       
##                                           
##             Sensitivity : 0.5313          
##             Specificity : 0.9476          
##          Pos Pred Value : 0.7876          
##          Neg Pred Value : 0.8468          
##               Precision : 0.7876          
##                  Recall : 0.5313          
##                      F1 : 0.6346          
##              Prevalence : 0.2678          
##          Detection Rate : 0.1423          
##    Detection Prevalence : 0.1807          
##       Balanced Accuracy : 0.7395          
##                                           
##        'Positive' Class : Churned         
## 

Diagnostic test

vif(md1)
##                                          GVIF Df GVIF^(1/(2*Df))
## Gender                               1.003156  1        1.001577
## `Age Group`                          1.069192  2        1.016866
## Married                              2.025361  1        1.423152
## `Number of Dependents`               1.088773  1        1.043443
## `Number of Referrals`                1.738341  1        1.318462
## `Tenure in Months`                  21.707871  1        4.659171
## `Avg Monthly Long Distance Charges`  1.343572  1        1.159125
## `Multiple Lines`                     1.403045  1        1.184502
## Contract                             1.440901  2        1.095617
## `Paperless Billing`                  1.129956  1        1.062994
## `Payment Method`                     1.147093  2        1.034903
## `Monthly Charge`                     2.307393  1        1.519010
## `Total Revenue`                     25.472390  1        5.047018

Suggestion

  1. Adjustment offer ranking

- Offer A seems to be the most effective when it has a high amount of revenue compared to other types even though the monthly payment is the same. The only weakness is that the number of users of offer A is relatively low

=> R&D department: need to vary offers with different prices and terms

=> Marketing department: should have some promotions for this offer

  1. Churn reasons

-45% of customers churn and switch to competitors, this could be from high price, service quality or negative experiences. Especially, contract month-to-month have large churned customers.

=> Need care and adjust immediately this contract type

  1. Based on logit model

-Factors that increase churn rate from large to small are: (1) Married, (2) Age group from 60 - 89, (3) Mailed Check, (4) Paperless billing, (5) Multiple Lines and (6) Monthly Charge

=> Need some specific policies