Trait-agnostic residual standardization for any y vs x relationship. Fit a LOESS mean trend ŷ(x), compute residuals r = y - ŷ, and standardize them to unit-free, z-like scores ENRz. Positive ENRz = above-trend; negative = below-trend.
Usage
computeENR(
tb,
span = 0.7,
family = "symmetric",
degree = 1,
use_weights = TRUE,
std_mode = c("robust_global", "global_sd", "local_loess"),
span_scale = 0.7
)Arguments
- tb
A data.frame/tibble with at least columns
xandy.- span
LOESS span for the mean trend (default 0.7).
- family
LOESS family;
"symmetric"is robust to outliers (default).- degree
Local polynomial degree for LOESS (1 = local lines).
- use_weights
If
TRUE, use columnnas LOESS weights when present.- std_mode
One of
"robust_global","global_sd", or"local_loess".robust_global: global MAD*1.4826 (robust σ)global_sd: global standard deviationlocal_loess: LOESS onabs(resid)to model local σ
- span_scale
LOESS span used only for the
local_loesssigma fit.