I'm working on building a logistic model which will be used to estimate the probability that an account will skip on their monthly payment. My dataset roughly includes 50,000 observations with 15% of the observations skipping their regularly scheduled payment. My explanatory variables include the age of the account, Incentive (which is described as the account's interest rate minus the market rate) and finally their original balance amount.

My first attempt: My logit model results below

glm(formula = Level ~ Age + Incentive + log(OriginalBalance), 
    family = binomial(link = "logit"), data = df)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-0.7633  -0.5788  -0.5335  -0.4777   2.3131  

                      Estimate Std. Error z value Pr(>|z|)    
(Intercept)          -0.226113   0.138865  -1.628    0.103    
Age                  -0.009313   0.001007  -9.245  < 2e-16 ***
Incentive             0.043627   0.009537   4.574 4.78e-06 ***
log(OriginalBalance) -0.124829   0.012034 -10.373  < 2e-16 ***
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 36449  on 44945  degrees of freedom
Residual deviance: 36168  on 44942  degrees of freedom
AIC: 36176

Number of Fisher Scoring iterations: 4

I then proceeded to plot the individual explanatory variables against the dependent variable using a gam smoothing function within R's ggplot2 package. See plot 1. Looking at this plot suggest nonlinearity and thus the need for transformations or to use splines. My question is whether these plots are evidence enough for needing to transform/include splines? Are there any statistical tests that I may find useful?

Additionally I ran an HL test and the results indicate that my current model fits poorly or my model is not well specified. This further leads me to believe that I need to transform/include splines or that I may potentially need to use interaction variables.

 hl <- ResourceSelection::hoslem.test(q6$Level, fitted(m))
> hl

    Hosmer and Lemeshow goodness of fit (GOF) test

data:  q6$Level, fitted(m)
X-squared = 31.238, df = 8, p-value = 0.0001274

Plot 1


1 Answer 1


First, the Hosmer-Lemeshow test is considered obsolete. With 50000 observations and only a few predictors you could use cross-validation to evaluate and compare models. And, yes, your plots indicate that using splines could be a good idea.

There are many posts discussing cross-validation for logistic regression models, see for instance How should two cross-validated logistic regression models be compared?, How to include an interaction term in GAM?, Cross-Validation in plain english?, How to reduce predictors the right way for a logistic regression model and search this site.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.