smooth.MSARIMA.outlierdummy
- MSARIMA.outlierdummy(level=0.999, type='rstandard')
Detect outliers and return a matrix of indicator dummy variables.
Computes standardised residuals (via
rstandard()orrstudent()), then derives two-sided quantile bounds[q_lo, q_hi]for the fitted distribution at the given confidencelevel. Observations whose standardised residual falls outside these bounds are labelled outliers.The quantile bounds are distribution-specific:
dnorm / dlnorm (log-space):
scipy.stats.norm.ppfdlaplace:
scipy.stats.laplace.ppfds:
scipy.stats.gennorm.ppf(..., beta=0.5)dgnorm:
scipy.stats.gennorm.ppf(..., beta=shape)dgamma:
scipy.stats.gamma.ppf(..., a=1/σ, scale=σ)dinvgauss:
scipy.stats.invgauss.ppfwith df-corrected dispersion
Mirrors R’s
outlierdummy.adam()from the greybox package.- Parameters:
level (float, default 0.999) – Two-sided confidence level for outlier detection. 0.99 flags observations in the outer 1 % of the distribution.
type ({"rstandard", "rstudent"}, default "rstandard") – Which standardised residuals to use.
"rstudent"is more sensitive to individual outliers in small samples.
- Returns:
Dataclass with fields:
outliersndarray of shape (n, m) or NoneBinary dummy matrix, one column per detected outlier.
Nonewhen no outliers are found.idndarray of int0-based indices of outlier observations.
statisticndarray of shape (2,)[lower, upper]quantile bounds used for detection.levelfloatThe confidence level used.
typestrThe residual type used (
"rstandard"or"rstudent").
- Return type:
OutlierDummy
- Raises:
ValueError – If
typeis not"rstandard"or"rstudent".ValueError – If the model has not been fitted yet.
Examples
>>> model = ADAM(model="AAN") >>> model.fit(y) >>> od = model.outlierdummy(level=0.99) >>> od.id # 0-based indices of detected outliers >>> od.statistic # [lower, upper] bounds, e.g. [-2.576, 2.576] >>> if od.outliers is not None: ... # Refit with outlier dummies as exogenous regressors ... model2 = ADAM(model="AAN") ... model2.fit(y, X=od.outliers)
Parent Class: MSARIMA