Skip to main content
ascl:1602.005 PyPi MIT

LRGS: Linear Regression by Gibbs Sampling

Code implementing a Gibbs sampler to deal with the problem of multivariate linear regression with uncertainties in all measured quantities and intrinsic scatter. Full details can be found in this paper (1509.00908), the abstract of which appears below. (The paper describes an implementation in the R language, while this package is a port of the method to Python.)

Kelly (2007, hereafter K07) described an efficient algorithm, using Gibbs sampling, for performing linear regression in the fairly general case where non-zero measurement errors exist for both the covariates and response variables, where these measurements may be correlated (for the same data point), where the response variable is affected by intrinsic scatter in addition to measurement error, and where the prior distribution of covariates is modeled by a flexible mixture of Gaussians rather than assumed to be uniform. Here I extend the K07 algorithm in two ways. First, the procedure is generalized to the case of multiple response variables. Second, I describe how to model the prior distribution of covariates using a Dirichlet process, which can be thought of as a Gaussian mixture where the number of mixture components is learned from the data. I present an example of multivariate regression using the extended algorithm, namely fitting scaling relations of the gas mass, temperature, and luminosity of dynamically relaxed galaxy clusters as a function of their mass and redshift. An implementation of the Gibbs sampler in the R language, called LRGS, is provided.

For questions, comments, requests, problems, etc. use the GitHub issues.

Status

LRGS for Python is currently in alpha. It has not been vetted for all possible combinations of univariate/multivariate covariates and responses. Some features of the R version are not implemented, in particular the Dirichlet process prior.

A submodule, lrgs.trunc, has been added to facilitate modeling of truncated data sets (see 1901.10522). This submodule depends on the external package LMC. It has no analog in the R version of LRGS.

See VERSION.md.

Installation

Automatic

Install from PyPI by running pip install lrgs. Note that PyPI may not have the latest version.

Manual

Download lrgs/ and put it somewhere on your PYTHONPATH. You will need to have the numpy and scipy packages installed.

Usage and Help

Documentation is sparse at this point, but an example notebook can be found here.

Metadata

Release files for lrgs 0.1.1

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

Source distribution (sdist)

Source distribution for lrgs 0.1.1
File Size Uploaded
lrgs-0.1.1.tar.gz 12.1 kB Details

Built distribution (wheel)

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

Total release size: 22.6 kB

Release files / lrgs-0.1.1.tar.gz

Download URL lrgs-0.1.1.tar.gz
Size 12.1 kB
Tags Source
SHA-256 checksum
How to use checksums
8a92b2accf2631512a474d0a4a9002322042e183b2d4691817a823ef1f1e6307
BLAKE2b-256 checksum
How to use checksums
8b490cc60e0dfd0abc53f9201f8a84f9e0cb583c22008f35c9cd6da70f928b69
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.1.2.post20210112 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.7.9

Release files / lrgs-0.1.1-py3-none-any.whl

Download URL lrgs-0.1.1-py3-none-any.whl
Size 10.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8a43c67dc84063bbbef801919da050f26fa6640bcd109c96c1bf23097d65490c
BLAKE2b-256 checksum
How to use checksums
0588625e9e33dddab90090ce726167ebc7ce8abe59277401cefa20f4bf65733c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.1.2.post20210112 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.7.9

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

0.0.2

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