Learn R Programming

performance (version 0.4.3)

performance_accuracy: Accuracy of predictions from model fit

Description

This function calculates the predictive accuracy of linear or logistic regression models.

Usage

performance_accuracy(model, method = c("cv", "boot"), k = 5, n = 1000)

Arguments

model

Fitted model object of class lm or glm, the latter being a logistic regression model (binary response).

method

Character string, indicating whether crossvalidation (method = "cv") or bootstrapping (method = "boot") is used to compute the accuracy values.

k

The number of folds for the kfold-crossvalidation.

n

Number of bootstrap-samples.

Value

A list with three values: The Accuracy of the model predictions, i.e. the proportion of accurately predicted values from the model, its standard error, SE, and the Method used to compute the accuracy.

Details

For linar models, the accuracy is the correlation coefficient between the actual and the predicted value of the outcome. For logistic regression models, the accuracy corresponds to the AUC-value, calculated with the auc-function.

The accuracy is the mean value of multiple correlation resp. AUC-values, which are either computed with crossvalidation or nonparametric bootstrapping (see argument method). The standard error is the standard deviation of the computed correlation resp. AUC-values.

Examples

Run this code
# NOT RUN {
model <- lm(mpg ~ wt + cyl, data = mtcars)
performance_accuracy(model)

model <- glm(vs ~ wt + mpg, data = mtcars, family = "binomial")
performance_accuracy(model)
# }

Run the code above in your browser using DataLab