coef2rate: Convert coefficient to rates

Description Usage Arguments Details Value Examples

Description

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.

Usage

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

Arguments

model

The model object

data

The data used to calculate the rates

stat

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

force.change

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

time

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

Details

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.

Value

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.

Examples

1
2
3
4
5
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/streamlineR documentation built on May 7, 2019, 10:40 a.m.