Skip to main content

Structural-break detection in high-dimensional factor models using QML methods.

Project description

fmbqml: Structural Break Analysis in High-Dimensional Factor Models

Python PyPI version License: MIT

fmbqml is a Python package for quasi-maximum-likelihood analysis of structural breaks in high-dimensional factor models. It provides tools for single-break testing and estimation, joint multiple-break estimation, sup-LR testing, factor-number selection, break-type classification, and diagnostic plots.

Links

Installation

Install the package from PyPI with:

python -m pip install fmbqml

For development from a source checkout, use:

python -m pip install -e .

Input data

The input data should be a finite two-dimensional NumPy array or pandas DataFrame with observations in rows and variables in columns. Missing values should be imputed before constructing a model.

Single-break analysis

Assuming that panel_data contains the input panel dataset:

from fmbqml import SingleBreakQML

model = SingleBreakQML(
    panel_data,
    trim_ratio=0.15,
    max_factors=10,
    factor_criterion="IC2",
)

result = model.lr_test(
    alpha=0.05,
    classify=True,
    n_sim=5000,
    random_state=12345,
)

print(result["reject_null"])
print(result["break_point"])
print(result.get("break_type"))

Use estimate_breakpoint() when a break is assumed to exist and significance testing is not required. In lr_test(), break_point is returned when the no-break null is rejected, while estimated_break_candidate records the profile optimizer.

Multiple-break analysis

from fmbqml import MultiBreakQML

model = MultiBreakQML(
    panel_data,
    max_break=5,
    max_factors=8,
    factor_criterion="IC2",
    trim_ratio=0.10,
)

result = model.estimate_breaks_jointly(
    min_break=0,
    classify=True,
)

print(result["n_breaks"])
print(result["breakpoints"])
print(result.get("break_types"))

The option min_break=0 permits selection of a no-break model. Use joint_sup_lr_test(n_breaks=...) to test no structural change against an exact number of breaks.

Factor-number selection

factor_criterion accepts IC1, IC2, IC3, PC1, PC2, PC3, AIC3, or BIC3. Integer indices 0 through 7 are also accepted in that order. The argument max_factors is a search bound and should be smaller than min(T, N).

Results and model state

Result dictionaries contain NumPy arrays for available profiles and nested structures for breakpoint classifications and information-criterion paths. For example, single-break procedures store candidate break locations together with LR or QML profile values, while multiple-break joint estimation stores the selected breakpoints and the information-criterion path used to choose the number of breaks.

Public result methods return independent copies of the cached results, so changing a returned object does not modify the model's internal state. Calling set_data() or set_parameters() validates the new values and clears previous estimates. Retrieve results with get_test_results(), get_joint_results(), or get_joint_test_results() after running the corresponding procedure.

Reproducibility

All stochastic procedures accept an explicit random seed. For reproducible critical values, pass random_state to lr_test(), joint_sup_lr_test(), and profile plotting routines that simulate critical values.

Example scripts demonstrating the main functionality of fmbqml are available in the project repository:

Dependencies

fmbqml depends on NumPy, SciPy, pandas, matplotlib, and joblib. Python 3.8 or newer is required.

License

fmbqml is distributed under the MIT License. See LICENSE.txt.

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

fmbqml-0.1.2.tar.gz (45.6 kB view details)

Uploaded Source

Built Distribution

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

fmbqml-0.1.2-py3-none-any.whl (55.4 kB view details)

Uploaded Python 3

File details

Details for the file fmbqml-0.1.2.tar.gz.

File metadata

  • Download URL: fmbqml-0.1.2.tar.gz
  • Upload date:
  • Size: 45.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for fmbqml-0.1.2.tar.gz
Algorithm Hash digest
SHA256 a8d17c046d6f6afed059ef116b1a0fc8fb0059f7e3625dde58164fe416dd7b3d
MD5 1dd5a09525f67079953af994ac2d9aec
BLAKE2b-256 9a34cb653b416396c70eeeb7c72bcfec20fd8bbbd7921b34ec9e4ae3289e61dc

See more details on using hashes here.

File details

Details for the file fmbqml-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: fmbqml-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 55.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for fmbqml-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c8f92eee1c96ede3b3790cad7b71d5c31c07fb846778f9922f42d2c1f8cd661d
MD5 d82e2c806f932ac45eaa5b90f78c0035
BLAKE2b-256 70d0dfcc893fae4f9837b90f76d359cc8da164fad75c20bdec252b4ff206a11e

See more details on using hashes here.

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