rms_orm_wrapper: Fit and predict wrappers for 'lrm' and 'orm'

View source: R/ordinal_reg-rms.R

rms_orm_wrapperR Documentation

Fit and predict wrappers for lrm and orm

Description

rms::orm() did not support case weights or penalty before version 7.0-0. The fit wrapper errs or warns informatively when either is requested from an older version. Both rms::lrm() and rms::orm() use rms::predictrms() internally, which does not accept tibble inputs. The predict wrapper ensures that newdata is converted to a plain data frame before the S3 method is dispatched.

Usage

rms_orm_wrapper(formula, data, weights = NULL, ..., call = rlang::caller_env())

predict_lrm_wrapper(object, newdata, type, ...)

Arguments

formula

The formula to pass.

data

The data frame to pass.

weights

An optional vector of case weights to pass.

...

Additional arguments passed to the underlying method.

call

The execution environment of a currently running function.

object

A fitted model object of class "lrm" or "orm".

newdata

A data frame or tibble of predictors.

type

The prediction type, passed to the underlying method.

Value

rms_orm_wrapper() returns an object of class orm as returned by rms::orm(). predict_lrm_wrapper() returns the result of stats::predict() dispatched on object.

Examples


house_data <-
  MASS::housing[rep(seq(nrow(MASS::housing)), MASS::housing$Freq), -5]
# fit wrapper
( fit_orig <- rms::orm(Sat ~ Infl + Type + Cont, data = house_data) )
( fit_wrap <- rms_orm_wrapper(
  Sat ~ Infl + Type + Cont, data = house_data
) )
# predict wrapper
( fit <- rms::lrm(Sat ~ Infl + Type + Cont, data = house_data) )
predict(
  fit,
  newdata = head(house_data, 3),
  type = "fitted.ind"
)
# tibble input is converted internally
predict_lrm_wrapper(
  fit,
  newdata = tibble::as_tibble(head(house_data, 3)),
  type = "fitted.ind"
)


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