fit_logit: Fit data into a logistic regression model

Description Usage Arguments Details Value Examples

View source: R/fit-logit.R

Description

fit_logit takes a dataset and formula input by the user to generate a logistic regression model that will be later used for the scoring borrower accounts.

Usage

1

Arguments

.data

A tibble or data.frame

formula

A formula of the form y ~ x_1 + x_2 + ..., where y is the bad variable and x1_2, x_2, ... are the variables that will be used in the scorecard.

Details

The function performs the following:

  1. Calculate the weights-of-evidence (WOEs) of the categorical variables

  2. Replace the category values with the weights of evidence

  3. Returns a glm model object with modified attributes

All numeric variables are used in the logistic regression model as is. All categorical variables are converted into WOEs before modelling. For better accuracy and for simplicity, it is recommended that numeric variables are first binned before modelling.

Value

A glm object containing the resulting model, with the name of the bad variable, and the weights of evidence for each value in each variable as attributes.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
library(dplyr)

bin_manual(german, bad, age = c_l(40, 55)) %>%
  fit_logit(bad ~ age + history + purpose)

bin_manual(german,
           bad,
           duration = c_r(15, 32),
           check = TRUE) %>%
 fit_logit(bad ~ duration + age + employed_since)
#

jgendrinal/creditscore documentation built on May 30, 2020, 3:51 p.m.