erroR: Performance metrics for categorical models

View source: R/erroR.R

erroRR Documentation

Performance metrics for categorical models

Description

Calculates common error metrics of fitted binary and multi-categorical response models. Available measures include: the brier score, logloss and misclassification error.

Usage

erroR(model, type = c("brier", "logloss", "misclass"), thresh = 5e-1)

Arguments

model

a model object or data.frame of observed and predicted values. The following class of objects can be directly passed to the erroR function: glm(), vglm(), serp(), polr(), clm(), mlogit() and multinom(). Other Other class of objects require providing a data.frame of observed and predicted values.

type

specifies the type of error metrics

thresh

resets the default misclassification threshold

Value

value

a numeric vector of the realized error value.

type

a character vector of error type.

threshold

a numeric vector of the misclassification threshold.

See Also

Rsquared

Examples


require(serp)

set.seed(1)
n <- 100
y <- factor(rbinom(n, 1, 0.3))
x <- rnorm(n)
#p <- runif(n)

m1 <- glm(y ~ x, family = binomial())

erroR(m1, type = "brier")
erroR(m1, type = "logloss")
erroR(m1, type = "misclass")
erroR(m1, type = "misclass", thresh=0.3)

# using data.frame
df <- data.frame(y, fitted(m1))
erroR(df, type = "brier")

m2 <- serp(rating ~ temp + contact, slope = "parallel", link = "logit",
           data = wine)
erroR(m2, type = "brier")
erroR(m2, type = "logloss")
erroR(m2, type = "misclass")


ejikeugba/gofcat documentation built on Feb. 3, 2023, 6:29 a.m.