woeregplot: Plot the charts for regresion models

Description Usage Arguments Details Value Examples

Description

Plot charts for each vairable in keeplist, including, relation chart, score chart, ROC curve chart

Usage

1
woeregplot(Data, keeplist = NULL, y, model)

Arguments

Data

data frame with at least two columns

keeplist

Name of the Independent Variables keept for capping, if missing then for all Independent Variables

y

Name of the dependent Variables

model

Name of the model fitted by regression

Details

Note: this is for credit modeling, and the most useful charts are relation chart, score chart and ROC curve Chart

Value

test: data is from the Titanic project https://www.kaggle.com/c/titanic/data traindata <- read.csv('train.csv',header=T,na.strings=c("")) Data <- subset(traindata,select=c(2,3,5,6,7,8,10,12)) model<-woereg(Data=Data,keeplist=c('Fare','Pclass'),droplist=c('Sex','Embarked'),y='Survived') library(magrittr) library(ggplot2) library(ROCR) woeregplot(Data=Data,y='Survived',model=model)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (Data, keeplist = NULL, y, model)
{
    if (is.null(keeplist)) {
        vallist <- coef(summary(model))[, 4]
        vallist <- vallist[!(names(vallist) %in% "(Intercept)")]
        keeplist <- c(names(vallist), y)
    }
    lscore <- predict(model, Data, type = "link")
    rscore <- predict(model, Data, type = "response")
    sdata <- data.frame(link = lscore, response = rscore, y = Data[,
        y], stringsAsFactors = FALSE)
    sdata %>% ggplot(aes(x = link, y = response, col = y)) +
        geom_point() + geom_rug() + ggtitle("link and response scores")
    rocp <- prediction(rscore, Data[, y])
    rocperf <- performance(rocp, "tpr", "fpr")
    plot(rocperf, colorize = TRUE)
  }

billyuanyao/WOECredit documentation built on May 28, 2019, 7:11 p.m.