
Quantile Regression Inference for Proportion Responses
Source:R/inference_proportion_quantile_regr.R
InferencePropQuantileRegr.RdFits a quantile regression for proportion responses (constrained to (0, 1)) using
the treatment indicator and, optionally, all recorded covariates as predictors.
Inference is performed on the logit (log-odds) scale: responses
\(y \in (0,1)\) are transformed via \(\text{logit}(y) = \log(y/(1-y))\) before
quantile regression, so the estimated treatment effect is a log-odds-ratio
shift at quantile tau; by default tau = 0.5, so this is a median
log-odds-ratio shift.
Fitting is via rq (method "br", the Barrodale-Roberts
simplex algorithm, for the point estimate; the default Frisch-Newton-adjacent
interior-point path for the variance-computing fit) on logit(y) ~ w + covariates
with no intercept column (the design matrix already carries one). Standard errors use
quantreg's Powell (1991) kernel sandwich "nid" estimator (heteroskedasticity-
and design-robust, valid under non-i.i.d. errors) when available, falling back to the
i.i.d.-errors "iid" estimator if "nid" extraction fails; inference on the
resulting standard error uses the asymptotic normal (Wald) approximation, not a
resampling-based reference distribution, for the asymptotic CI/p-value paths.
compute_asymp_confidence_interval/compute_asymp_two_sided_pval use the
fit's residual degrees of freedom \(n - p\) in a \(t\)-reference (via
compute_z_or_t_ci_from_s_and_df) rather than a plain normal reference, so the
interval/test remain slightly conservative in small samples relative to a bare Wald z.
This class requires the quantreg package, which is listed under
Suggests and is not installed automatically with EDI.
Install quantreg manually before use. Only uncensored proportion responses are
supported (checked via assertNoCensoring at construction).
References
Koenker, R. and Bassett, G. (1978). "Regression Quantiles."
Econometrica, 46(1), 33-50, doi:10.2307/1913643
, for quantile regression itself.
Powell, J. L. (1991). "Estimation of Monotonic Regression Models under Quantile
Restrictions," in Nonparametric and Semiparametric Methods in Econometrics and
Statistics, Cambridge University Press, for the "nid" sandwich standard error.
See also
InferenceContinQuantileRegr for the
untransformed (continuous-scale) analogue of this class.
Super class
Inference -> InferencePropQuantileRegr
Methods
+ inherited public methods from Inference
Inference$capabilities()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_model_formula()Inference$get_nonestimable_reason()Inference$get_nonestimable_stage()Inference$get_optimization_alg()Inference$get_response()Inference$get_response_type()Inference$get_treatment()Inference$is_nonestimable()Inference$set_optimization_alg()Inference$set_seed()Inference$supports()
InferencePropQuantileRegr$new()
Uses the shared randomization two-sided p-value contract; see
InferenceRand.
Initialize a quantile-regression inference object for a completed design with a proportion response.
Usage
InferencePropQuantileRegr$new(
des_obj,
model_formula = NULL,
tau = 0.5,
verbose = FALSE
)Arguments
des_objA completed
Designobject with a proportion response.model_formulaOptional 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.tauThe quantile to estimate (default 0.5).. Default 0.5.
verboseWhether to print progress messages.. Default FALSE.
InferencePropQuantileRegr$compute_estimate()
Computes the fitted treatment coefficient of the tau-quantile
regression of logit(y) on the treatment indicator (plus any adjustment
covariates) — a log-odds-ratio shift at quantile tau of the
proportion response, not a difference in means or in the raw-scale quantile.
Caches beta_hat_T (and, unless estimate_only, the standard error
and residual degrees of freedom) so repeated calls are cheap; returns
NA_real_ if the reduced design matrix is degenerate (fewer usable rows
than columns) or the quantreg fit fails/errors.
InferencePropQuantileRegr$compute_estimate_with_bootstrap_weights()
Recomputes compute_estimate's treatment log-odds-ratio-shift
coefficient with each subject's (or block's) contribution to the tau-quantile
fit reweighted by subject_or_block_weights (expanded to per-row weights and
passed as quantreg::rq(..., weights = ...)), for the Bayesian bootstrap
contract; see InferenceBayesianBootstrap.
Writes into the same beta_hat_T/s_beta_hat_T/df cache
fields that compute_estimate reads from — a call to this method overwrites
the cached original-data estimate with the bootstrap-reweighted one, so a subsequent
compute_estimate() call will return the bootstrap replicate's value
from cache rather than recomputing on the original data, until the cache is reset by
whatever higher-level bootstrap driver owns this object's lifecycle. Returns
NA_real_ under the same degenerate-design/fit-failure conditions as
compute_estimate.
InferencePropQuantileRegr$compute_asymp_confidence_interval()
Uses the shared asymptotic confidence-interval contract; see
InferenceAsymp.
InferencePropQuantileRegr$compute_asymp_two_sided_pval()
Uses the shared asymptotic two-sided p-value contract; see
InferenceAsymp.
Examples
# \donttest{
seq_des = DesignSeqOneByOneBernoulli$new(n = 10, response_type = 'proportion')
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(runif(10))
inf = InferencePropQuantileRegr$new(seq_des)
inf$compute_estimate()
#> [1] -0.4722314
# }