Skip to contents

Internal function to compute the R-squared of observations versus predictions via stats::cor(). Used within f_numeric_glm(), f_numeric_gam(), f_numeric_rf(), f_count_glm(), and f_count_gam().

Usage

score_r2(o = NULL, p = NULL, ...)

Arguments

o

(required, numeric vector) Observations. Default: NULL

p

(required, numeric vector) Predictions. Default: NULL

...

(optional) Internal args (e.g. function_name for validate_arg_function_name, a precomputed correlation matrix m, or cross-validation args for preference_order).

Value

numeric: Pearson R-squared

See also

Examples

  score_r2(
    o = c(1, 1, 1, 0.5, 0.5, 0, 0),
    p = c(1, 0.8, 0.7, 0.6, 0.5, 0.1, 0)
  )
#> [1] 0.9077973