f_v_rf_categorical: Association Between a Categorical Response and a Categorical...

View source: R/preference_order_methods.R

f_v_rf_categoricalR Documentation

Association Between a Categorical Response and a Categorical or Numeric Predictor

Description

Computes the Cramer's V between a categorical response (of class "character" or "factor") and the prediction of a Random Forest model with a categorical or numeric predictor and weighted cases.

Usage

f_v_rf_categorical(df)

Arguments

df

(required, data frame) with columns:

  • "x": (character, factor, or numeric) categorical or numeric predictor.

  • "y" (character or factor) categorical response.

Value

numeric: Cramer's V

See Also

Other preference_order_functions: f_auc, f_r2, f_r2_counts, f_v()

Examples

#load example data
data(vi)

#reduce size to speed-up example
vi <- vi[1:1000, ]

#categorical response and predictor
#to data frame without NAs
df <- data.frame(
  y = vi[["vi_factor"]],
  x = vi[["soil_type"]]
) |>
  na.omit()

#Cramer's V of a Random Forest model
f_v_rf_categorical(df = df)

#categorical response and numeric predictor
df <- data.frame(
  y = vi[["vi_factor"]],
  x = vi[["swi_mean"]]
) |>
  na.omit()

f_v_rf_categorical(df = df)

collinear documentation built on April 12, 2025, 1:36 a.m.