HMath.TimeSeries.Diagnostics¶
Module index · Numerical conventions
Description
Explicit-lag stationarity statistics, bounded change-point/warping reference algorithms, and forecast diagnostics. Statistical critical values are model-dependent approximations, not guarantees of stationarity.
On this page¶
| API | Purpose |
|---|---|
| Deterministic | Stationarity-test deterministic terms: level-only or linear-trend specification. |
| Level | Declaration and type contract below. |
| LinearTrend | Declaration and type contract below. |
| Stationarity | Significance level paired with critical value. |
| Stationarity | Declaration and type contract below. |
| stationarityStatistic | Computed ADF/KPSS stationarity test statistic. |
| stationarityCriticalValues | Significance-level and critical-value pairs for the selected test/deterministic specification. |
| stationarityObservations | Number of effective observations used by the test. |
| stationarityNull | Human-readable null hypothesis, which differs between ADF and KPSS. |
| augmentedDickeyFuller | OLS of delta x_t on x_(t-1), an intercept, optional trend, and explicitly supplied lagged differences. |
| kpss | KPSS leveltrend stationarity with an explicit BartlettNewey--West lag bandwidth. |
| changePoints | Exact quadratic dynamic programming for piecewise-constant least squares, minimizing total within-segment SSE plus penalty per change. |
| cusum | Two-sided Page CUSUM with supplied baseline mean/SD. |
| anomalies | Median/MAD outliers, using the normal-consistency factor 1.4826022185. |
| DTWResult | Dynamic-time-warping accumulated distance and original-series zero-based alignment path. |
| DTWResult | Declaration and type contract below. |
| dtwDistance | Accumulated dynamic-time-warping path cost. |
| dtwPath | Optimal alignment as zero-based index pairs from the two input series. |
| dynamicTimeWarping | Absolute local cost; Sakoe--Chiba radius must include both endpoints. |
| spectrum | One-sided unwindowed periodogram density. |
| ForecastMetric | Prediction-error metric selector; scale/zero-denominator preconditions are checked by the metric function. |
| MAE | Declaration and type contract below. |
| MSE | Declaration and type contract below. |
| RMSE | Declaration and type contract below. |
| MAPE | Declaration and type contract below. |
| SMAPE | Declaration and type contract below. |
| MASE | Declaration and type contract below. |
| forecastError | MAPE and sMAPE are percentages; zero/zero sMAPE contributes zero. |
Documentation
Deterministic
data Deterministic Source #
Stationarity-test deterministic terms: level-only or linear-trend specification.
Constructors
| Level | |
| LinearTrend |
Instances
| Show Deterministic Source # | |
Defined in HMath.TimeSeries.Diagnostics Methods showsPrec :: Int -> Deterministic -> ShowS # show :: Deterministic -> String # showList :: [Deterministic] -> ShowS # | |
| Eq Deterministic Source # | |
Defined in HMath.TimeSeries.Diagnostics Methods (==) :: Deterministic -> Deterministic -> Bool # (/=) :: Deterministic -> Deterministic -> Bool # | |
Stationarity
data Stationarity Source #
Significance level paired with critical value. ADF rejects for smaller statistics, KPSS for larger ones. No interpolated p value is fabricated.
Constructors
| Stationarity | |
Fields
| |
Instances
| Show Stationarity Source # | |
Defined in HMath.TimeSeries.Diagnostics Methods showsPrec :: Int -> Stationarity -> ShowS # show :: Stationarity -> String # showList :: [Stationarity] -> ShowS # | |
| Eq Stationarity Source # | |
Defined in HMath.TimeSeries.Diagnostics | |
augmentedDickeyFuller
augmentedDickeyFuller :: Deterministic -> Int -> [Double] -> Either MathError Stationarity Source #
OLS of delta x_t on x_(t-1), an intercept, optional trend, and explicitly supplied lagged differences. Returns the lagged-level t statistic. Critical values use MacKinnon (2010) finite-sample polynomials for one series: https:/www.statsmodels.orgstablegeneratedstatsmodels.tsa.stattools.adfuller.html . There is no automatic lag selection or normal/Student-t p-value shortcut.
kpss
kpss :: Deterministic -> Int -> [Double] -> Either MathError Stationarity Source #
KPSS leveltrend stationarity with an explicit BartlettNewey--West lag bandwidth. Critical values are Table 1 of Kwiatkowski et al. (1992), as documented at https://www.statsmodels.org/stable/generated/statsmodels.tsa.stattools.kpss.html .
changePoints
changePoints :: Double -> Int -> [Double] -> Either MathError [Int] Source #
Exact quadratic dynamic programming for piecewise-constant least squares, minimizing total within-segment SSE plus penalty per change. Break indices are zero-based starts of new segments. No pruning/approximation is used.
cusum
cusum :: Double -> Double -> Double -> Double -> [Double] -> Either MathError [Int] Source #
Two-sided Page CUSUM with supplied baseline mean/SD. A threshold crossing emits its index and resets both cumulative scores. drift and threshold are in standardized observation units.
anomalies
anomalies :: Double -> [Double] -> Either MathError [Int] Source #
Median/MAD outliers, using the normal-consistency factor 1.4826022185. If MAD is zero, every value different from the median is an anomaly.
DTWResult
Dynamic-time-warping accumulated distance and original-series zero-based alignment path.
Constructors
| DTWResult | |
Fields
| |
dynamicTimeWarping
dynamicTimeWarping :: Int -> [Double] -> [Double] -> Either MathError DTWResult Source #
Absolute local cost; Sakoe--Chiba radius must include both endpoints. Returns the unnormalized path cost, with diagonalupleft tie priority.
spectrum
spectrum :: Double -> [Double] -> Either MathError [(Double, Double)] Source #
One-sided unwindowed periodogram density. Non-DC/Nyquist bins are doubled; integral of density over frequency equals the sample mean square.
ForecastMetric
data ForecastMetric Source #
Prediction-error metric selector; scale/zero-denominator preconditions are checked by the metric function.
Instances
| Show ForecastMetric Source # | |
Defined in HMath.TimeSeries.Diagnostics Methods showsPrec :: Int -> ForecastMetric -> ShowS # show :: ForecastMetric -> String # showList :: [ForecastMetric] -> ShowS # | |
| Eq ForecastMetric Source # | |
Defined in HMath.TimeSeries.Diagnostics Methods (==) :: ForecastMetric -> ForecastMetric -> Bool # (/=) :: ForecastMetric -> ForecastMetric -> Bool # | |
forecastError
forecastError :: ForecastMetric -> [Double] -> [Double] -> Either MathError Double Source #
MAPE and sMAPE are percentages; zero/zero sMAPE contributes zero. MASE supplies its separate training set and seasonal lag to avoid test leakage.