StatsLibX logoStatsLibX

TimeSeriesStats

v0.4.0

Autocorrelation structure, stationarity testing (ADF + KPSS), classical decomposition, rolling statistics and lag features for chronologically ordered data.

Overview

TimeSeriesStats analyses a single numeric column in chronological order. Stationarity is diagnosed with two tests with opposite null hypotheses — ADF (H₀: unit root) and KPSS (H₀: stationary) — so a robust verdict falls out of combining them. All statistics are implemented with numpy/scipy: no statsmodels dependency.

Quick start
from statslibx import TimeSeriesStats
import numpy as np

rng = np.random.default_rng(0)
t = np.arange(144)
df = pd.DataFrame({
    "value": 0.05 * t + 2.0 * np.sin(2 * np.pi * t / 12) + rng.normal(scale=0.3, size=144),
})

ts = TimeSeriesStats(df, column="value")
ts.acf().is_white_noise        # False — clear seasonality
ts.stationarity_test()         # {'adf': ..., 'kpss': ...}
ts.decompose(period=12)         # trend / seasonal / residual
ts.summary()

Methods

acf
acf(column=None, nlags=None, conf_level=0.95) -> AutocorrelationResult
pacf
pacf(column=None, nlags=None, conf_level=0.95) -> AutocorrelationResult
stationarity_test
stationarity_test(column=None, method='both', regression='c', alpha=0.05, max_lag=None)
decompose
decompose(column=None, period=None, model='additive') -> DecompositionResult
rolling_stats
rolling_stats(column=None, window=5, stats=('mean', 'std', 'min', 'max')) -> DataFrame
lag_matrix
lag_matrix(column=None, max_lag=5, drop_na=True) -> DataFrame

Result objects

AutocorrelationResult / StationarityResult / DecompositionResult
to_dataframe() · to_dict() · to_markdown() · to_json()