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

1
confusion_stat(pred=pred,obs=obs)

Arguments

pred

Predicted values

obs

Observed values

Format

x

The function has two arguments: predicted values, response values

Value

confusion matrix

Note

confusion_stat() must be loaded into memory in order to be effectve. As a function in LOGIT, it is immediately available to a user.

Author(s)

Rafael de Souza, ELTE University, and Joseph M. Hilbe, Arizona State University

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
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)