Skip to main content

bimets — Time-Series Analysis and Econometric Modeling in Python

bimets is a Python port of the BIMETS R package for regular time-series analysis and econometric modeling. It covers time-series manipulation, parsing of Model Description Language (MDL), estimation, and deterministic and stochastic simulation.

bimets has only three dependencies: NumPy and SciPy, for numerical computation, and pandas for data interoperability.

The library keeps all the underlying mathematical behavior of BIMETS but introduces some design differences due to the Python ecosystem, such as immutable objects, explicit inputs, NumPy-based storage and pandas interoperability.

See Migration from R for a detailed comparison.

Main features

bimets provides tools for working with regular time series and for estimating and simulating multi-equation econometric models:

  • Work with regular time series. Create annual, semiannual, quarterly, monthly, weekly, and daily series; inspect their calendars; perform aligned arithmetic; apply lag, lead, difference, growth, moving-window, extension, aggregation, and disaggregation operations.
  • Organize and exchange data. Store named series in immutable datasets, convert them to and from pandas objects, and read or write BIMETS-compatible CSV files.
  • Define models in MDL. Load and safely parse BIMETS Model Description Language models, including identities, behavioral equations, conditional alternatives, lags, leads, transformations, and coefficient declarations.
  • Estimate behavioral equations. Use ordinary least squares (OLS) or instrumental variables (IV), with support for coefficient restrictions, polynomial distributed lags (PDLs), autoregressive errors, and Chow stability tests.
  • Run deterministic simulations. Solve static, dynamic, forecast, and residual-check simulations for backward- or forward-looking models using Gauss-Seidel or Newton algorithms, with exogenizations and add factors where needed.
  • Explore alternative scenarios. Perform stochastic simulation, calculate multiplier matrices, target endogenous variables through renormalization, and run Monte Carlo optimal-control searches.
  • Move from BIMETS R incrementally. Use familiar uppercase function aliases alongside the idiomatic Python API, with documented compatibility behavior and intentional differences.

Installation

pip install bimets

Quick start

Create a quarterly series with the user-oriented timeseries() constructor, which returns a BimetsSeries:

from bimets import timeseries

gdp = timeseries(
    [100.0, 102.0, 105.0, 107.0],
    start=(2020, 1),
    freq="Q",
    title="GDP",
)

growth = gdp.delta_percent()
growth.values
# array([2.        , 2.94117647, 1.9047619 ])

print(gdp)
#      Qtr1 Qtr2 Qtr3 Qtr4
# 2020  100  102  105  107

For users coming from BIMETS R, the uppercase TIMESERIES() constructor is intentionally provided as a familiar entry point. The same example can be written using the original BIMETS function names:

from bimets import TIMESERIES, TSDELTAP

gdp = TIMESERIES(
    [100.0, 102.0, 105.0, 107.0],
    start=(2020, 1),
    freq="Q",
    title="GDP",
)

growth = TSDELTAP(gdp, lag=1)
growth.values
# array([2.        , 2.94117647, 1.9047619 ])

print(gdp)
#      Qtr1 Qtr2 Qtr3 Qtr4
# 2020  100  102  105  107

TIMESERIES() is an alias of timeseries(), so both constructors return the same immutable BimetsSeries and accept the same arguments.

Printed series follow R's frequency-dependent layout: quarterly and monthly series are arranged by year and cycle, while other frequencies use a compact Time Series block. For debugging, repr(gdp) instead shows a concise value preview with the range, frequency, and metadata. TABIT() and tabulate() reuse the display rules in an aligned Date/Prd. table.

Named model data can be exchanged with pandas and updated immutably over an inclusive year-period range:

from bimets import BimetsDataset

data = BimetsDataset({"gdp": gdp})
frame = data.to_frame()
restored = BimetsDataset.from_frame(frame)
scenario = restored.assign_range(
    {"gdp": [110.0, 112.0]},
    start=(2020, 3),
    end=(2020, 4),
)

assign_range() leaves data and restored unchanged. Scalars are broadcast; sequences must contain one value per selected period.

Individual series support BIMETS-compatible year-period and date indexing, with immutable replacements through with_values():

