cellIRWLS: Cell-weighted Iteratively Reweighted Least Squares

View source: R/cellwise_utils.R

cellIRWLSR Documentation

Cell-weighted Iteratively Reweighted Least Squares

Description

Performs robust regression where each predictor cell (i, k) carries its own weight, rather than collapsing to a single row-level weight. This is the key building block for all three cellwise-robust imputation methods (cellM, cellIRMI, cellEM).

Usage

cellIRWLS(
  X,
  y,
  w_cell = NULL,
  w_response = NULL,
  maxit = 50,
  eps = 1e-06,
  method = "tukey",
  alpha = NULL,
  init = "s-estimator",
  damping = TRUE
)

Arguments

X

n \times p design matrix (predictors, without intercept)

y

numeric n-vector (response)

w_cell

n \times p matrix of cell weights for the predictors (from cellWeights). If NULL, all weights are set to 1.

w_response

numeric n-vector of cell weights for the response variable. If NULL, all response weights are 1.

maxit

maximum number of IRWLS iterations, Default: 50

eps

convergence tolerance on the relative change in coefficients, Default: 1e-6

method

weight function: "huber" or "tukey", Default: "tukey"

alpha

tuning constant. If NULL, the default for the chosen method is used.

init

initialisation for the coefficients: "s-estimator" (default; robustbase::lmrob.S with a cell-weighted-OLS fallback) or "ols" (cell-weighted OLS).

damping

logical; if TRUE (default) the cell-weight update is adaptively damped across iterations for stability.

Value

A list with components:

coefficients

named numeric vector of regression coefficients (including intercept)

fitted

numeric n-vector of fitted values

residuals

numeric n-vector of residuals

weights

numeric n-vector of final combined row-level weights (product of psi-weight and response-weight)

w_total

the n \times (p+1) matrix of final total weights (including the intercept column)

sigma

final robust scale estimate

converged

logical indicating convergence

iterations

number of iterations performed

Algorithm

  1. Initialize coefficients with an S-estimator (robustbase::lmrob.S) when init = "s-estimator" and n > 2p, otherwise cell-weighted OLS.

  2. Iterate until convergence:

    1. Compute residuals r = y - X \beta.

    2. Estimate robust scale \sigma = \mathrm{MAD}(r).

    3. Compute psi-weights w^{\psi}_i from standardized residuals r_i / \sigma.

    4. Form row weights w^{row}_i = w^{\psi}_i \cdot w^{resp}_i.

    5. Construct weighted design matrix with cell weights entering linearly: \tilde{X}_{ik} = \sqrt{w^{row}_i} \cdot w^{cell}_{ik} \cdot X_{ik}, and weighted response \tilde{y}_i = \sqrt{w^{row}_i} \cdot y_i.

    6. Solve via QR decomposition: \beta = (\tilde{X}^T \tilde{X})^{-1} \tilde{X}^T \tilde{y}.

  3. Return coefficients, residuals, combined weights.

Author(s)

Matthias Templ


VIM documentation built on Sept. 2, 2026, 5:07 p.m.