staged.blocks {PDtoolkit} | R Documentation |
Staged blocks regression
Description
staged.blocks
performs blockwise regression where the predictions of each blocks' model is used as an
offset for the model of the following block.
Usage
staged.blocks(
method,
target,
db,
coding = "WoE",
blocks,
p.value = 0.05,
miv.threshold = 0.02,
m.ch.p.val = 0.05
)
Arguments
method |
Regression method applied on each block.
Available methods: |
target |
Name of target variable within |
db |
Modeling data with risk factors and target variable. |
coding |
Type of risk factor coding within the model. Available options are: |
blocks |
Data frame with defined risk factor groups. It has to contain the following columns: |
p.value |
Significance level of p-value for the estimated coefficient. For |
miv.threshold |
MIV (marginal information value) entrance threshold applicable only for code"stepMIV" method. Only the risk factors with MIV higher than the threshold are candidate for the new model. Additional criteria is that MIV value should significantly separate good from bad cases measured by marginal chi-square test. |
m.ch.p.val |
Significance level of p-value for marginal chi-square test applicable only for code"stepMIV" method. This test additionally supports MIV value of candidate risk factor for final decision. |
Value
The command staged.blocks
returns a list of three objects.
The first object (model
) is the list of the models of each block (an object of class inheriting from "glm"
).
The second object (steps
), is the data frame with risk factors selected from the each block.
The third object (dev.db
), returns the list of block's model development databases.
References
Anderson, R.A. (2021). Credit Intelligence & Modelling, Many Paths through the Forest of Credit Rating and Scoring, OUP Oxford
See Also
embedded.blocks
, ensemble.blocks
, stepMIV
, stepFWD
,
stepRPC
, stepFWDr
and stepRPCr
.
Examples
suppressMessages(library(PDtoolkit))
data(loans)
#create risk factor priority groups
rf.all <- names(loans)[-1]
set.seed(22)
blocks <- data.frame(rf = rf.all, block = sample(1:3, length(rf.all), rep = TRUE))
blocks <- blocks[order(blocks$block), ]
blocks
#method: stepFWDr
res <- staged.blocks(method = "stepFWDr",
target = "Creditability",
db = loans,
blocks = blocks)
names(res)
nb <- length(res[["models"]])
res$models[[nb]]
auc.model(predictions = predict(res$models[[nb]], type = "response",
newdata = res$dev.db[[nb]]),
observed = res$dev.db[[nb]]$Creditability)
identical(unname(predict(res$models[[1]], type = "link", newdata = res$dev.db[[1]])),
res$dev.db[[2]]$offset.vals)
identical(unname(predict(res$models[[2]], type = "link", newdata = res$dev.db[[2]])),
res$dev.db[[3]]$offset.vals)