Skip to contents

Iteratively excludes values whose EWMA deviation exceeds an interval-specific threshold (ET cap). Each round removes the single worst outlier (largest |dewma|, with age then internal_id as tiebreakers). Iterates until no candidates remain or <3 values.

Usage

remove_ewma_wt(
  subj_df,
  wtallow_formula = "piecewise",
  exc_label = "Exclude-A-Traj-Extreme",
  ewma_window = 15
)

Arguments

subj_df

Data frame with age_days, meas_m, internal_id columns (pre-sorted)

wtallow_formula

Formula for ET cap computation

exc_label

Exclusion code label assigned to excluded values.

ewma_window

Maximum number of positions on each side included in the EWMA (default 15)

Value

Named character vector: internal_id -> exc_label for excluded values

Details

Threshold: ET cap derived from wtallow formula and upper weight (UW). Per-observation threshold based on min neighbor gap and max(wt, ewma).

90% rule: directional dewma (before/after) must exceed 90% of threshold. For edge values, the missing directional EWMA falls back to the overall EWMA, so the 90% rule does not block exclusion; a missing neighbor gap is treated as Inf when choosing the interval.