gdp[[2020, 2]]          # 102.0
gdp["2020-04/2020-09"] # inclusive date range

revised_gdp = gdp.with_values([[2020, 2], [2020, 3]], [103, 106])

The time-series tutorial covers calendar inspection, cumulative ranges, conversion, tabular display, and CSV exchange.

Operations of BimetsSeries are available as functions and, where natural, as methods:

from bimets import tsdeltap

functional = tsdeltap(gdp, lag=1)
method = gdp.delta_percent(lag=1)

Compatible BIMETS R function names are also exported with their original, case-sensitive spelling. Most are uppercase; date2yp and normalizeYP retain their mixed-case names as in the R implementation. These aliases reference the canonical Python functions and retain their Python signatures. See the public API inventory for the complete alias mapping and the time-series API reference for constructor, function, and method signatures.

A small MDL model can be parsed and simulated directly:

from bimets import BimetsModel, simulate, timeseries

model = BimetsModel.from_text(
    """MODEL
IDENTITY> y
EQ> y = x + 0.5 * TSLAG(y)
END""",
    name="dynamic-example",
)
data = {
    # The 1999 observation supplies the initial value for TSLAG(y).
    "y": timeseries([0, 0, 0, 0], start=(1999, 1)),
    "x": timeseries([1, 1, 1], start=(2000, 1)),
}

result = simulate(
    model,
    data,
    coefficients={},
    time_range=(2000, 1, 2002, 1),
)
result["y"].values.tolist()
# [1.0, 1.5, 1.75]

Documentation

Topic Documentation
Index of detailed documentation Documentation
All tutorials Tutorial index
Time-series construction, access, and indexing Time-series tutorial
Time-series manipulation Manipulating time series
MDL, estimation, and simulation guides MDL · Estimation · Simulation
API documentation API reference
Public symbols and R aliases API inventory
Conceptual and API differences from R Migration from BIMETS R
Solver architecture, vectorization, and multiprocessing Solver strategies
Compatibility and numerical validation Conformance page
Reproducible public examples examples/

Origin, copyright, and license

This project is a Python port of BIMETS, originally developed by Andrea Luciani and Roberto Stok. The original BIMETS package is copyright 2021–2031 Bank of Italy and is distributed under the GNU General Public License, version 3 or later.

The port is based on BIMETS 4.1.2. It includes adaptations of concepts, interfaces, documentation examples, test cases, and model definitions from the original package, together with a new Python implementation. Copyright in original or adapted material remains with its respective holders; copyright in new contributions remains with the respective contributors unless otherwise agreed.

The complete Python distribution is licensed under the GNU General Public License, version 3 or later. See NOTICE for the full attribution and modification notice.

The names BIMETS and Bank of Italy are used for attribution and identification of compatibility. This project does not imply endorsement by the original authors or by Bank of Italy.

Download files

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

Source Distribution

bimets-1.0.0.tar.gz (2.1 MB view details)

Uploaded Source

Built Distribution

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

bimets-1.0.0-py3-none-any.whl (159.2 kB view details)

Uploaded Python 3

File details

Details for the file bimets-1.0.0.tar.gz.

File metadata

  • Download URL: bimets-1.0.0.tar.gz
  • Upload date:
  • Size: 2.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for bimets-1.0.0.tar.gz
Algorithm Hash digest
SHA256 dd0fe3d5292179156732cd45bc55af7131469674d6cfe62d6c94a195f9bfa2ff
MD5 27efdfb52b7a12017a5b53500851c07e
BLAKE2b-256 766d98236fc00cd2543b3b5e1b327ad79cf7214591f6b6aa0aacdd2d85952b25

See more details on using hashes here.

File details

Details for the file bimets-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: bimets-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 159.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for bimets-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 82b8b5983801d9b8931331fd5be5567a48044efa145485ed94077d4fe16c4989
MD5 171fd9d02b9debbba923f1e01e84db75
BLAKE2b-256 5f1eb396a316e43064c9bab482c51c999bb22b9dc8cb105aa1a5f117f8e416b2

See more details on using hashes here.

Release history Release notifications | RSS feed

1.0.1

2 files

This release

1.0.0 This release

2 files

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