identify_response_type: Detect response variable type for model selection

View source: R/identify_response_type.R

identify_response_typeR Documentation

Detect response variable type for model selection

Description

Used by f_auto() to identify the type of a response variable and select a proper modelling method to compute preference order. Supported types are:

  • "continuous-binary": decimal numbers and two unique values; results in a warning, as this type is difficult to model.

  • "continuous-low": decimal numbers and 3 to 5 unique values; results in a message, as this type is difficult to model.

  • "continuous-high": decimal numbers and more than 5 unique values.

  • "integer-binomial": integer with 0s and 1s, suitable for binomial models.

  • "integer-binary": integer with 2 unique values other than 0 and 1; returns a warning, as this type is difficult to model.

  • "integer-low": integer with 3 to 5 unique values or meets specified thresholds.

  • "integer-high": integer with more than 5 unique values suitable for count modelling.

  • "categorical": character or factor with 2 or more levels.

  • "unknown": when the response type cannot be determined.

Usage

identify_response_type(df = NULL, response = NULL, quiet = FALSE, ...)

Arguments

df

(required; dataframe, tibble, or sf) A dataframe with responses (optional) and predictors. Must have at least 10 rows for pairwise correlation analysis, and 10 * (length(predictors) - 1) for VIF. Default: NULL.

response

(optional, character string) Name of a response variable in df. Default: NULL.

quiet

(optional; logical) If FALSE, messages are printed. Default: FALSE.

...

(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

character string: response type

See Also

Other data_types: identify_categorical_variables(), identify_logical_variables(), identify_numeric_variables(), identify_valid_variables(), identify_zero_variance_variables()

Examples

data(vi_smol)

identify_response_type(
  df = vi_smol,
  response = "vi_numeric"
)

identify_response_type(
  df = vi_smol,
  response = "vi_counts"
)

identify_response_type(
  df = vi_smol,
  response = "vi_binomial"
)

identify_response_type(
  df = vi_smol,
  response = "vi_categorical"
)

identify_response_type(
  df = vi_smol,
  response = "vi_factor"
)


collinear documentation built on Dec. 8, 2025, 5:06 p.m.