Skip to main content

rstl

A Python port of R's stl function. Translated rather literally from the original R/Fortran source and vectorized with NumPy.

For more information see the R manual.

Compatible with Python 2 and 3.

Installation

pip install --user rstl

Usage

Import the STL class and call its constructor.

import numpy as np
from rstl import STL

ts = np.arange(144)
freq = 12

stl = STL(ts, freq, "periodic")

trend = stl.trend

Documentation

The code itself is mostly uncommented due to it being a literal translation.

class STL(ts, freq, s_window, s_degree=0, t_window=None,
          t_degree=1, l_window=None, l_degree=None, s_jump=None,
          t_jump=None, l_jump=None, robust=False, inner=None, outer=None):

Note that a value of None means that the default R value will be used. (These could not be specified in the signature because Python does not allow referencing other parameters).

Args:

  • ts: The time series (numpy array).
  • freq: The frequency of the time series.
  • s_window: Either the character string "periodic" or the span (in lags) of the loess window for seasonal extraction, which should be odd and at least 7, according to Cleveland et al.

Optional args:

  • s_degree, t_window, t_degree, l_window, l_degree, s_jump, t_jump, l_jump, robust, inner and outer. See the R manual for their meanings and defaults.

Attributes:

  • trend: The trend component of the time series (numpy array).

  • seasonal: The seasonal component of the time series (numpy array).

  • remainder: The remainder of the time series not explained by trend and seasonal components (numpy array).

  • weights: The final robust weights (all one if fitting is not done robustly) (numpy array).

  • s_window, s_degree, t_window, t_degree, l_window, l_degree, s_jump, t_jump, l_jump, inner and outer. Note that these may have been altered by the program.

Performance

According to tests a runtime increase of factor ~3-5 should be expected.

Copyright and License

Python port Copyright 2018 Eric Rauch.

Original source Copyright 2014 B.D. Ripley; Fortran code by Cleveland et al (1990) from ‘netlib’.

Licensed under the GPLv3.

Release files for rstl 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rstl 0.1.3
File Size Uploaded
rstl-0.1.3.tar.gz 4.6 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for rstl 0.1.3
File Interpreter ABI Platform
rstl-0.1.3-py3-none-any.whl Python 3 none any Details
rstl-0.1.3-py2-none-any.whl Python 2 none any Details

Total release size:15.0 kB

Release files / rstl-0.1.3.tar.gz

Download URL rstl-0.1.3.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
6d8ae0ccf8d05cb8d8f02d2562a0aee1ec05f00590febd39decd7bf35a17908e
BLAKE2b-256 checksum
How to use checksums
0f3daba48cae8e8374596f7f4a81b434c7036c004b8de72fa897ac20045fd1f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/2.7.15

Release files / rstl-0.1.3-py3-none-any.whl

Download URL rstl-0.1.3-py3-none-any.whl
Size 5.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1d7e5e0cf25d47d13c87f92d981d947578890c3f7de126ea6e8b3cfdf0c5785b
BLAKE2b-256 checksum
How to use checksums
2f9503821bfcb59d5e4cb9dd5e2ffce5bf1ec7da53c51b247b202bcfea03d81f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/2.7.15

Release files / rstl-0.1.3-py2-none-any.whl

Download URL rstl-0.1.3-py2-none-any.whl
Size 5.2 kB
Tags Python 2
SHA-256 checksum
How to use checksums
c778d031dfb9f8dd655f75c493e98d2e842c920b9e93675f61fa006e6878a5db
BLAKE2b-256 checksum
How to use checksums
970919adf441a30c3d9260c1b3d77f6c6d2b1cf8e5505fa01299d5b6b64bdc37
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/2.7.15

Release history Release notifications | RSS feed

This release

0.1.3 This release

3 release files

0.1.2

3 release files

0.1.1

3 release files

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page