ransac_lme4: RANSAC initial estimator for LMM

View source: R/ransac.R

ransac_lme4R Documentation

RANSAC initial estimator for LMM

Description

RANSAC-style random subsample initial estimator for linear mixed-effects models.

Usage

ransac_lme4(
  formula,
  data,
  K = 200L,
  sub_frac = 0.5,
  scale_fn = robustbase::Qn,
  seed = NULL,
  verbose = FALSE
)

Arguments

formula

model formula in lmer syntax.

data

full data frame.

K

number of random subsamples (default 200).

sub_frac

fraction of the data per subsample (default 0.5).

scale_fn

function from a numeric residual vector to a scalar scale. Default Qn.

seed

optional RNG seed for reproducibility.

verbose

logical; print progress every 50 subsamples.

Details

For K random subsamples of the data, fit a classical lmer on each subsample, score by a robust scale of residuals computed on the full data, and return the lmer fit minimising that score.

The motivation is that for redescending psi-functions (e.g. bisquarePsi) the rlmer optimiser benefits from a starting value close to the true parameters. A bad initial estimate can produce phony local minima (e.g. random-effects correlation pinned at +/- 1; see Koller and Stahel 2022, Section 4.4). RANSAC is a classical way of generating a high-breakdown-point initial estimate by subsampling.

Value

list with fit (best lmerMod), scale (its score), subset (its row indices), scales (vector of all K scores), K, n_sub.

Examples

  set.seed(1)
  res <- ransac_lme4(Reaction ~ Days + (Days | Subject),
                      data = sleepstudy, K = 30)
  res$scale

robustlmm documentation built on June 21, 2026, 5:12 p.m.