
Abstract class for ordinal CLMM-based Inference in KK designs
Source:R/inference_ordinal_KK_clmm_abstract.R
InferenceAbstractKKOrdinalCLMM.RdThe random-intercept standard deviation \(\sigma_b\) may be estimated at the lower boundary (\(\sigma_b \to 0\), reported as a log-sigma near \(-5\)). That is a legitimate maximum-likelihood estimate when the likelihood decreases as \(\sigma_b^2\) leaves 0; the fit then equals the fixed-effects cumulative-link fit.
The random intercept is integrated with a 60-node Gauss-Hermite rule. The
native fit maximizes the marginal likelihood from several starts (the
default start and a few values of \(\log\sigma_b\)) on a 20-node rule,
which costs a third as much, and then refits only the start that is best
under the 60-node rule on that rule, from its estimates; the reported fit is
the 60-node optimum. Convergence is judged by the projected gradient: its
norm must be at most \(\max(10^{-4}, \epsilon_g)\) (\(\epsilon_g\) is the
kernel tolerance, 1e-12 here), where at the lower variance boundary the
\(\log\sigma_b\) coordinate is left out when the score in
\(\sigma_b^2\) points outward (a KKT point). A fit that fails that test
after L-BFGS is polished (a tight L-BFGS restart, then damped Newton steps on
the remaining coordinates, aiming at \(10^{-5}\)).
A native fit is accepted only if it converged and the gradient norm is at
most \(10^{-4}\). Otherwise it is retried once with Newton-Raphson from the
returned parameters (from that point only, unless the fit sits at the lower
variance boundary with a gradient norm above \(10^{-3}\), where the
\(\log\sigma_b\) starts are rerun as well); if that also fails the gradient
test, the estimate is NA with nonestimable reason
"kk_clmm_rcpp_not_stationary". With the default tolerance the retry
rarely runs (only when the polish cannot bring the gradient below
\(10^{-4}\)).
compute_rand_two_sided_pval(type = "score") is an opt-in
randomization statistic for large \(n\). The default statistic refits the
CLMM on every redraw (about a second per redraw at \(n = 1000\)). The
score statistic fits the CLMM once with the treatment coefficient fixed at
0 and takes, for each subject, the posterior mean over its pair's random
intercept of \(\partial \log p(y_i \mid \eta_i) / \partial \eta_i\); the
statistic is \(T(w) = \sum_i w_i r_i\), the score for the treatment
coefficient, so each redraw is one inner product (a p-value with 501 draws
takes well under a second at \(n = 1000\)). It uses the same draws, tail
counting, tie rule and \((1 + b)/(1 + B)\) p-value as the default. Like any
randomization test it is exact under the sharp null of no effect, but it is
a different statistic, so its p-values and power differ (simulated, KK14,
\(n = 50\), a 50%-power effect: rejection rate 0.43 against 0.37 for the
default). It tests only \(\delta = 0\). These classes do not offer a
randomization confidence interval.
The ordinal package's clmm() (used by the weighted
Bayesian-bootstrap refits and by use_rcpp = FALSE) fits the log-log
model when asked for link = "cloglog" and vice versa (observed in
ordinal 2026.7.26; clm() is correct). EDI detects this once per
session with a small probe and passes clmm() the link name that fits
the complementary log-log model.
Super class
Inference -> InferenceAbstractKKOrdinalCLMM
Methods
Public methods
+ inherited public methods from Inference
Inference$capabilities()Inference$clear_randomization_cache()Inference$compute_exact_confidence_interval()Inference$compute_exact_two_sided_pval_for_treatment_effect()Inference$duplicate()Inference$get_analysis_data()Inference$get_covariates()Inference$get_design_object()Inference$get_estimand()Inference$get_model_formula()Inference$get_nonestimable_reason()Inference$get_nonestimable_stage()Inference$get_optimization_alg()Inference$get_procedure_validity()Inference$get_response()Inference$get_response_type()Inference$get_summary()Inference$get_supported_estimands()Inference$get_treatment()Inference$is_nonestimable()Inference$set_estimand()Inference$set_optimization_alg()Inference$set_seed()Inference$supports()
InferenceAbstractKKOrdinalCLMM$new()
Initialize KK cumulative-link mixed-model inference for
ordinal responses, validate the matched design, and prepare the ordinal
likelihood used by InferenceAbstractKKOrdinalCLMM.
Usage
InferenceAbstractKKOrdinalCLMM$new(
des_obj,
model_formula = NULL,
use_rcpp = TRUE,
verbose = FALSE,
harden = TRUE,
smart_cold_start_default = NULL
)Arguments
des_objA completed
Designobject.model_formulaOptional formula for covariate adjustment.
use_rcppLogical. If
TRUE(default), use the internal Rcpp implementation (no external packages required). SetFALSEto fall back to ordinal::clmm.verboseA flag indicating whether messages should be displayed.
hardenWhether to apply robustness measures.
smart_cold_start_defaultWhether to use smart cold start values.
InferenceAbstractKKOrdinalCLMM$compute_estimate()
Compute the ordinal CLMM treatment-effect estimate by fitting
the cumulative-link mixed model and caching the treatment coefficient for
related InferenceAsymp methods.
InferenceAbstractKKOrdinalCLMM$compute_estimate_with_bootstrap_weights()
Recomputes the KK ordinal CLMM treatment estimate under Bayesian-bootstrap weights.
InferenceAbstractKKOrdinalCLMM$compute_asymp_confidence_interval()
Compute the ordinal CLMM asymptotic confidence interval for
the treatment coefficient using the fitted-model standard error. See
InferenceAsymp.
InferenceAbstractKKOrdinalCLMM$compute_asymp_two_sided_pval()
Compute the ordinal CLMM asymptotic two-sided p-value for the
treatment coefficient using the fitted-model standard error. See
InferenceAsymp.
InferenceAbstractKKOrdinalCLMM$compute_rand_two_sided_pval()
Randomization p-value for the treatment effect. With
type = NULL (the default) it is the shared randomization test
(InferenceRandCI$compute_rand_two_sided_pval()): every redraw refits the
CLMM and the statistic is the treatment estimate. type = "score" uses the
score statistic at the null fit instead: the CLMM is fit once with the treatment
coefficient fixed at 0, and each redraw costs one inner product (see the class
details). Both are exact randomization tests of the sharp null of no effect; they
use different statistics, so their p-values and power differ.
Usage
InferenceAbstractKKOrdinalCLMM$compute_rand_two_sided_pval(
r = 501,
delta = 0,
transform_responses = "none",
na.rm = TRUE,
show_progress = TRUE,
permutations = NULL,
type = NULL,
args_for_type = NULL,
zero_one_logit_clamp = .Machine$double.eps,
alternative = "two.sided"
)Arguments
rNumber of randomization draws (default 501).
deltaNull treatment effect (default 0). Only 0 is supported, for both the default statistic and
type = "score"; any other value errors: no sharp null exists on the latent log-odds scale, and shifting the ordinal levels bydeltawould test a different hypothesis.transform_responsesResponse transform for the default statistic (see
InferenceRand$compute_rand_two_sided_pval()); must be"none"withtype = "score".na.rmDrop non-finite draws (they are always dropped; see
InferenceRand$compute_rand_two_sided_pval()).show_progressWhether to show progress (default statistic only).
permutationsOptional pre-generated assignment draws: a list with element
w_mat(an \(n \times r\) 0/1 matrix, one column per draw), as forInferenceRand$compute_rand_two_sided_pval().NULLdraws them from the design; both statistics then use the same draws.typeNULL(default) or"score"."score"selects the score-at-the-null-fit statistic, offered only by the KK CLMM classes; other values are rejected. The randomization confidence interval does not use it (and is not offered by these classes).args_for_typeMust be
NULL.zero_one_logit_clampPassed to the default statistic; unused with
type = "score".alternative"two.sided"(default),"greater"or"less", with the same tail counts, tie rule and \((1 + b)/(1 + B)\) counting as the default statistic.