measures_model_fitness: Obtain Measures of Model Fitness

View source: R/measures_model_fitness.R

measures_model_fitnessR Documentation

Obtain Measures of Model Fitness

Description

TBD

Usage

measures_model_fitness(
  y,
  y.fitted,
  family,
  dispersion = NULL,
  inverse.link.y = TRUE,
  classify = FALSE,
  classify.rule = 0.5
)

Arguments

y

A vector containing responses/outcome values..

y.fitted

A vector containing predicted outcome/response values obtain from some model.

family

Response type (see above).

dispersion

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

inverse.link.y

Logical. When TRUE, y.fitted is assumed to have had the inverse link function applied to the values. When FALSE, y.fitted is assumed to be the linear predictor XB, and the inverse link function is internally applied to y.fitted.

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 data frame consisting of a single row and a column for each model fitness measure.

Note

This function is set to replace measure_glm_raw and measure_bh_raw.

Examples


## binary data
yb <- rbinom(20, size = 1, prob = 0.5)
yb.f <- yb
yb.f[c(2, 5, 6, 7, 13, 17)] <- abs(1 - yb[c(2, 5, 6, 7, 13, 17)])

measures_model_fitness(
  y = yb,
  y.fitted = yb.f,
  family = "binomial",
  classify = TRUE
  )

## gaussian data
yg <- rnorm(20)
yg.f <- yg + rnorm(20, 0, 2/3)

measures_model_fitness(
  y = yg,
  y.fitted = yg.f,
  family = "gaussian",
  dispersion = 1
 )


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