Skip to contents

Fits a linear quantile regression, \(Q_\tau(Y_i \mid x_i) = x_i^\top\beta_\tau\), for a continuous response, estimating \(\beta_\tau\) by minimizing the asymmetric ("pinball" / "check") loss $$\hat\beta_\tau = \operatorname*{arg\,min}_\beta \sum_{i=1}^n \rho_\tau(y_i - x_i^\top\beta), \qquad \rho_\tau(u) = u\left(\tau - \mathbb{1}[u < 0]\right),$$ via quantreg's simplex method (quantreg::rq/rq.fit(..., method = "br")). The treatment coefficient is the estimated shift in the \(\tau\)-th conditional quantile of the response attributable to treatment, holding any other covariates in model_formula fixed; by default tau = 0.5, so this is median regression (robust to outliers and distributional skew relative to mean-based estimators, at the cost of losing the mean-shift interpretation away from \(\tau = 0.5\)).

Standard errors use quantreg's Powell-style "nid" (non-i.i.d., kernel-based sparsity/local-density estimator) sandwich covariance when available, with fallback to the simpler "iid" estimator if needed. Inference (confidence intervals, p-values) is based on the resulting asymptotic normal approximation, not an exact finite-sample distribution.

This class requires the quantreg package, which is listed under Suggests and is not installed automatically with EDI. Install quantreg manually before use.

References

Koenker, R., and Bassett, G. (1978). "Regression Quantiles." Econometrica, 46(1), 33-50, doi:10.2307/1913643 , for the check-loss quantile regression estimator; Koenker, R. (2005). Quantile Regression, Cambridge University Press, for the Powell-style sandwich standard error estimators used here.

Super class

Inference -> InferenceContinQuantileRegr

Methods

+ inherited public methods from Inference


InferenceContinQuantileRegr$new()

Uses the shared randomization two-sided p-value contract; see InferenceRand.

Initialize a quantile-regression inference object for a completed design with a continuous, uncensored response. Requires the quantreg package to be installed.

Usage

InferenceContinQuantileRegr$new(
  des_obj,
  model_formula = NULL,
  tau = 0.5,
  verbose = FALSE
)

Arguments

des_obj

A completed Design object with a continuous response.

model_formula

Optional formula for covariate adjustment. If NULL (default), the formula from the design object is used and its pre-computed design matrix is reused. If a formula is provided, a new design matrix is constructed from the design's imputed covariates.

tau

The quantile \(\tau \in (0, 1)\) to estimate (default 0.5, i.e. median regression).

verbose

Whether to print progress messages. Default FALSE.


InferenceContinQuantileRegr$compute_estimate()

Computes the treatment coefficient \(\hat\beta_{T,\tau}\) from a check-loss quantile regression fit at quantile tau (see class documentation for the full model). Rank-deficient covariate columns are dropped before fitting (see private$reduce_design_matrix_for_quantile()); returns NA if the reduced design has no usable treatment column or too few residual degrees of freedom.

Usage

InferenceContinQuantileRegr$compute_estimate(estimate_only = FALSE)

Arguments

estimate_only

If TRUE, skip variance component calculations.


InferenceContinQuantileRegr$compute_estimate_with_bootstrap_weights()

Recomputes the quantile-regression treatment estimate under subject/block bootstrap weights (quantreg::rq(..., weights = row_weights)), used by the Bayesian bootstrap and related weighted-resampling machinery; see InferenceBayesianBootstrap. Unlike $compute_estimate(), this always reduces the design matrix from scratch (reuse_factorizations = FALSE) rather than reusing a cached rank-reduction from a prior warm-started fit.

Usage

InferenceContinQuantileRegr$compute_estimate_with_bootstrap_weights(
  subject_or_block_weights,
  estimate_only = FALSE
)

Arguments

subject_or_block_weights

Bootstrap weights at the subject or block level.

estimate_only

If TRUE, skip variance calculations.


InferenceContinQuantileRegr$compute_asymp_confidence_interval()

Computes a \(1-\alpha\) level confidence interval for the quantile-regression treatment coefficient \(\hat\beta_{T,\tau}\), using quantreg's Powell-style "nid" asymptotic standard error (falling back to "iid" if unavailable — see class documentation) and residual degrees of freedom \(n - p\). See InferenceAsymp for the shared asymptotic confidence-interval contract this delegates to.

Usage

InferenceContinQuantileRegr$compute_asymp_confidence_interval(alpha = 0.05)

Arguments

alpha

The confidence level in the computed confidence interval is 1 - alpha. The default is 0.05.


InferenceContinQuantileRegr$compute_asymp_two_sided_pval()

Computes a two-sided Wald p-value testing \(H_0: \beta_{T,\tau} = \code{delta}\), from the same quantreg sandwich standard error and degrees of freedom used by $compute_asymp_confidence_interval(). See InferenceAsymp for the shared asymptotic two-sided p-value contract this delegates to.

Usage

InferenceContinQuantileRegr$compute_asymp_two_sided_pval(delta = 0)

Arguments

delta

The null difference to test against. Default is zero.


InferenceContinQuantileRegr$clone()

The objects of this class are cloneable with this method.

Usage

InferenceContinQuantileRegr$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

# \donttest{
seq_des = DesignSeqOneByOneBernoulli$new(n = 10, response_type = 'continuous')
for (i in 1:10) {
  seq_des$add_one_subject_to_experiment_and_assign(data.frame(x1 = rnorm(1)))
}
seq_des$add_all_subject_responses(rnorm(10))
inf = InferenceContinQuantileRegr$new(seq_des)
inf$compute_estimate()
#> [1] 1.387923
# }