
Fast Adjacent-Category Logit with Variance (C++)
Source:R/RcppExports.R
fast_adjacent_category_logit_with_var_cpp.RdAdjacent-category logit model fitting with full variance-covariance matrix.
Usage
fast_adjacent_category_logit_with_var_cpp(
X,
y,
maxit = 100L,
tol = 1e-08,
smart_cold_start = TRUE,
fixed_idx = NULL,
fixed_values = NULL,
optimization_alg = "lbfgs",
warm_start_fisher_info = NULL,
warm_start_params = NULL,
warm_start_beta = NULL
)Arguments
- X
A numeric matrix of predictors.
- y
A numeric vector of responses (categorical).
- maxit
Maximum number of iterations. Fast Adjacent-Category Logit Regression with Variance, Direct MLE (C++ Backend)
Fits the same adjacent-category logit model as
fast_adjacent_category_logit_cpp(see that page for the model, category-coding/remapping, parameter layout, and optimizer contract, all shared unchanged here) and additionally computes the observed-information-based variance-covariance matrix of the fitted parameters.- tol
Convergence tolerance.
- 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.
- fixed_idx
Optional integer indices (into the
c(alpha, beta)parameter layout described in Details) of parameters to hold fixed rather than estimate.- fixed_values
Optional values to fix the parameters named by
fixed_idxat; must be the same length asfixed_idx.- optimization_alg
Optimization algorithm; see Details.
- warm_start_fisher_info
Optional initial Fisher Information matrix (over the full
c(alpha, beta)parameter vector) to warm-start curvature information.- warm_start_params
Optional starting values for the full parameter vector
c(alpha, beta). If provided,smart_cold_startis ignored.- warm_start_beta
Optional starting values for just the covariate coefficients \(\beta\) (cut intercepts \(\alpha\) are still initialized separately). If provided,
smart_cold_startis ignored.
Value
A list with all the components of
fast_adjacent_category_logit_cpp (b, alpha,
params, neg_loglik, converged), plus ssq_b_1
(equivalently ssq_b_j, the variance of the first covariate's
coefficient), vcov (the full parameter variance-covariance matrix, or
NULL if not converged), and fisher_information (the full observed
information matrix at the fitted parameters, over all parameters regardless of
fixed_idx).
Details
Variance computation. The observed Fisher information (the Hessian of the
negative log-likelihood, via AdjacentCategoryLogitNegLogLik::hessian()) is
evaluated at the fitted parameter vector over all n_alpha + p
parameters (returned in full as fisher_information), then restricted to the
free (non-fixed_idx) parameters and inverted via a rank-aware
(symmetric_pseudo_inverse(), not a plain Cholesky/LDLT solve) inverse
before being expanded back to full (n_alpha + p) x (n_alpha + p) size as
vcov. The pseudo-inverse is used deliberately: adjacent-category fits can
have an estimable treatment effect even when nuisance columns make the full
information matrix rank-deficient, a case where a standard Cholesky/LDLT solve
can report spurious success with an invalid (sometimes negative) variance rather
than failing cleanly. vcov is only populated when converged is
TRUE; otherwise it is NULL.
First-covariate variance shortcut. ssq_b_1 (aliased as
ssq_b_j for interface consistency with the package's other
fast_*_with_var_cpp functions) is the variance of \(\hat\beta_1\), the
coefficient on the first column of X — by the package's usual
convention, the treatment-effect column — extracted directly from the free-parameter
covariance block rather than requiring the caller to index into the full
vcov matrix; it is NA if that coefficient was fixed
(via fixed_idx) or if its estimated variance is non-finite or non-positive.
See also
fast_adjacent_category_logit_cpp for the estimate-only
variant and the full model/parameterization documentation.