Skip to contents

Fits a robust linear regression — by default via this package's fast_robust_regression_cpp C++ backend (use_rcpp = TRUE; see that page for the full M/MM-estimator model, weight functions, and asymptotic variance formula), or via MASS::rlm when use_rcpp = FALSE — for a continuous response using the treatment indicator and, optionally, all recorded covariates as predictors. This provides a Huber/MM-style robustness upgrade over ordinary least squares when outcomes are heavy-tailed or outlier-prone, down-weighting large residuals rather than letting them dominate the fit the way squared-error loss does.

The method argument is passed through to either backend and may be either "M" (Huber's psi function) or "MM" (Tukey's bisquare weight, the default — higher breakdown point than "M" at some cost in asymptotic efficiency under normality). When use_rcpp = TRUE (the default), coefficient standard errors come from the C++ backend's own M-estimator asymptotic variance (ssq_b_j); when FALSE, they come from the coefficient table returned by summary.rlm(). Either way, confidence intervals and p-values use that standard error with residual degrees of freedom \(n - p\) in a normal-theory Wald approximation (not an exact finite-sample distribution).

Super class

Inference -> InferenceContinRobustRegr

Methods

+ inherited public methods from Inference


InferenceContinRobustRegr$new()

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

Initialize a robust-regression inference object for a completed design with a continuous, uncensored response.

Usage

InferenceContinRobustRegr$new(
  des_obj,
  model_formula = NULL,
  method = "MM",
  use_rcpp = TRUE,
  verbose = FALSE,
  smart_cold_start_default = NULL
)

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.

method

Robust estimation method, "M" (Huber) or "MM" (Tukey bisquare, higher breakdown point). Default "MM".

use_rcpp

Whether to use the fast_robust_regression_cpp C++ backend (TRUE, default) instead of MASS::rlm (FALSE).

verbose

Whether to print progress messages. Default FALSE.

smart_cold_start_default

Whether to use smart starting values for the optimizer.


InferenceContinRobustRegr$compute_estimate()

Computes the robust-regression treatment coefficient \(\hat\beta_T\) from an M/MM-estimator fit (see class documentation for the full model and use_rcpp backend choice). Rank-deficient covariate columns are dropped before fitting via private$fit_with_hardened_qr_column_dropping().

Usage

InferenceContinRobustRegr$compute_estimate(estimate_only = FALSE)

Arguments

estimate_only

If TRUE, skip variance component calculations.


InferenceContinRobustRegr$compute_estimate_with_bootstrap_weights()

Recomputes the robust-regression treatment estimate under subject/block bootstrap weights, used by the Bayesian bootstrap and related weighted-resampling machinery; see InferenceBayesianBootstrap. When use_rcpp = TRUE, reproduces MASS::rlm's default wt.method = "inv.var" weighting exactly by pre-multiplying X and y by \(\sqrt{\text{weight}}\) and running unweighted M-estimation on the transformed data via the C++ backend (rather than adding native weight support to that backend); when use_rcpp = FALSE, passes weights directly to MASS::rlm. This variant never populates a standard error or degrees of freedom (both left NA) — it is estimate-only by construction, matching the estimate_only default of the fast path it always uses internally.

Usage

InferenceContinRobustRegr$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.


InferenceContinRobustRegr$compute_asymp_confidence_interval()

Computes a \(1-\alpha\) level confidence interval for the robust-regression treatment coefficient \(\hat\beta_T\), using the M/MM-estimator's asymptotic standard error (see class documentation for its source depending on use_rcpp) and residual degrees of freedom \(n - p\) in a normal-theory Wald approximation. See InferenceAsymp for the shared asymptotic confidence-interval contract this delegates to.

Usage

InferenceContinRobustRegr$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.


InferenceContinRobustRegr$compute_asymp_two_sided_pval()

Computes a two-sided Wald p-value testing \(H_0: \beta_T = \code{delta}\), from the same M/MM-estimator standard error and residual degrees of freedom used by $compute_asymp_confidence_interval(). See InferenceAsymp for the shared asymptotic two-sided p-value contract this delegates to.

Usage

InferenceContinRobustRegr$compute_asymp_two_sided_pval(delta = 0)

Arguments

delta

The null difference to test against. Default is zero.


InferenceContinRobustRegr$clone()

The objects of this class are cloneable with this method.

Usage

InferenceContinRobustRegr$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 = InferenceContinRobustRegr$new(seq_des)
inf$compute_estimate()
#> [1] -0.2321722
# }