| Type: | Package |
| Title: | Location-Varying Gating for Mixtures of Quantile Regressions |
| Version: | 0.1.2 |
| Description: | Extends finite mixtures of quantile regressions (the 'mixqr' package) with a concomitant-covariate, quantile-indexed mixing gate. The mixing probabilities follow a multinomial-logit model whose coefficients may depend on a separate set of gating covariates and on the quantile level, so that latent-class membership can change across the conditional distribution. This turns the location-varying mixing idea of Furno (2025) into a likelihood and EM object with proper standard errors on the gate. Estimation reuses the 'mixqr' component and error-density machinery; the gate is fit by a weighted multinomial-logistic M-step and reduces exactly to a constant gate when the gating model is an intercept only. |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| Depends: | R (≥ 4.1) |
| Imports: | mixqr (≥ 0.1.1), stats, graphics |
| Suggests: | nnet, ggplot2, testthat (≥ 3.0.0), knitr, rmarkdown |
| RoxygenNote: | 7.3.3 |
| Config/testthat/edition: | 3 |
| Config/Needs/website: | pkgdown |
| VignetteBuilder: | knitr |
| URL: | https://github.com/kvenkita/mixqrgate |
| BugReports: | https://github.com/kvenkita/mixqrgate/issues |
| NeedsCompilation: | no |
| Packaged: | 2026-07-07 16:00:26 UTC; kyle |
| Author: | Kailas Venkitasubramanian [aut, cre, cph] |
| Maintainer: | Kailas Venkitasubramanian <kailasv@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-07-16 13:20:07 UTC |
mixqrgate: Location-Varying Gating for Mixtures of Quantile Regressions
Description
A companion to the mixqr package that adds a concomitant-covariate, quantile-indexed mixing gate to finite mixtures of quantile regressions. The mixing probabilities follow a multinomial-logit model whose coefficients can depend on gating covariates and on the quantile level, so latent-class membership may change across the conditional distribution – the location-varying mixing idea of Furno (2025), turned into a likelihood/EM object with standard errors on the gate.
Main entry point
-
mixqrgate()– fit a gated mixture of quantile regressions. -
sim_gate2()– a two-component design with a location-varying gate.
Author(s)
Maintainer: Kailas Venkitasubramanian kailasv@gmail.com [copyright holder]
References
Furno, M. (2025). Finite Mixture at Quantiles and Expectiles. Journal of Risk and Financial Management 18(4), 177.
Wu, Q. and Yao, W. (2016). Mixtures of quantile regressions. Computational Statistics & Data Analysis 93, 162–176.
GrĂ¼n, B. and Leisch, F. (2008). FlexMix version 2: finite mixtures with concomitant variables and varying and constant parameters. Journal of Statistical Software 28(4), 1–35.
See Also
Useful links:
Minimal pseudo-inverse (avoids a MASS dependency).
Description
Minimal pseudo-inverse (avoids a MASS dependency).
Usage
MASS_ginv(A, tol = 1e-10)
Confidence intervals for the gate coefficients
Description
Confidence intervals for the gate coefficients
Usage
## S3 method for class 'mixqrgate'
confint(object, parm, level = 0.95, tau = NULL, ...)
Arguments
object |
A |
parm |
Ignored; intervals are returned for all gate coefficients. |
level |
Confidence level. |
tau |
Quantile level at which to report the (location-varying) gate; defaults to the first grid point. |
... |
Unused. |
Value
A matrix of lower/upper limits for the gate coefficients.
Gate probabilities pi_ik from gate coefficients and gating design.
Description
Gate probabilities pi_ik from gate coefficients and gating design.
Usage
gate_predict(gamma, Z)
Arguments
gamma |
A |
Z |
A gating design matrix |
Value
An n x G matrix of mixing probabilities.
Sandwich covariance for the gate coefficients (the inference Furno lacks).
V = A^{-1} B A^{-1}, A = -Hessian of Q, B = sum_i s_i s_i'.
Description
Sandwich covariance for the gate coefficients (the inference Furno lacks).
V = A^{-1} B A^{-1}, A = -Hessian of Q, B = sum_i s_i s_i'.
Usage
gate_sandwich_vcov(Z, P, fit)
Louis observed-information gate covariance (analytic, classification-aware).
Description
Applies Louis's (1982) identity to the gate block: the observed information is
the complete-data information minus the missing information induced by the
latent class labels,
I_obs = A - sum_i ( E[S_i S_i' | y] - s_i s_i' ),
where A is the complete-data gate information (the gate Newton information at
the fitted probabilities), s_i = sum_k p_ik g_ik is the conditional score and
g_ik the gate score were observation i in class k. The cross-information
with the component coefficients is O(1/n) and omitted (DESIGN sec. 2.4), so this
is the gate-block marginal. Cheaper than the multiple-imputation variance and a
useful cross-check. Returns solve(I_obs).
Usage
gate_vcov_louis(Z, posterior, prior)
Multiple-imputation gate covariance (propagates classification uncertainty).
Description
Draws hard labels from the posterior, refits the gate, and combines the
within- and between-imputation variance: V = V_W + (1 + 1/B) V_B.
Usage
gate_vcov_mi(Z, posterior, ridge, B = 200L, maxit = 50L, tol = 1e-08)
One gated-EM fit from a single initial responsibility matrix.
Description
One gated-EM fit from a single initial responsibility matrix.
Usage
gated_em_fit(y, X, Z, G, tau, method, p_init, control)
Arguments
y, X, Z |
Response, component design, gating design. |
G |
Number of components. |
tau |
Quantile level. |
method |
|
p_init |
Initial |
control |
A |
Value
A list with the fitted state (beta, gate, prior, posterior, loglik...).
Fit a weighted multinomial logit by ridge-penalised Newton/IRLS.
Description
Fit a weighted multinomial logit by ridge-penalised Newton/IRLS.
Usage
irls_multinom_fit(Z, P, lambda = 0.001, maxit = 50L, tol = 1e-08)
Arguments
Z |
Gating design |
P |
Fractional responses |
lambda |
Ridge penalty. |
maxit, tol |
Newton iterations / tolerance. |
Value
A list with gamma ((q+1) x (G-1)), hessian, pi, converged.
Fit a gated mixture of quantile regressions
Description
Fits a finite mixture of tau-quantile regressions whose mixing probabilities follow a multinomial-logit gate on concomitant covariates, optionally indexed by the quantile level. The gate turns the location-varying mixing of Furno (2025) into a likelihood/EM object with standard errors.
Usage
mixqrgate(
formula,
data,
gating = ~1,
G = 2L,
tau = 0.5,
vary_gating = c("none", "discrete"),
method = c("ald", "kde"),
variance = c("sandwich", "louis", "stochEM"),
gate_B = 200L,
control = mixqrgate_control()
)
Arguments
formula |
Component model, |
data |
A data frame. |
gating |
One-sided concomitant gate formula in the gating covariates;
|
G |
Number of components. Default |
tau |
Quantile level(s) in (0, 1). A vector triggers a location-varying (per-tau) gate. |
vary_gating |
|
method |
|
variance |
Gate standard errors. |
gate_B |
Number of imputations for |
control |
A |
Value
An object of class "mixqrgate".
References
Furno, M. (2025). Finite Mixture at Quantiles and Expectiles. JRFM 18(4), 177.
Examples
set.seed(1)
d <- sim_gate2(n = 300)
fit <- mixqrgate(y ~ x, data = d, gating = ~ z, G = 2, tau = 0.5)
fit
Control parameters for mixqrgate()
Description
Control parameters for mixqrgate()
Usage
mixqrgate_control(
nstart = 10L,
maxit = 500L,
tol = 1e-06,
gate_ridge = 0.001,
gate_maxit = 50L,
gate_tol = 1e-08,
label_order = "slope",
bandwidth = NULL,
kde_grid = 512L,
trace = FALSE,
seed = NULL
)
Arguments
nstart |
Number of multi-start initialisations (the mixture likelihood is
multimodal). Default |
maxit |
Maximum EM iterations. Default |
tol |
Convergence tolerance on the relative parameter change. Default |
gate_ridge |
Ridge penalty on the gate coefficients (stabilises the
multinomial-logit M-step under separation / small samples). Default |
gate_maxit, gate_tol |
Inner Newton iterations / tolerance for the gate
M-step. Defaults |
label_order |
Component ordering for label switching: |
bandwidth |
Optional KDE bandwidth override ( |
kde_grid |
KDE grid size ( |
trace |
Logical; print EM progress. Default |
seed |
Optional integer RNG seed. |
Value
A list of class "mixqrgate_control".
Permutation that orders components by slope (default) or intercept.
Description
Permutation that orders components by slope (default) or intercept.
Usage
order_components(beta, label_order = "slope")
Plot a gated mixture fit
Description
which = "gating" draws the class-average gate probability against the
quantile level – the location-varying mixing picture that is Furno's headline
finding. which = "fit" draws the data coloured by class with the component
quantile lines at the first grid point.
Usage
## S3 method for class 'mixqrgate'
plot(x, which = c("gating", "fit"), ...)
Arguments
x |
A |
which |
|
... |
Passed to |
Value
Invisibly x.
Predict gate probabilities or class membership
Description
Predict gate probabilities or class membership
Usage
## S3 method for class 'mixqrgate'
predict(object, newdata = NULL, type = c("prob", "class"), tau = NULL, ...)
Arguments
object |
A |
newdata |
Optional data frame (must contain the gating covariates). |
type |
|
tau |
Quantile level at which to evaluate the (location-varying) gate; defaults to the first grid point. |
... |
Unused. |
Value
A matrix of gate probabilities (type = "prob") or an integer vector
of class labels (type = "class").
Simulate a two-component mixture with a concomitant gate
Description
Membership depends on a gating covariate z through a logit
Pr(class 2 | z) = plogis(gamma[1] + gamma[2] z); the two components are
quantile regressions of y on x with distinct slopes. Errors are
median-zero.
Usage
sim_gate2(
n = 400L,
gamma = c(0, 1.5),
b1 = c(2, -3),
b2 = c(-2, 3),
sigma = c(1, 1.5),
loc_vary = 0,
het = FALSE
)
Arguments
n |
Sample size. |
gamma |
Length-2 gate coefficients (intercept, slope on |
b1, b2 |
Length-2 (intercept, slope) for components 1 and 2. |
sigma |
Length-2 error scales. |
loc_vary |
Strength of the location-varying gate (0 = membership independent of the quantile rank; larger = stronger upper-tail tilt toward class 2). |
het |
If |
Details
With loc_vary > 0 the gate becomes genuinely location-varying in the
sense of Furno (2025): membership also depends on the latent quantile rank, so
class 2 is over-represented in the upper tail and the class composition –
hence the fitted gate – shifts across the quantile level. With het = TRUE
the second component's spread grows with x.
Value
A data frame with y, x, z, and the true class.
References
Furno, M. (2025). Finite Mixture at Quantiles and Expectiles. JRFM 18(4), 177.
Row-wise softmax over (G-1) linear predictors plus a zero reference column.
Description
Row-wise softmax over (G-1) linear predictors plus a zero reference column.
Usage
softmax_rows(eta)
Summarize a gated mixture fit
Description
Reports, per quantile level, the component coefficients and the gate coefficients with standard errors, z- and p-values – the inference on how membership depends on the gating covariates (and, across the grid, on tau).
Usage
## S3 method for class 'mixqrgate'
summary(object, ...)
Arguments
object |
A |
... |
Unused. |
Value
An object of class "summary.mixqrgate".