Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Quantile Regression with Constrained Splines

Python 3.9+ PyPI version DOI License: GPL v3 Documentation Documentation EN

Code style: black Python R

Python implementation of quantile regression with constrained splines (degrees 1-4). Degrees 1-3 are based on the article "Quantile regression with cubic splines under shape constraints" by Alexandre Abbes, while degree 4 is a natural consequence of the cited references.

The R version features have been now updated to match the level of this python package and is complemented with a graphical frontent.

Associated packages

Package Langage Description Lien
BsplineQuantReg R R version of this package. CRAN
Contraints splines deg 1-4,
self-contained
BsplineQuantRegGui R contraints splines deg 1-4, self-contained GITHUB
cobs R Constrained B-Splines (linear and quadratic) CRAN
quantreg R Quantile Regression CRAN
quantreg Python Quantile Regression statmodels or PyPI
Ce package Python Splines de degrés 1 à 4 contraintes GitHub

Comparison of packages

Fonctionnality cobs (R) BsplineQuantReg (R) (+gui) BsplineQuantRegpy (Python)
Linear Splines
Quadratic Splines
Cubic Splines
Quartic Splines
Contraints at knots
Over the whole interval
Region constraints
Third derivative
Gui
Self-contained for Bsplines ❌ (utilise SciPy)

## Features

-  Quantile regression with splines of degree 1 to 4
-  Constraints on derivatives (monotonicity, convexity, third derivative)
-  Constraints valid over the entire interval or selected regions
-  Multiple solvers support (CLARABEL, ECOS, SCS, MOSEK)
-  Graphical interface for interactive testing (Tkinter)
-  Export python executabe code to reproduce the analysis


##  Installation

### Python

```bash
# From PyPI
pip install BsplineQuantRegpy

# Or from source
git clone https://github.com/alexandreabbes/BsplineQuantRegpy.git
cd BsplineQuantRegpy
pip install -e .

R

# From CRAN
install.packages("BsplineQuantReg")

Links

File Structure

Graphical Interface

  • Quant_reg_tk.py - Tkinter GUI for interactive parameter testing (spline degree, knots, derivative constraints)

Main Algorithms

File Description
SplineCubicQuant.py Cubic splines with constraints on 1st, 2nd, and 3rd derivatives
SplineQuarticQuant.py Quartic splines with exact constraints over the entire interval
SplineQuadraticQuant.py Quadratic splines with constraints on 1st and 2nd derivatives
SplineLinearQuant.py Linear splines with constraints on 1st derivative '
quantile_spline.py Unified function for regresion with any degree 1-4 and constraints

Examples and Data

  • example_temerature.py - Replication of the test on global warming (temperatures , data in temp.xls)
  • examples/ - Additional usage examples

Quick Start

(be carrefull with the capital letter in the name)

from BsplineQuanRegpy import SplineCubicQuantile
import numpy as np
Quickstart
Quickstart2

Or launch the GUI:

```python
from BsplineQuantRegpy import run_gui
run_gui()

Prerequisites

Python

pip install numpy scipy pandas matplotlib cvxpy

``

Citation

If you use this code in your research, please cite:

@article{abbes2025quantile,
  title={Quantile regression with cubic polynomial splines under shape constraints with applications},
  author={Abbes, Alexandre},
  year={2025},
  doi={10.5281/zenodo.17427913}
}


## Contributions

Contributions are welcome! Feel free to:

- Open an [issue](https://github.com/alexandreabbes/BsplineQuantRegpy/issues)
- Suggest improvements

## License

This project is licensed under the GPL-v3 License - see the [LICENSE](LICENSE) file for details.

## AI Assistance

This project was carried out with the assistance of **DeepSeek** ([https://deepseek.com/](https://deepseek.com/)), which helped the developer with:
- Implementing constrained spline algorithms from MATLAB to Python
- Translating mathematical concepts into Python code
- Structuring programs and documentation

DeepSeek is a language model developed by 深度求索 [1].

[1] DeepSeek-AI. (2024). DeepSeek-V3 Technical Report. arXiv:2412.19437.

## References

- Abbes, A. (2025). Quantile regression with cubic polynomial splines under shape constraints with applications. doi:10.5281/zenodo.17427913
- He, X., & Shi, P. (1998). Monotone B-spline smoothing. *Journal of the American Statistical Association*, 93(442), 643-650.
- Karlin, S., & Studden, W.J. (1966). *Tchebycheff Systems: With Applications in Analysis and Statistics*. Interscience Publishers.
- Papp, D., & Alizadeh, F. (2014). Shape-Constrained Estimation Using Nonnegative Splines. *Journal of Computational and Graphical Statistics*, 23(1), 211-231.


## Contact

**Author**: Alexandre Abbes
**Email**: alexandre-dot-abbes-at-proton-dot-me
**GitHub**: [alexandreabbes](https://github.com/alexandreabbes)

Download files

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

Source Distribution

bsplinequantregpy-1.0.5a0.tar.gz (523.3 kB view details)

Uploaded Source

Built Distribution

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

bsplinequantregpy-1.0.5a0-py3-none-any.whl (536.6 kB view details)

Uploaded Python 3

File details

Details for the file bsplinequantregpy-1.0.5a0.tar.gz.

File metadata

  • Download URL: bsplinequantregpy-1.0.5a0.tar.gz
  • Upload date:
  • Size: 523.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for bsplinequantregpy-1.0.5a0.tar.gz
Algorithm Hash digest
SHA256 d609b88980ef8df8b777d1ec2c2b852c94c338ef15f4452eecf6b4b1445b6df2
MD5 9be5d9218ad8f2a4f2b8ee411a5963f5
BLAKE2b-256 08347abc45ebbe8f9ff4e73af0608528daa7d55ddc1d75faf1c817e429f6a315

See more details on using hashes here.

File details

Details for the file bsplinequantregpy-1.0.5a0-py3-none-any.whl.

File metadata

File hashes

Hashes for bsplinequantregpy-1.0.5a0-py3-none-any.whl
Algorithm Hash digest
SHA256 36a6eb3e93963e574814735497c16b9b3a28b542c15d6ab2c6b4f35bb8e84020
MD5 53dd20aa896af3c7594280159ceddb89
BLAKE2b-256 ee6576b7f29b253d44524f957f6270350c710a57aa795e7b23d29c73627884c3

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.5a0 This release

2 files

1.0.4

2 files

1.0.1

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