Fits a cumulative-link model with common slopes and freely estimated thresholds, by maximum likelihood or mean bias reduction. Selected terms can have threshold-specific slopes in a dense fit with either estimation method. Positive slopes shift probability toward higher outcome categories.

# S3 method for class 'fastglm_ordinal_design'
fastglm_ordinal(
  x,
  y,
  weights = NULL,
  offset = NULL,
  levels = NULL,
  firth = NULL,
  tol = 1e-08,
  maxit = 200L,
  block.size = 2048L,
  control = list(),
  link = NULL,
  nonparallel = NULL,
  ...
)

fastglm_ordinal(x, ...)

# Default S3 method
fastglm_ordinal(
  x,
  y,
  weights = NULL,
  offset = NULL,
  levels = NULL,
  firth = FALSE,
  tol = 1e-08,
  maxit = 200L,
  block.size = 2048L,
  control = list(),
  link = "logit",
  nonparallel = NULL,
  ...
)

# S3 method for class 'formula'
fastglm_ordinal(
  x,
  data,
  weights,
  offset,
  subset,
  na.action,
  contrasts = NULL,
  levels = NULL,
  firth = FALSE,
  tol = 1e-08,
  maxit = 200L,
  block.size = 2048L,
  control = list(),
  model = TRUE,
  link = "logit",
  nonparallel = NULL,
  ...
)

Arguments

x

a formula, an object from fastglm_ordinal_prepare(), or a finite dense numeric matrix of location predictors. A matrix must omit the intercept; formula fits remove the model-matrix intercept because the thresholds already specify location.

y

an ordered factor, a factor or character response with an explicit category order in levels, integer category codes with levels, or a matrix whose columns contain category counts in increasing outcome order. Named columns must match levels in the same order.

weights

nonnegative integer frequency weights for individual responses. For count matrices, counts times weights must be integers. Frequencies are used without normalization.

offset

a location offset: the model is link{Pr(Y <= j)} = alpha[j] - x beta - offset.

levels

category labels in increasing order. Numeric responses are interpreted as codes from one to the number of labels.

firth

use mean bias reduction through adjusted score equations. NULL in a prepared-design fit uses that design's default.

tol

tolerance for the remaining change in cumulative linear predictors and the standardized adjusted score.

maxit

maximum fitting iterations.

block.size

maximum observations processed together by the numerical kernel. The input design is retained in memory.

control

named optimizer controls: score.tol, step.tol, max.step, max.halves, condition.tol, standardize, trace, and observed. For common-slope maximum likelihood, observed=TRUE (the default) begins with observed-information Newton steps; expected information still certifies convergence and gives the reported covariance.

cumulative link: "logit" (proportional odds), "probit", or "cloglog" (complementary log-log). Prepared fits use their saved link when NULL is supplied.

nonparallel

terms whose slopes may differ across cumulative thresholds. For a formula fit, supply a one-sided formula selecting complete terms from the fitted formula, such as ~ exposure or ~ exposure:group. ~ . selects every predictor term. For a matrix, supply distinct column names or indices. NULL or an empty selection retains the common-slope model and its existing fitting path.

...

additional arguments to the default or formula method.

data, subset, na.action, contrasts

formula and model-frame arguments.

model

retain the formula model frame.

Value

An object of class fastglm_ordinal, with thresholds alpha, location coefficients beta, the full coefficients vector, category mapping, covariance, convergence diagnostics, and retained design. With selected nonparallel effects, the additional class fastglm_ordinal_partial provides threshold-specific slope methods; gamma stores these slopes as a predictor-by-threshold matrix, and beta contains only the common slopes. nobs() gives the total frequency, while nobs.rows counts rows with positive total frequency.

Details

By default, thresholds are estimated in increasing order. The same location slopes apply to all cumulative probabilities. Full-rank location designs are required. Sparse matrices and repeatable sources are not accepted by this interface.

With nonparallel, the model is link{Pr(Y <= j)} = alpha[j] - x_common beta - x_nonparallel gamma[,j] - offset. A selected predictor has a separate slope at each threshold and no additional common slope. Fitting requires every declared category to have positive frequency. The cumulative predictors must remain ordered at the observed predictor values, and predictions check this condition at each supplied row. Ordering at training values does not establish validity under extrapolation. A fully varying logit mean-bias-reduced model that is saturated across predictor patterns, with constant offsets within patterns and an empty intermediate category in a pattern, has no interior adjusted-score solution and is rejected before iteration. Other boundary failures retain their convergence diagnostics. See ordinal-partial-methods.

In common-slope models, an empty interior category is removed from the numerical fit and then restored to the declared scale with zero fitted probability and coincident thresholds. Convergence and information refer to the reduced model. Standard errors for the tied thresholds are unavailable. Bias-reduced fits retain empty endpoint categories; maximum likelihood with empty endpoints requires infinite thresholds and is rejected.

The covariance uses inverse expected Fisher information at the fitted estimate. It gives a first-order model-based approximation; this interface does not provide ordinal penalized-profile inference. Robust covariance is available through fastglm_vcov() or vcov(type="HC0") for converged retained dense or streamed fits with every declared category observed. Mean bias reduction solves the adjusted equations for the original thresholds and slopes. It does not maximize a log-determinant penalized ordinal likelihood.

logLik() evaluates the ordinary categorical frequency likelihood, omitting multinomial grouping constants. Consequently, grouping identical covariate patterns preserves this likelihood convention. For bias-reduced fits it is the ordinary likelihood evaluated at the bias-reduced estimate. deviance() compares this kernel with a saturated fit to the supplied response rows. It therefore uses a grouped multinomial saturated model for a count-matrix response and depends on the chosen grouping.

References

Kosmidis, I. (2014). Improved estimation in cumulative link models. Journal of the Royal Statistical Society, Series B, 76, 169–196. doi:10.1111/rssb.12025 .

Examples

set.seed(91)
x <- rnorm(150)
y <- ordered(cut(.5*x + rlogis(150), c(-Inf,-.5,.7,Inf),
                 labels=c("low","middle","high")))
fit <- fastglm_ordinal(y ~ x, firth=TRUE)
coef(fit, component="location")
#>        x 
#> 0.318986 
head(predict(fit))
#>         low    middle      high
#> 1 0.3826174 0.2915654 0.3258172
#> 2 0.3843550 0.2914401 0.3242049
#> 3 0.2587628 0.2794648 0.4617725
#> 4 0.2222789 0.2660190 0.5117021
#> 5 0.4563854 0.2806691 0.2629455
#> 6 0.2473555 0.2758408 0.4768038