Description Usage Arguments Details Value Examples
Plot charts for each vairable in keeplist, including, relation chart, score chart, ROC curve chart
1 | woeregplot(Data, keeplist = NULL, y, model)
|
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 |
Note: this is for credit modeling, and the most useful charts are relation chart, score chart and ROC curve Chart
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)
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)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.