Learn R Programming

LOGIT (version 1.3)

confusion_stat: Display confusion or classification matrix following logistic regression using glm with binomial family.

Description

Provides a confusion matrix of classification statistics following logistic regression.

Usage

confusion_stat(pred=pred,obs=obs)

Arguments

pred
Predicted values
obs
Observed values

Value

confusion matrix

Format

x
The function has two arguments: predicted values, response values

References

Hilbe, Joseph M. (2015), Practical Guide to Logistic Regression, Chapman & Hall/CRC.

Hilbe, Joseph M. (2009), Logistic Regression Models, Chapman & Hall/CRC.

See Also

glm

Examples

Run this code
library(MASS)
library(LOGIT)
data(R84)
R84$cage <- R84$age - mean(R84$age)
R84$cdoc <- R84$docvis - mean(R84$docvis)
mylogit <- glm(outwork ~ cdoc + female + kids + cage + factor(edlevel),
family=binomial, data=R84)
mu <- predict(mylogit, type="response")
cutpoint<-ROCtest(mylogit, fold=10, type="Sensitivity")$cut
mu[mu>=cutpoint]<-1
mu[mu<cutpoint]<-0
confusion_stat(mu, R84$outwork)

Run the code above in your browser using DataLab