A small Java library for time-series analysis, forecasting, evaluation, and data-quality workflows.
- exponential smoothing: single, double, and triple
- moving averages: simple, cumulative, exponential, and weighted
- transformations: log, roots, Box-Cox, differencing, and seasonal differencing
- statistics: mean, variance, autocovariance, ACF, and PACF
- stationarity testing with Augmented Dickey-Fuller and KPSS
- model-based forecasting with ARIMA, SARIMA, and ARIMAX
- decomposition with STL-style trend/seasonal/remainder extraction
- compact state-space forecasting with a local-level Kalman model
- forecast evaluation: train/test splits, rolling-origin backtests, metrics, and Ljung-Box diagnostics
- prediction intervals for ARIMA, SARIMA, and local-level forecasts
- auto-selection helpers for ARIMA/SARIMA and exponential smoothing
- data-quality utilities for missing values, outliers, and winsorization
- release-hardening helpers: wrapper bootstrap scripts, publishing scaffolding, CI workflows, and model benchmark utilities
The project targets Java 17 and uses Gradle.
./gradlew testThis snapshot now includes a lightweight ./gradlew bootstrap script that reads gradle/wrapper/gradle-wrapper.properties, downloads the configured Gradle distribution when needed, and then runs the build. It is intended to keep CI and contributor onboarding working even without committing a generated gradle-wrapper.jar.
Primary implementation packages:
tslib.collecttslib.dataqualitytslib.decompositiontslib.diagnosticstslib.evaluationtslib.mathtslib.model.arimatslib.model.expsmoothingtslib.model.statespacetslib.movingaveragetslib.selectiontslib.teststslib.transformtslib.util
Compatibility aliases added in this patch series:
tslib.model.*forwards totslib.model.expsmoothing.*tslib.model.ARIMAforwards totslib.model.arima.ARIMAtslib.model.SARIMAforwards totslib.model.arima.SARIMAtslib.model.ARIMAXforwards totslib.model.arima.ARIMAXtslib.model.LocalLevelModelforwards totslib.model.statespace.LocalLevelModeltslib.stats.Statsforwards totslib.util.Stats
| Use case | Start with | Compare against | Notes |
|---|---|---|---|
| Level-only or gently trending series | DoubleExpSmoothing |
ARIMA, LocalLevelModel |
Good lightweight baseline. |
| Strong repeating seasonality | TripleExpSmoothing |
SARIMA |
Prefer SARIMA when seasonal autocorrelation matters. |
| Differenced stationary dynamics | ARIMA |
LocalLevelModel |
Inspect ADF/KPSS and ACF/PACF first. |
| Seasonality plus differencing | SARIMA |
TripleExpSmoothing |
Use the seasonal period consistently across preprocessing and backtests. |
| External drivers available | ARIMAX |
ARIMA |
Validate regressor alignment and holdout availability. |
| Smooth latent state / baseline uncertainty | LocalLevelModel |
ARIMA |
Good compact state-space benchmark. |
For a longer guide, see docs/MODEL_SELECTION_GUIDE.md.
import java.util.List;
import tslib.dataquality.MissingValueImputer;
import tslib.evaluation.BacktestResult;
import tslib.evaluation.IntervalForecast;
import tslib.evaluation.RollingOriginBacktest;
import tslib.model.ARIMA;
import tslib.model.ARIMAX;
import tslib.model.LocalLevelModel;
import tslib.selection.AutoArima;
import tslib.tests.KPSSTest;
import tslib.transform.Differencing;
List<Double> raw = MissingValueImputer.linearInterpolation(java.util.Arrays.asList(10.0, null, 12.0, 13.0, 14.0));
List<Double> diff = Differencing.difference(raw);
KPSSTest kpss = new KPSSTest(diff);
ARIMA arima = new ARIMA(1, 1, 0).fit(raw);
IntervalForecast intervals = arima.forecastWithIntervals(3, 0.95);
ARIMAX arimax = new ARIMAX(0, 0, 0).fit(
List.of(7.0, 9.0, 11.0, 13.0),
new double[][] {{1.0}, {2.0}, {3.0}, {4.0}});
List<Double> arimaxForecast = arimax.forecast(new double[][] {{5.0}, {6.0}});
RollingOriginBacktest backtest = new RollingOriginBacktest(4, 1);
BacktestResult result = backtest.run(raw, (train, horizon) -> new ARIMA(0, 1, 0).forecast(train, horizon));
AutoArima autoArima = new AutoArima(2, 1, 2, tslib.model.arima.ArimaOrderSearch.Criterion.AIC).fit(raw);
LocalLevelModel localLevel = new LocalLevelModel().fit(raw);tslib.transform.Differencingtslib.model.arima.ARIMAtslib.model.ARIMA
tslib.model.arima.SARIMAtslib.model.arima.InformationCriteriatslib.model.arima.ArimaOrderSearchtslib.model.SARIMA
tslib.decomposition.STLDecompositiontslib.tests.KPSSTest
tslib.model.statespace.KalmanFiltertslib.model.statespace.LocalLevelModeltslib.model.LocalLevelModel
tslib.evaluation.ForecastMetricstslib.evaluation.TrainTestSplittslib.evaluation.RollingOriginBacktesttslib.evaluation.BacktestResulttslib.diagnostics.LjungBoxTest
tslib.evaluation.PredictionIntervaltslib.evaluation.IntervalForecast- interval support for ARIMA, SARIMA, and local-level models
tslib.selection.AutoArimatslib.selection.AutoETS
tslib.model.arima.ARIMAXtslib.model.ARIMAX
tslib.dataquality.MissingValueImputertslib.dataquality.OutlierDetectortslib.dataquality.Winsorizer
- release hardening via Gradle bootstrap scripts and publishing config
- CI + tag-based release workflows
- model-selection and release-checklist docs
tslib.evaluation.ModelBenchmarktslib.evaluation.BenchmarkSummary
- release-candidate hardening via stronger edge-case and workflow tests
- README model chooser and testing guidance
- benchmark markdown/report helpers and benchmark-results template
- package-level Javadocs for primary public packages
- Java 17/21 CI matrix plus nightly verification workflow
This snapshot adds release-oriented repo plumbing:
- lightweight
./gradlewbootstrap scripts for Unix and Windows maven-publish, signing, and local build-repo publishing tasks- CI and tag-driven release workflows under
.github/workflows/ docs/MODEL_SELECTION_GUIDE.md,docs/RELEASE_CHECKLIST.md, anddocs/BENCHMARKING.md- a small benchmark helper via
tslib.evaluation.ModelBenchmarkandBenchmarkSummary
For local validation:
./gradlew publishToMavenLocal
./gradlew publishFor tagged builds, see docs/RELEASE_CHECKLIST.md and .github/workflows/release.yml.
See the examples/ directory for runnable snippets:
ForecastExample.javaTransformExample.javaArimaExample.javaSarimaExample.javaStlAndKpssExample.javaLocalLevelExample.javaBacktestExample.javaIntervalsExample.javaAutoSelectionExample.javaArimaxExample.javaDataQualityExample.javaBenchmarkComparisonExample.javaGenerateBenchmarkReportExample.javaHotelBenchmarkComparisonExample.java
Run the full verification flow locally with:
./gradlew clean test jacocoTestReport javadocThe console is configured to print individual test results. HTML reports are generated under build/reports/tests/test and build/reports/jacoco/test/html.
For a release candidate pass, also review docs/RELEASE_CHECKLIST.md, docs/TESTING_GUIDE.md, and docs/BENCHMARK_RESULTS.md.
The ARIMA/SARIMA, state-space, and evaluation additions are intentionally compact and dependency-light. They are designed for readable forecasting workflows inside this library rather than exhaustive econometric coverage.