Skip to main content

Covariate moderated EBNM

Project description

como (Covariate moderated EBNM)

Python implimentation of various covariate moderated EBNM

Problem set-up

$$ \begin{align} \hat\beta \sim N(\beta, s^2) \ \beta \sim \pi_0(x) f_0 + \pi_1(x) f_1 \ \log \frac{\pi_1(x)}{\pi_0(x)} = {\bf \beta}^T {\bf x} \end{align} $$

  1. A logistic regression model $\log \frac{\pi_1({\bf x})}{\pi_0({\bf x})} = {\bf b}^T {\bf x}$
  2. A null component distribution $f_0$
  3. A alternative component distribution $f_1$

TwoComponentCoMo

TwoComponentCoMo is an abstract class that encapsulates the logic for fitting two component covariate moderated EBNM. It's constructor requires a dictionary

  1. data a dictionary
  2. f0 and f1 two ComponentDistribution object (described below)
  3. logreg a LogisticRegression object (described below)

ComponentDistribution

We've implmented a few options for $f_0$ and $f_1$ that can be flexibly recombined. ComponentDistribution

  1. convolved_log_pdf(self, beta, se): compute $\log p(\hat\beta | s^2) = \log \int N(\hat\beta | \beta, s^2) f(\beta) d\beta$
  2. update(self, data): update the parameters of ComponentDistribution using data. Importantly, in practice this function should weight our observations according to the assignment probabilities.

So far we've implimented the following component distributions:

  1. PointMassComponent: a point mass, usual choice for $f_0$
  2. NormalFixedLocComponent: a normal distribution with fixed location parameter (default loc=0)-- we estimate the scale parameter
  3. UnimodalNormalMixtureComponent: a scale mixture of normals, we estimate the mixture distribution $\pi$

LogisticRegression

LogisticRegression.predict(): return (expected) predicted log odds given current parameter estimates LogisticRegression.evidence(): compute the log likelihood or lower bound for current parameter estimates LogisticRegression.update(): update the logistic regression, accounting for the current assignment probabilities

So far we've implimented the following classes inheriting LogisticRegression:

  1. LogisticSuSiE: log odds are modeled with a sparse regression $\beta^T x$ where $\beta$ has the sum of single effects prior.
  2. InterceptOnly: ignore the covariates, just estimate a constant mixture proprotion for all observations

Putting it all together

We can easily specify a new two component model, inheriting from the base TwoComponentCoMo class

class PointNormalSuSiE(TwoComponentCoMo):
    def __init__(self, data, scale=1.0):
        """
        Initialize Point Normal SuSiE
        (Covariatiate EBNM with "point-normal" effects,
        and SuSiE prior on the mixture proportion)

        Parameters:
            data: dictionary with keys
                'beta' and 'se' for observations and standard errors,
                'X' and 'Z' for annotations and (fixed) covariates resp.
            scale: (initial) scale parameter for the normal mixture component
        """
        f0 = PointMassComponent(0.0)
        f1 = NormalFixedLocComponent(0, scale)
        
        # TODO: make sure `y` is a key in data, otherwise make it
        logreg = LogisticSusie(data, L=10)
        super().__init__(data, f0, f1, logreg)

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

como-ebnm-0.0.13.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

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

como_ebnm-0.0.13-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file como-ebnm-0.0.13.tar.gz.

File metadata

  • Download URL: como-ebnm-0.0.13.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.3

File hashes

Hashes for como-ebnm-0.0.13.tar.gz
Algorithm Hash digest
SHA256 6e0cc10be9e41c6b7cadb2c721d5471b80a9e5291a6cf377b7ba79363f3bd064
MD5 16e168b9d1d9e003b19a731f2b51ffd6
BLAKE2b-256 bab51c8e7f4baabd2b6dae0c87f970832fa4cf79a8ef33c4533e248be33d828f

See more details on using hashes here.

File details

Details for the file como_ebnm-0.0.13-py3-none-any.whl.

File metadata

  • Download URL: como_ebnm-0.0.13-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.3

File hashes

Hashes for como_ebnm-0.0.13-py3-none-any.whl
Algorithm Hash digest
SHA256 92e720aee5e71b9d94e0f45911b68386d425258b7612b883c328f72810aa13ef
MD5 fc9ba1baf86dccf2424befcaade244a3
BLAKE2b-256 f5708eb275067c4ea153919b9fbd1fcb09013b3811d0682a0d3ca45711f7f2fa

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