# Robust Cross-Validation of Predictive Models Used in Credit Default Risk
## 2 Credit Default Modeling Use Case
### Logistic Regression  
Credit default models must be explainable and understandable to make sure that they properly reflect the underlying risks of the lending activities, and they can be used together with different business assumptions to make decisions in other potential scenarios. More importantly, the models must be explainable to banking regulators as part of the legal requirements originated by the Basel Accords set by the Basel Committee on Banking Supervision. Therefore, the models should be flexible and easy to understand, like linear regressions, while taking into consideration that predictions must belong to the (0, 1) interval, as happens with the probability of a credit default. Logistic regressions are very convenient for this task as they link a linear regression model with predictions in the (0, 1) domain via a logit function that is analytically easy to handle. These are the reasons why logistic regression is the only predictive modeling technique underlying the credit scorecards used for rating credit applications for more than 50 years. Logistic regressions can predict with some degree of accuracy the probability of an event in a specific time horizon. When used for credit default modeling, financial institutions can assess which credit applications could be worthy of lending, considering their probability of default (PD). Logistic regression is a particular case of generalized linear models commonly used when the outcome variable is dichotomous; that is, the response is a binary random variable that represents the occurrence of an event or otherwise non-event. In the context of consumer credit default modeling, a data sample consists of a certain number of credit customers (or credit lines), each of which can be assigned to a specific group of credit behavior that is defined by the values taken by certain customer and/or product attributes. Let \(N\) be the number of possible credit behavior groups, then each group is characterized by the probability of default of any of its members or \(PD_{i}\) where \(i=1,2,\ldots N\). Define \(n_{i}\) as the number of observations in group \(i\), and define also the random variable \(Y_{i}\) as the number of defaults in group \(i\) considering all default events as independent among them. Then, each random variable \(Y_{i}\) follows a binomial distribution:  
\[Prob(Y_{i}=y_{i})=\binom{n_{i}}{y_{i}}PD_{i}^{y_{i}}(1-PD_{i})^{n_{i}-y_{i}}\]  
The log-likelihood function of the joint probability distribution of random variables \(Y_{1},Y_{2},\ldots Y_{N}\) is:  
\[l(PD_{1},\ldots,\ PD_{N};\ y_{1},\ \ldots,y_{N})=\sum_{i=1}^{N}\left[y_{i} \text{log}\ PD_{i}+(n_{i}-y_{i})\text{log}\ (1-PD_{i})+log\binom{n_{i}}{y_{i}}\right]\]  
Building a probability of default model means representing the dependency between the response or dependent variable \(PD_{i}\) of each homogeneous credit default group and some of the customer attributes given by a vector of independent variables \(X=(X_{1},X_{2},\ldots X_{p})\). Generally, the logit function is used as the link between the probability of default \(PD\) and a linear combination of the covariates \(\{X_{i}\}_{i=1,\ldots p}\):  
\[Log\ \left(\frac{PD}{1-PD}\right)=\beta_{0}+\beta_{1}\times X_{1}+\beta_{2} \times X_{2}+\ldots\ \beta_{p}\times X_{p}\]  
The left-hand side of this expression or logit function represents the logarithm of odds, and the \(p\) coefficients \(\beta\) in the right-hand side are estimated by maximum likelihood, thus maximizing the log-likelihood function. In order to include categorical explanatory variables in the above formula, it is very common to transform each categorical variable into a set of dummy or binary variables. When a categorical variable takes \(K\) different values, a set of \(K\) binary variables can be created, setting the value 1 for one specific value and 0 otherwise. This is usually called _variable binarization_. Another possibility is to use the weight of evidence (_voe_) of the categorical variables as the covariates to include in the model formula.