coef2rate: Convert coefficient to rates

Description Usage Arguments Details Value Examples

View source: R/coef2rate.R


coef2rate is designed to convert regression coefficients back to the good/bad rates for each group and variables, so that the non-technical audience can understand it easily. The coef2rate function works in two different ways dependent on whether force.change is FALSE or TRUE.


coef2rate(model, data, stat, force.change = TRUE, time = NULL)



The model object


The data used to calculate the rates


The statistics output from the level.stat function. The group/WOE is used to link the predicted rates back to the original values.


Whether to force the model to use all data, and change the value in each variable to be one of its levels.


The length of time to predict. It is only required in survival model.


If force.change is set to FALSE, the function will estimate the predicted value for each record of the given data using the given model. Then, average the predicted value for each group and variable.

If the force.change is set to TRUE, the function will go through each predictor, force the value in this predictor to be one of its group and keep all other predictors unchanged, and then calculate the predicted value for each record. By averaging the values for all record, we get a single Pred.Rate.1 for the given group and predictor. We can get the average predicted value for all groups and predictors, by going through them one by one. The idea behind force.change originates from the interpretation of regression coefficients - keep all other variables unchanged, and only change the value for one predictor. By doing this, we can get the pure effect of that variable.


The predicted rates for each group and variable, together with the frequency of records in each group, and the information value passed to the stat argument.


data <- rpart::stagec
data <- na.omit(data)
mod <- glm(pgstat ~ eet + grade + ploidy, data, family=binomial(link='logit'))
st <- level.stat(data, y = 'pgstat')
coef2rate(mod, data, st)

JianhuaHuang/streamit documentation built on Aug. 19, 2018, 6:59 a.m.