get_metrics {riskscores}R Documentation

Get Model Metrics

Description

Calculates a risk model's accuracy, sensitivity, and specificity given a set of data.

Usage

get_metrics(
  mod,
  X = NULL,
  y = NULL,
  weights = NULL,
  threshold = NULL,
  threshold_type = c("response", "score")
)

Arguments

mod

An object of class risk_mod, usually a result of a call to risk_mod().

X

Input covariate matrix with dimension n×pn \times p; every row is an observation.

y

Numeric vector for the (binomial) response variable.

weights

Numeric vector of length nn with weights for each observation. Unless otherwise specified, default will give equal weight to each observation.

threshold

Numeric vector of classification threshold values used to calculate the accuracy, sensitivity, and specificity of the model. Defaults to a range of risk probability thresholds from 0.1 to 0.9 by 0.1.

threshold_type

Defines whether the threshold vector contains risk probability values ("response") or threshold values expressed as scores from the risk score model ("score"). Default: "response".

Value

Data frame with accuracy, sensitivity, and specificity for each threshold.

Examples

y <- breastcancer[[1]]
X <- as.matrix(breastcancer[,2:ncol(breastcancer)])

mod <- risk_mod(X, y)
get_metrics(mod, X, y)

get_metrics(mod, X, y, threshold = c(150, 175, 200), threshold_type = "score")

[Package riskscores version 1.1.1 Index]