The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

Package {mixqrgate}


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

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 "mixqrgate" object.

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 ⁠(q+1) x (G-1)⁠ coefficient matrix (columns = classes 2..G).

Z

A gating design matrix ⁠n x (q+1)⁠.

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

"ald" or "kde".

p_init

Initial ⁠n x G⁠ responsibilities.

control

A mixqrgate_control() list.

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 ⁠n x (q+1)⁠.

P

Fractional responses ⁠n x G⁠ (responsibilities; rows sum to 1).

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, y ~ x1 + x2 (intercept implied).

data

A data frame.

gating

One-sided concomitant gate formula in the gating covariates; ~1 (default) reproduces a constant gate (and the plain mixqr fit).

G

Number of components. Default 2.

tau

Quantile level(s) in (0, 1). A vector triggers a location-varying (per-tau) gate.

vary_gating

"none" (gate depends on covariates, not tau) or "discrete" (a separate gate per tau-grid point; Furno mode).

method

"ald" (parametric asymmetric-Laplace, genuine likelihood) or "kde" (Wu & Yao nonparametric error densities).

variance

Gate standard errors. "sandwich" (default) is the observed-information sandwich conditional on the fitted class memberships, so it under-covers when components overlap. "louis" applies Louis's (1982) identity to the gate block – an analytic, classification-aware covariance (complete information minus the missing information from the latent labels), the recommended choice for inference. "stochEM" is a multiple-imputation alternative (slower; a useful cross-check).

gate_B

Number of imputations for variance = "stochEM". Default 200.

control

A mixqrgate_control() list.

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 10.

maxit

Maximum EM iterations. Default 500.

tol

Convergence tolerance on the relative parameter change. Default 1e-6.

gate_ridge

Ridge penalty on the gate coefficients (stabilises the multinomial-logit M-step under separation / small samples). Default 1e-3.

gate_maxit, gate_tol

Inner Newton iterations / tolerance for the gate M-step. Defaults 50 and 1e-8.

label_order

Component ordering for label switching: "slope" (default, ascending first slope) or "intercept".

bandwidth

Optional KDE bandwidth override (method = "kde").

kde_grid

KDE grid size (method = "kde"). Default 512.

trace

Logical; print EM progress. Default FALSE.

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 "mixqrgate" object.

which

"gating" (default) or "fit".

...

Passed to graphics::plot().

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 "mixqrgate" object.

newdata

Optional data frame (must contain the gating covariates).

type

"prob" (gate probabilities) or "class" (most likely class).

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 z).

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 TRUE, component-2 spread grows with x (heteroscedastic).

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 "mixqrgate" object.

...

Unused.

Value

An object of class "summary.mixqrgate".

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.