multiple_inference.bayes.nonparametric#
Nonparametric empirical Bayes.
References
@article{cai2021nonparametric,
title={Nonparametric empirical bayes estimation and testing for sparse and heteroscedastic signals},
author={Cai, Junhui and Han, Xu and Ritov, Ya'acov and Zhao, Linda},
journal={arXiv preprint arXiv:2106.08881},
year={2021}
}
Notes
This implementation is based on Cai et al.’s nonparametric Dirac delta prior. Future work should also implement their mixture model with a Laplace prior.
Classes
|
Bayesian model with a nonparametric Dirac delta prior. |
- class multiple_inference.bayes.nonparametric.Nonparametric(*args: Any, num: int = 100, n_clusters: int = 1, cv=5, rtol: float = 0.99, max_iter: int = 100, bandwidth_rvs_size: int = 32, **kwargs: Any)[source]#
Bayesian model with a nonparametric Dirac delta prior.
- Parameters
num (int, optional) – Number of parameters to fit for the prior. Defaults to 100.
n_clusters (int, optional) – Number of clusters to use for featurized estimation. Defaults to 1.
cv (int, optional) – Determines the cross validation splitting strategy (input to
sklearn.model_selection.check_cv). Defaults to 5.rtol (float, optional) – Relative tolerance stopping criteria for expectation maximization. The EM algorithm terminates when the relative improvement between iterations falls below this threshold. Defaults to .99.
max_iter (int, optional) – Maximum number of EM iterations. Defaults to 100.
bandwidth_rvs_size (int, optional) – Number of bandwidth values to try when tuning the kernel density estimator in between EM iterations to smooth the prior. Defaults to 32.
Examples
import numpy as np from multiple_inference.bayes import Nonparametric np.random.seed(0) model = Nonparametric(np.arange(10), np.identity(10)) results = model.fit() print(results.summary())
Bayesian estimates ======================================= coef pvalue (1-sided) [0.025 0.975] --------------------------------------- x0 0.686 0.197 -0.594 2.148 x1 1.226 0.062 -0.189 2.965 x2 1.977 0.011 0.304 3.982 x3 2.982 0.001 0.991 4.941 x4 3.990 0.000 1.960 5.892 x5 4.943 0.000 3.050 7.061 x6 6.036 0.000 3.989 8.037 x7 7.063 0.000 5.024 8.673 x8 7.768 0.000 6.089 9.123 x9 8.264 0.000 6.862 9.506 =============== Dep. Variable y ---------------