Skip to main content

This package implements the TSRAKING procedure developed by Statistics Canada in Python3.

Project description

TSRaking

TSRaking is a Python library for generalized time series raking (benchmarking) and constrained adjustment of multi-dimensional data.

It implements a Generalized Least Squares (GLS) raking procedure that reconciles:

  • High-frequency predictions (e.g., monthly estimates)
  • Low-frequency totals (e.g., annual constraints)
  • Cross-sectional constraints (e.g., provincial totals summing to national totals)

TSRaking is designed for statistical agencies, researchers, and practitioners who need to enforce accounting identities or hierarchical consistency in time series data.


Features

  • Generalized least squares raking
  • Lightweight (NumPy-based)
  • Suitable for hierarchical time series benchmarking and frequency table rebalancing

The raking adjustment is computed via:

$$\hat{\theta} = x + V_e G^\top (G V_e G^\top + V_\varepsilon)^{-1} (g - Gx)$$

If the constraint system is rank-deficient, then Moore–Penrose matrix inversion is used to obtain a unique solution.


System Requirements

Software Requirements

  • Python ≥ 3.8
  • NumPy

Optional (for development):

  • pytest

Operating Systems

The development version of TSRaking has been tested on:

  • Linux (Ubuntu 20.04+)
  • macOS
  • Windows 10/11

The package is pure Python and should run on any operating system that supports Python 3.8+.


Installation

Install from PyPI

Create a virtual environment (recommended):

python -m venv tsraking-env
source tsraking-env/bin/activate  # macOS/Linux
# or
tsraking-env\Scripts\activate     # Windows

For developers or users who want the latest features from the main branch:

git clone https://github.com/akil-h/tsrakingpy.git
cd tsrakingpy

python -m venv tsraking-env
source tsraking-env/bin/activate  # macOS/Linux
# or
tsraking-env\Scripts\activate     # Windows

pip install -e .

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tsraking-0.1.3.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tsraking-0.1.3-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file tsraking-0.1.3.tar.gz.

File metadata

  • Download URL: tsraking-0.1.3.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tsraking-0.1.3.tar.gz
Algorithm Hash digest
SHA256 da9e97ec73c0d5e954b911bee674167767bb5d33f0458a8a845fd9190b4adf4a
MD5 7753e53c8d517e962cae7c635f14f8f3
BLAKE2b-256 fcb0cd02762eab8a09eff2bb4dfe3a2e5c2125b03c46aaace9a33035d59e819a

See more details on using hashes here.

Provenance

The following attestation bundles were made for tsraking-0.1.3.tar.gz:

Publisher: publish.yml on akil-h/tsrakingpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tsraking-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: tsraking-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tsraking-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7278fdcdd2026b3d05b83a9932a5647a1d7e9d5492d834448035d1b73a352e3b
MD5 0e6c079a8e79dc7de4c4e95ccfbbeab5
BLAKE2b-256 f58dff5ef1bfd7b15ddf510783653542139c5888bd4af10e78c94e3a93181cf9

See more details on using hashes here.

Provenance

The following attestation bundles were made for tsraking-0.1.3-py3-none-any.whl:

Publisher: publish.yml on akil-h/tsrakingpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page