measure_glm_raw: Evaluating Fitted Models

View source: R/measure_raw.R

measure_glm_rawR Documentation

Evaluating Fitted Models

Description

Obtain measures of model performance for fitted models.

Usage

measure_glm_raw(
  y,
  y.fitted,
  family,
  dispersion = 1,
  classify = FALSE,
  classify.rule = 0.5
)

Arguments

y

This is an outcome/response vector.

y.fitted

This predicted (estimated) response values for GLMs or probabilties of response values for ordinal models from a fitted model or cross-validation.

family

A character stating to which family the model belongs.

dispersion

A scalar defining the dispersion parameter from a GLM, or theta for negative binomial.

classify

Logical. When TRUE and family = "binomial" applies a classification rule given by the argument classify.rule, and outputs accuracy, sensitivity, specificity, positive predictive value (ppv), and negative predictive value (npv).

classify.rule

A value between 0 and 1. For a given predicted value from a logistic regression, if the value is above classify.rule, then the predicted class is 1; otherwise the predicted class is 0. The default is 0.5.

Details

When the family is treated as Gaussian, returns deviance, R2, mean squared error (MSE), and mean absolute error (MAE). Additionally, when the outcome is binary, returns misclassification, and if classify = TRUE, then returns accuracy, sensitivity, specificity, positive predictive value (PPV), negative predictive value (NPV), Matthews correlation coefficient (MCC), and F1 score.

Value

A vector.

Note

This function is a modified version of measure.glm from BhGLM, with the modification that measures are no longer rounded, and classification evaluation is possible for binary outcomes, along with measures of classification performance.

Examples


y <- c(1, 1, 1, 0, 0, 1, 0, 0, 0, 1)
y.fitted <- c(0, 1, 1, 0, 1, 1, 0, 0, 1, 0)

measure_glm_raw(y, y.fitted, family = "binomial", classify = TRUE)


jmleach-bst/ssnet documentation built on March 4, 2024, 5:04 p.m.