STL Rust
Seasonal-trend decomposition for Rust
:tada: Zero dependencies
Installation
Add this line to your application’s Cargo.toml
under [dependencies]
:
= "0.3"
Getting Started
Decompose a time series
use Stl;
let series = vec!;
let period = 7; // period of the seasonal component
let res = fit.unwrap;
Get the components
res.seasonal;
res.trend;
res.remainder;
Robustness
Use robustness iterations
let res = params.robust.fit.unwrap;
Get robustness weights
res.weights;
Multiple Seasonality
Specify multiple periods
use Mstl;
let res = fit.unwrap;
Parameters
Set STL parameters
.seasonal_length // length of the seasonal smoother
.trend_length // length of the trend smoother
.low_pass_length // length of the low-pass filter
.seasonal_degree // degree of locally-fitted polynomial in seasonal smoothing
.trend_degree // degree of locally-fitted polynomial in trend smoothing
.low_pass_degree // degree of locally-fitted polynomial in low-pass smoothing
.seasonal_jump // skipping value for seasonal smoothing
.trend_jump // skipping value for trend smoothing
.low_pass_jump // skipping value for low-pass smoothing
.inner_loops // number of loops for updating the seasonal and trend components
.outer_loops // number of iterations of robust fitting
.robust // if robustness iterations are to be used
params
Set MSTL parameters
.iterations // number of iterations
.lambda // lambda for Box-Cox transformation
.seasonal_lengths // lengths of the seasonal smoothers
.stl_params // STL params
params
Strength
Get the seasonal strength
res.seasonal_strength;
Get the trend strength
res.trend_strength;
Credits
This library was ported from the Fortran implementation.
References
- STL: A Seasonal-Trend Decomposition Procedure Based on Loess
- MSTL: A Seasonal-Trend Decomposition Algorithm for Time Series with Multiple Seasonal Patterns
- Measuring strength of trend and seasonality
History
View the changelog
Contributing
Everyone is encouraged to help improve this project. Here are a few ways you can help:
- Report bugs
- Fix bugs and submit pull requests
- Write, clarify, or fix documentation
- Suggest or add new features
To get started with development: