Skip to main content

Temporal Disaggregation of Time Series Data in Python

Project description

tsdisagg

Tools for converting low time series data to high frequency, based on the R package tempdisagg, and espeically the accompanying paper by Sax and Steiner 2013.

tsdisagg allows the user to convert low frequency time series data (e.g., yearly or quarterly) to a higher frequency (e.g., quarterly or monthly) in a way that preserves desired aggregate statistics in the high frequency data. It should, for example, sum back to the original low-frequency data.

In addition, regression-based methods are also implemented that allow the user to supply "indicator series", allowing variation from correlated high-frequency time series to be imputed into the low frequency data.

If you have any questions or issues, please open a thread. Pull requests to add features or fix bugs are welcome. Please clone the repository locally to have access to the testing suite.

Installation

To install, use pip install tsdisagg

Current Features

Currently, only conversion between yearly, quarterly, and monthly data is supported. Conversion to lower frequencies is non-trivial due to the calendar math that needs to be added, but this is on my to-do list.

The following interpolation methods have been implemented:

Single series, non-parametric methods:

  • Denton
  • Denton-Cholette

Multiseries, regression-based methods:

  • Chow-Lin
  • Litterman

Examples

Disaggregate a timeseries using the univariate Denton-Cholette method:

import pandas as pd
from tsdisagg import disaggregate_series
from tsdisagg.datasets import load_data

# Load example data
sales_a = load_data("annual_sales")


# Disaggregate from annual to quarterly using Denton-Cholette method
sales_q_dc = disaggregate_series(
    sales_a.resample("YS").last(), # Use `.resample` to ensure the frequency is set correctly
    target_freq="QS", # Desired output frequency
    method="denton-cholette", # Disaggregation method
    agg_func="sum", # Sales are flow data, so we want the quarters to sum back to the annual data
    h=1, # Differencing order (1 in this case to preserve the trend)
)

Disaggregate a timeseries using the multivariate Chow-Lin method with an indicator series:

import pandas as pd
from tsdisagg import disaggregate_series
from tsdisagg.datasets import load_data

# Load example data
sales_a = load_data("annual_sales")
exports_q = load_data("quarterly_exports")

# Disaggregate from annual to quarterly using Chow-Lin method with quarterly sales as indicator
sales_q_chow_lin = disaggregate_series(
    sales_a.resample("YS").last(), # Target series, annual frequency
    exports_q.assign(intercept=1), # Indicator matrix. We can have as many series as we want here; so we use
                                   # Exports at quarterly frequency, plus a deterministic intercept term.
    method="chow-lin", # Disaggregation method
    agg_func="sum", # Sales are flow data, so we want the quarters to sum back to the annual data
    optimizer_kwargs={"method": "powell"}, # Additional arguments to the optimizer
)

Citing tsdisagg

If you use tsdisagg in your research, please use the following citation:

@software{tsdisagg,
author = {Jesse Grabowski},
title = {tsdisagg: Temporal Disaggregation of Time Series Data in Python},
version = {0.1.0},
url = {https://github.com/jessegrabowski/tsdisagg},
howpublished = {GitHub},
year = {2025},
}

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

tsdisagg-1.3.1.tar.gz (103.5 kB view details)

Uploaded Source

Built Distribution

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

tsdisagg-1.3.1-py2.py3-none-any.whl (13.6 kB view details)

Uploaded Python 2Python 3

File details

Details for the file tsdisagg-1.3.1.tar.gz.

File metadata

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

File hashes

Hashes for tsdisagg-1.3.1.tar.gz
Algorithm Hash digest
SHA256 fbd64abc589795ed78387fedf3e066d467caae42adf710e9da17cbe51e49eb80
MD5 d474203df6cbc46ef90fbf52d46441db
BLAKE2b-256 c464bfbab8f858a17c9f9e11808867acf6ef3b5c5d959fc0c82402bae248907f

See more details on using hashes here.

Provenance

The following attestation bundles were made for tsdisagg-1.3.1.tar.gz:

Publisher: release.yml on jessegrabowski/tsdisagg

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

File details

Details for the file tsdisagg-1.3.1-py2.py3-none-any.whl.

File metadata

  • Download URL: tsdisagg-1.3.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tsdisagg-1.3.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7554fd273346f3fc75b19c4ab477f93f49a2bb6a2238cebdd4975fc9dce7c97f
MD5 ffb203ffe5cf19a486236a104cc63126
BLAKE2b-256 360b11846f71a97dfb8f1095d601a37a119d8fa039d4538c62ffb189788b160b

See more details on using hashes here.

Provenance

The following attestation bundles were made for tsdisagg-1.3.1-py2.py3-none-any.whl:

Publisher: release.yml on jessegrabowski/tsdisagg

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