Learn R Programming

PDtoolkit (version 1.2.0)

auc.model: Area under curve (AUC)

Description

auc.model calculates area under curve (AUC) for a given predicted values and observed target variable.

Usage

auc.model(predictions, observed)

Value

The command auc.model returns value of AUC.

Arguments

predictions

Model predictions.

observed

Observed values of target variable.

See Also

bivariate for automatic bivariate analysis.

Examples

Run this code
suppressMessages(library(PDtoolkit))
data(gcd)
#categorize numeric risk factor
gcd$maturity.bin <- ndr.bin(x = gcd$maturity, y = gcd$qual, y.type = "bina")[[2]]
#estimate simple logistic regression model
lr <- glm(qual ~ maturity.bin, family = "binomial", data = gcd)
#calculate auc
auc.model(predictions = predict(lr, type = "response", newdata = gcd),
    observed = gcd$qual)

Run the code above in your browser using DataLab