Skip to main content

GitHub PyPI PyPI - Python Version

Introduction

Linear regression of the simple least-squares variety has been a canonical method used to characterize the relation between two variables, but its utility is limited by the fact that it reduces full population statistics down to three numbers: a slope, normalization and variance/standard deviation. With large empirical or simulated samples we can perform a more sensitive analysis using a localized linear regression method (see, Farahi et al. 2018 and Anbajagane et al. 2020). The KLLR method generates estimates of conditional statistics in terms of the local the slope, normalization, and covariance. Such a method provides a more nuanced description of population statistics appropriate for the very large samples with non-linear trends.

This code is an implementation of the Kernel Localized Linear Regression (KLLR) method that performs a localized Linear regression described in Farahi et al. (2018). It employs bootstrap re-sampling technique to estimate the uncertainties. We also provide a set of visualization tools so practitioners can seamlessly generate visualization of the model parameters.

If you use KLLR or derivates based on it, please cite the following papers which introduced the tool:

Localized massive halo properties in BAHAMAS and MACSIS simulations: scalings, lognormality, and covariance.

Stellar Property Statistics of Massive Halos from Cosmological Hydrodynamics Simulations: Common Kernel Shapes.

A list of other publications that employed KLLR in their data analysis.

D. Anbajagane, A. Evrard, A. Farahi, Baryonic Imprints on DM Halos: Population Statistics from Dwarf Galaxies to Galaxy Clusters, MNRAS, (2022).

D. Anbajagane et al., Galaxy Velocity Bias in Cosmological Simulations: Towards Percent-level Calibration, MNRAS, (2022).

A. Nachmann, W. K. Black, Intra-cluster Summed Galaxy Colors, arXiv preprint, (2021).

Dependencies

numpy, scipy, matplotlib, pandas, sklearn, tqdm

References

[1]. A. Farahi, et al. "Localized massive halo properties in BAHAMAS and MACSIS simulations: scalings, lognormality, and covariance." Monthly Notices of the Royal Astronomical Society 478.2 (2018): 2618-2632.

[2]. D. Anbajagane, et al. Stellar Property Statistics of Massive Halos from Cosmological Hydrodynamics Simulations: Common Kernel Shapes. No. arXiv: 2001.02283. 2020.

Acknowledgment

A.F. is supported by the University of Texas at Austin. D.A. is supported by the National Science Foundation Graduate Research Fellowship under Grant No. DGE 1746045.

Installation

Run the following to install:

pip install kllr

Quickstart

To start using KLLR, simply use from KLLR import kllr_model to access the primary functions and class. The exact requirements for the inputs are listed in the docstring of the kllr_model() class further below. An example for using KLLR looks like this:

    from kllr import kllr_model                                       

    lm = kllr_model(kernel_type = 'gaussian', kernel_width = 0.2)     
    xrange, yrange_mean, intercept, slope, scatter, skew, kurt = lm.fit(x, y, bins=11)                                   

Illustration

Illustration of the KLLR fit with varying kernel size.

Release files for kllr 2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kllr 2.0
File Size Uploaded
kllr-2.0.tar.gz 21.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for kllr 2.0
File Interpreter ABI Platform
kllr-2.0-py3-none-any.whl Python 3 none any Details

Total release size: 43.7 kB

Release files / kllr-2.0.tar.gz

Download URL kllr-2.0.tar.gz
Size 21.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e9c2a99233ccab0f4fffea12032d562f74c880ee037d1c921fd5caddd3df724b
BLAKE2b-256 checksum
How to use checksums
64630221b6da0455db8b5fd3f62207d59c0fece6476c2e813d0a29aa02fd216a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.25.1 requests-toolbelt/0.9.1 urllib3/1.26.4 tqdm/4.59.0 importlib-metadata/3.10.0 keyring/22.3.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.8

Release files / kllr-2.0-py3-none-any.whl

Download URL kllr-2.0-py3-none-any.whl
Size 21.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bfbfd062c66d13344afabd0a76cb2c28bc0a86abe3c37b9cb1e7507ac53f0744
BLAKE2b-256 checksum
How to use checksums
73fe3d01cc369df6db5ec1303d459a3ec8ca6cbd40b2eb1140b43ff49d121b7f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.25.1 requests-toolbelt/0.9.1 urllib3/1.26.4 tqdm/4.59.0 importlib-metadata/3.10.0 keyring/22.3.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.8

Release history Release notifications | RSS feed

This release

2.0 This release

2 release files

1.0.0

2 release 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