classification_summary {bayesrules}R Documentation

Posterior Classification Summaries

Description

Given a set of observed data including a binary response variable y and an rstanreg model of y, this function returns summaries of the model's posterior classification quality. These summaries include a confusion matrix as well as estimates of the model's sensitivity, specificity, and overall accuracy.

Usage

classification_summary(model, data, cutoff = 0.5)

Arguments

model

an rstanreg model object with binary y

data

data frame including the variables in the model, both response y and predictors x

cutoff

probability cutoff to classify a new case as positive (0.5 is the default)

Value

a list

Examples

x <- rnorm(20)
z <- 3*x
prob <- 1/(1+exp(-z))
y <- rbinom(20, 1, prob)
example_data <- data.frame(x = x, y = y)
example_model <- rstanarm::stan_glm(y ~ x, data = example_data, family = binomial)
classification_summary(model = example_model, data = example_data, cutoff = 0.5)                   

[Package bayesrules version 0.0.2 Index]