Module stationarity

Module stationarity 

Source
Expand description

Stationarity transformations for time series

This module provides methods to transform non-stationary time series into stationary ones, which is essential for many time series modeling techniques.

§Stationarity Transformations

  • Differencing: First and higher-order differencing to remove trends
  • Detrending: Remove linear, polynomial, or local trends
  • Log transformation: Stabilize variance for exponential growth patterns
  • Box-Cox transformation: Generalized power transformation for variance stabilization
  • Seasonal differencing: Remove seasonal patterns
  • Combined transformations: Multiple transformations in sequence

§Stationarity Tests

  • Augmented Dickey-Fuller (ADF): Test for unit root (simplified implementation)
  • KPSS test: Test for trend stationarity (simplified)
  • Phillips-Perron test: Alternative unit root test (basic implementation)

§Examples

use sklears_preprocessing::temporal::stationarity::{
    StationarityTransformer, StationarityMethod
};
use scirs2_core::ndarray::Array1;

// Create sample time series with trend
let mut data = Array1::zeros(100);
for i in 0..100 {
    data[i] = (i as f64) + (i as f64 * 0.1).sin(); // Linear trend + sine wave
}

// Apply first differencing to remove trend
let transformer = StationarityTransformer::new()
    .with_method(StationarityMethod::FirstDifference);

let stationary_data = transformer.transform(&data).unwrap();

Structs§

StationarityTransformer
Stationarity transformer for making time series stationary
StationarityTransformerConfig
Configuration for stationarity transformer
StationarityTransformerFitted
Fitted state containing transformation parameters

Enums§

FillMethod
Methods for handling missing values created by transformations
StationarityMethod
Stationarity transformation methods