Breaking Down of Model Predictions for glm models
Breaking Down of Model Predictions for glm models
## S3 method for class 'glm' broken( model, new_observation, ..., baseline = 0, predict.function = stats::predict.glm )
model |
a glm model |
new_observation |
a new observation with columns that corresponds to variables used in the model |
... |
other parameters |
baseline |
the origin/baseline for the breakDown plots, where the rectangles start. It may be a number or a character "Intercept". In the latter case the orgin will be set to model intercept. |
predict.function |
function that will calculate predictions out of model (typically |
an object of the broken class
# example for wine data wine$qualityb <- factor(wine$quality > 5.5, labels = c("bad", "good")) modelg <- glm(qualityb~fixed.acidity + volatile.acidity + citric.acid + residual.sugar + chlorides + free.sulfur.dioxide + total.sulfur.dioxide + density + pH + sulphates + alcohol, data=wine, family = "binomial") new_observation <- wine[1,] br <- broken(modelg, new_observation) logit <- function(x) exp(x)/(1+exp(x)) plot(br, logit) # example for HR_data model <- glm(left~., data = HR_data, family = "binomial") explain_1 <- broken(model, HR_data[1,]) explain_1 plot(explain_1) plot(explain_1, trans = function(x) exp(x)/(1+exp(x))) explain_2 <- broken(model, HR_data[1,], predict.function = betas) explain_2 plot(explain_2, trans = function(x) exp(x)/(1+exp(x)))
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.