Skip to contents

As fast_ordinal_regression_cpp (see that page for the full proportional-odds model), but each observation's log-likelihood contribution is multiplied by a nonnegative weights[i] (negative weights are clamped to zero internally by the underlying weighted log-likelihood). Always fits with estimate_only = FALSE (equivalent to that function's default), so the observed information and, when invertible, the full variance-covariance matrix are always computed.

Usage

fast_ordinal_regression_weighted_cpp(
  X,
  y,
  weights,
  warm_start_params = NULL,
  smart_cold_start = TRUE,
  maxit = 100L,
  tol = 1e-06,
  fixed_idx = NULL,
  fixed_values = NULL,
  optimization_alg = "lbfgs",
  warm_start_fisher_info = NULL
)

Arguments

X

A numeric matrix of predictors (no intercept column needed; see fast_ordinal_regression_cpp).

y

A numeric vector of ordinal responses; only the rank order of distinct values matters, not their numeric coding.

weights

A numeric vector of observation weights, length nrow(X) (negative entries are treated as zero).

warm_start_params

Optional starting values for \([\alpha, \beta]\). If provided, smart_cold_start is ignored.

smart_cold_start

Logical. If TRUE, use an initial OLS-based guess when starting from scratch (a "cold start") with no prior knowledge. This is ignored if a warm start is provided.

maxit

Maximum number of optimizer iterations.

tol

Convergence tolerance.

fixed_idx

Optional 1-indexed positions (into \([\alpha,\beta]\)) of parameters to hold fixed.

fixed_values

Optional values, parallel to fixed_idx, of the fixed parameters.

optimization_alg

Optimization algorithm (default "lbfgs").

warm_start_fisher_info

Optional initial curvature (Fisher/observed information) matrix.

Value

A list with components b, alpha, params, n_params, converged, iterations, neg_loglik, observed_information/fisher_information/information (all the same observed-information matrix), information_type ("observed"), ssq_b_j (the variance of b[1]), and vcov — the latter two are NA/omitted if the free-parameter information matrix is not invertible.

Fixed parameters, warm starts, and optimization

fixed_idx (1-indexed into the combined \([\alpha, \beta]\) parameter vector, thresholds first) and fixed_values optionally hold a subset of parameters at caller-supplied constant values rather than estimating them. warm_start_params supplies starting values for \([\alpha, \beta]\) directly (skipping smart_cold_start); otherwise thresholds always start evenly spaced on \((-1, 1)\) at \(-1 + 2(k+1)/K\), and \(\beta\) starts at either zero, or (when smart_cold_start = TRUE, the default) an OLS fit of the rank-rescaled response \((y - 1)/(K - 1)\) on X — falling back silently to zero if that OLS solve is not well-posed. When smart_cold_start = TRUE and no warm_start_fisher_info is supplied, the Hessian at the starting values is additionally used to seed the optimizer's first-iteration curvature estimate. Optimization runs via optimization_alg (default "lbfgs") for up to maxit iterations or until the parameter/gradient change falls below tol.

See also

fast_ordinal_regression_cpp for the unweighted variant and the full model documentation.