In-sample fit restricted model
You calculated the accuracy for logitModelFull
. It's very important to do that with all your model candidates.
Therefore,logitModelNew
is specified and lives in your environment.
When comparing the values of the different models with each other: In case different models have the same accuracy values, always choose the model with less explanatory variables.
This exercise is part of the course
Machine Learning for Marketing Analytics in R
Exercise instructions
Do the same steps as in the previous exercise for the new model.
Use
predict()
to receive a probability for each customer to default his payment.Then calculate a confusion matrix with the same threshold of 0.5 for classification. Note that
SDMTools
cannot be downloaded from CRAN anymore. Install it instead viaremotes::install_version("SDMTools", "1.1-221.2")
.Calculate the accuracy of the restricted model and compare it to the accuracy of the full model. You will continue your analysis only with the superior model.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Calculate the accuracy for 'logitModelNew'
# Make prediction
defaultData$predNew <- predict(logitModelNew, type = ___, na.action = ___)
# Construct the in-sample confusion matrix
confMatrixModelNew <- confusion.matrix(defaultData$___,defaultData$___, threshold = ___)
confMatrixModelNew
# Calculate the accuracy...
accuracyNew <- sum(diag(___)) / ___(___)
accuracyNew
# and compare it to the full model's accuracy
accuracyFull