0
$\begingroup$

I tried developing a scorecard to assess creditworthiness using the "Scorecard" package on R. The problem I encountered is when I scale the card and calculate the points for each attribute of each characteristic: when I calculate the score through the package I get one score, but when I do the scaling myself and calculate the score manually I get another score. I'm not sure if the package uses a different methodology or if I did something wrong.

Here's the code of the calculation done through the package:

library(scorecard)

# load germancredit data
data("germancredit")
summary(germancredit)

# filter attributes:
filtered_data = var_filter(germancredit, y="creditability")

# breaking data into train and test by creating two sub-objects "Train" and "Test" using the  split function
dt_list = split_df(filtered_data, y="creditability", ratio = 0.6, seed = 30)

#Storing the two sub-objects created by last function in separate variables
train = dt_list$train
test = dt_list$test

# Automatic Optimal WoE binning
binned_data = woebin(filtered_data, y="creditability")

#adjusting breaks
breaks_adj = list(
  age.in.years=c(26, 35, 40),
  other.debtors.or.guarantors=c("none", "co-applicant%,%guarantor"))

bins_adj = woebin(filtered_data, y="creditability", breaks_list=breaks_adj)


# Converting train and test into WoE values: all values of each attributes
# are replaced by their respective WoE values already calculated
train_woe = woebin_ply(train, bins_adj)
test_woe = woebin_ply(test, bins_adj)

# Logistic Regression applied to the training data that we converted to WoE values:
m1 = glm( creditability ~ ., family = binomial(), data = train_woe)

# Show estimated coefficients and significance level of each attribute:
summary(m1)


# Scorecard Scaling & final card:
card = scorecard(bins = binned_data, m1, points0 = 600, odds0 = 50, pdo = 20)

But when I calculate the score manually for example for the attribute "Rent" of the "Housing" characteristic as such (following Siddiqi (2006), Credit Risk Scorecards):

#for rent attribute:
Housing_coeff = 0.120110
rent_woe = 0.4044452
intercept = -0.9419
num_of_charac = 14
pdo = 20
factor = pdo/log(2)
offset = 600 - (factor*log(50))

#Score rent
(Housing_coeff*rent_woe + (intercept/num_of_charac) ) * factor + (offset/num_of_charac)

I have a way different score than the one given by the package. Also some of the scores given by the package are negative and I don't know if that's supposed to be.

Thanks.

$\endgroup$
0
$\begingroup$

Nevermind I found the answer. I looked into the source code and the package uses a slightly different methodology than the "standard" one.

| cite | improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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