R/performance_rse.R

Defines functions performance_rse

Documented in performance_rse

#' @title Residual Standard Error for Linear Models
#' @name performance_rse
#'
#' @description Compute residual standard error of linear models.
#'
#' @inheritParams performance_rmse
#'
#' @details The residual standard error is the square root of the residual
#'   sum of squares divided by the residual degrees of freedom.
#'
#' @return Numeric, the residual standard error of `model`.
#'
#' @examples
#' data(mtcars)
#' m <- lm(mpg ~ hp + gear, data = mtcars)
#' performance_rse(m)
#' @export
performance_rse <- function(model) {
  # Residual standard error
  sqrt(sum(insight::get_residuals(model)^2, na.rm = TRUE) / insight::get_df(model, type = "residual"))
}

Try the performance package in your browser

Any scripts or data that you put into this service are public.

performance documentation built on Oct. 19, 2024, 1:07 a.m.