performance.glm.Rd
Produce indices of model performance for logistic regression
# S3 method for glm
performance(x, data, digits = 4, p = 0.5, plot = TRUE, ...)
an object of class "glm"
.
a data frame. If no data frame is provided, the model training data is used.
integer; number of digits to print (default=4).
numeric; probability cutoff for classifying cases (default = 0.5)
logical; If TRUE
the results are plotted.
not currently used
The results of the methods performance.glm
The model in the glm
object is used to predict the
the predicted probability of being a "positive" case for each observation
in the data frame. If a data frame is not specified, the model is
applied to the training data (data frame contained in the model component
of the glm
object).
If the predicted probability is greater then p
, the case is
classified as "positive", "not positive" otherwise. The actual and
predicted classifications are compared to calculate performance
metrics.
The function returns general information
about the model, a confusion matrix and statistics generated by
the confusionMatrix
function from the caret
package, and a graph visualizing the results.
# performance on training sample
fit <- regress(caesarian ~ ., data = caesarian)
performance(fit, plot=TRUE)
#> LOGISTIC REGRESSION PERFORMANCE
#> Data : caesarian
#> N : 80
#> Response variable : caesarian
#> Category Balance : no (0.42%) yes (0.58%)
#> Predicted category: yes
#> Prob to classify : >=0.5
#>
#> Model: glm(caesarian ~ .,
#> family = binomial, data = caesarian)
#>
#> Confusion Matrix
#>
#> Actual
#> Predicted no yes
#> no 22 11
#> yes 12 35
#>
#> Overall Statistics
#>
#> Accuracy: 0.7125
#> 97% CI : (0.6005, 0.8082)
#> No Information Rate: 0.575
#> P-Value [Acc > NIR]: 0.007869
#>
#> Statistics by Category
#>
#> Sensitivity 0.7609
#> Specificity 0.6471
#> Pos Pred Value 0.7447
#> Neg Pred Value 0.6667
#> F1 0.7527
#> ---
#> Note: recall = sensitivity,
#> precision = pos pred value.