This is a sample of the data:
| 1 |
M |
Single |
84 |
London |
| 0 |
F |
Married |
79 |
NY |
| 1 |
M |
Married |
73 |
LA |
| 1 |
F |
Married |
83 |
London |
| 0 |
F |
Married |
62 |
London |
| 1 |
F |
Divorced |
60 |
London |
| 1 |
F |
Single |
89 |
NY |
| 1 |
F |
Divorced |
88 |
London |
| 1 |
F |
Married |
41 |
London |
| 1 |
F |
Married |
70 |
Lisbon |
| 1 |
M |
Married |
88 |
NY |
| 1 |
F |
Married |
85 |
London |
| 0 |
F |
Single |
59 |
LA |
| 1 |
M |
Married |
51 |
NY |
| 1 |
F |
Married |
72 |
NY |
| 1 |
M |
Divorced |
62 |
Lisbon |
| 0 |
F |
Married |
82 |
NY |
| 1 |
F |
Married |
44 |
NY |
| 1 |
F |
Single |
66 |
NY |
| 1 |
F |
Single |
90 |
LA |
End of Descriptive Statistics Part!
Logistic Regression Part:
##
## Call:
## glm(formula = Working ~ ., family = "binomial", data = data)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.8958 -1.2630 0.7440 0.7944 1.1777
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 1.7219274 0.5733826 3.003 0.00267 **
## GenderM 0.0001382 0.1885039 0.001 0.99942
## MaritalMarried -0.4771340 0.3056331 -1.561 0.11849
## MaritalSingle -0.3097531 0.3274686 -0.946 0.34420
## MaritalWidowed -0.0264423 0.5120215 -0.052 0.95881
## Happiness -0.0043254 0.0062318 -0.694 0.48762
## CityLisbon 0.0518423 0.2751298 0.188 0.85054
## CityLondon -0.3058739 0.3083405 -0.992 0.32120
## CityNY 0.0668611 0.2560313 0.261 0.79398
## CityParis -0.8649718 0.3897429 -2.219 0.02646 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 697.91 on 599 degrees of freedom
## Residual deviance: 687.04 on 590 degrees of freedom
## AIC: 707.04
##
## Number of Fisher Scoring iterations: 4
| X1 |
1 |
600 |
0.732 |
0.061 |
0.739 |
0.739 |
0.034 |
0.494 |
0.834 |
0.34 |
-1.547 |
3.366 |
0.002 |
Several options for prediction:
Prediction based upon 50%:
##
## 0 1
## 0 1 160
## 1 1 438
## Confusion Matrix and Statistics
##
## Reference
## Prediction 0 1
## 0 1 1
## 1 160 438
##
## Accuracy : 0.7317
## 95% CI : (0.6943, 0.7667)
## No Information Rate : 0.7317
## P-Value [Acc > NIR] : 0.5212
##
## Kappa : 0.0057
##
## Mcnemar's Test P-Value : <2e-16
##
## Sensitivity : 0.006211
## Specificity : 0.997722
## Pos Pred Value : 0.500000
## Neg Pred Value : 0.732441
## Prevalence : 0.268333
## Detection Rate : 0.001667
## Detection Prevalence : 0.003333
## Balanced Accuracy : 0.501967
##
## 'Positive' Class : 0
##
Prediction based upon mean probability of prediction value
##
## 0 1
## 0 72 89
## 1 164 275
## Confusion Matrix and Statistics
##
## Reference
## Prediction 0 1
## 0 72 164
## 1 89 275
##
## Accuracy : 0.5783
## 95% CI : (0.5377, 0.6182)
## No Information Rate : 0.7317
## P-Value [Acc > NIR] : 1
##
## Kappa : 0.0642
##
## Mcnemar's Test P-Value : 3.282e-06
##
## Sensitivity : 0.4472
## Specificity : 0.6264
## Pos Pred Value : 0.3051
## Neg Pred Value : 0.7555
## Prevalence : 0.2683
## Detection Rate : 0.1200
## Detection Prevalence : 0.3933
## Balanced Accuracy : 0.5368
##
## 'Positive' Class : 0
##
Prediction based upon mean probability of prediction value
ROC Curve
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases

AUC value
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Area under the curve: 0.5708
##
## 0 1
## 0 13 148
## 1 11 428
## Confusion Matrix and Statistics
##
## Reference
## Prediction 0 1
## 0 13 11
## 1 148 428
##
## Accuracy : 0.735
## 95% CI : (0.6978, 0.7699)
## No Information Rate : 0.7317
## P-Value [Acc > NIR] : 0.4478
##
## Kappa : 0.0762
##
## Mcnemar's Test P-Value : <2e-16
##
## Sensitivity : 0.08075
## Specificity : 0.97494
## Pos Pred Value : 0.54167
## Neg Pred Value : 0.74306
## Prevalence : 0.26833
## Detection Rate : 0.02167
## Detection Prevalence : 0.04000
## Balanced Accuracy : 0.52784
##
## 'Positive' Class : 0
##
You can find a video showing all the code and the process here