clm_wrapper: Fit wrapper for 'ordinal::clm()'

View source: R/ordinal_reg-clm.R

clm_wrapperR Documentation

Fit wrapper for ordinal::clm()

Description

Fit clm(), translating parallel_reg into the nominal formula. This is done here rather than in parsnip::translate() because the formula can only be split once data is known, and because the standard translation (make_form_call()) overwrites any location formula that translate() sets.

Usage

clm_wrapper(
  formula,
  data,
  weights = NULL,
  parallel_reg = NULL,
  link = NULL,
  threshold = NULL,
  ...,
  call = rlang::caller_env()
)

Arguments

formula

The formula to pass.

data

The data frame to pass.

weights

An optional vector of case weights to pass.

parallel_reg

Logical; whether predictor effects are shared across thresholds. When FALSE, every predictor is moved to a nominal formula.

...

Additional arguments to pass.

call

The execution environment of a currently running function.

Value

An object of class clm as returned by ordinal::clm().

Examples


house_data <-
  MASS::housing[rep(seq(nrow(MASS::housing)), MASS::housing$Freq), -5]
# arguments are translated
( fit_orig <- ordinal::clm(
  Sat ~ Type + Cont, data = house_data,
  link = "logit", threshold = "symmetric2"
) )
( fit_wrap <- clm_wrapper(
  Sat ~ Type + Cont, data = house_data,
  link = "logistic", threshold = "symmetric_zero"
) )
# relax the parallel regression assumption
( fit_orig <- ordinal::clm(
  Sat ~ 1, data = house_data,
  nominal = ~ Infl + Cont
) )
( fit_wrap <- clm_wrapper(
  Sat ~ Infl + Cont, data = house_data,
  parallel_reg = FALSE
) )


ordered documentation built on Nov. 23, 2026, 9:08 a.m.