kernelmix 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. kernelmix-0.3.0/CHANGELOG.md +32 -0
  2. kernelmix-0.3.0/CITATION.cff +10 -0
  3. kernelmix-0.3.0/CONTRIBUTING.md +46 -0
  4. kernelmix-0.3.0/LICENSE +339 -0
  5. kernelmix-0.3.0/MANIFEST.in +5 -0
  6. kernelmix-0.3.0/NOTICE +23 -0
  7. kernelmix-0.3.0/PKG-INFO +102 -0
  8. kernelmix-0.3.0/README.md +73 -0
  9. kernelmix-0.3.0/docs/airquality.md +107 -0
  10. kernelmix-0.3.0/docs/api.md +313 -0
  11. kernelmix-0.3.0/docs/assets/mathjax-config.js +4 -0
  12. kernelmix-0.3.0/docs/assets/style.css +11 -0
  13. kernelmix-0.3.0/docs/citation.md +5 -0
  14. kernelmix-0.3.0/docs/data/airquality-provenance.json +180 -0
  15. kernelmix-0.3.0/docs/data/airquality.csv +154 -0
  16. kernelmix-0.3.0/docs/development.md +47 -0
  17. kernelmix-0.3.0/docs/faq.md +49 -0
  18. kernelmix-0.3.0/docs/figures/airquality.json +15 -0
  19. kernelmix-0.3.0/docs/figures/airquality.pdf +0 -0
  20. kernelmix-0.3.0/docs/figures/airquality.png +0 -0
  21. kernelmix-0.3.0/docs/figures/count-survival.csv +156 -0
  22. kernelmix-0.3.0/docs/figures/count-survival.pdf +0 -0
  23. kernelmix-0.3.0/docs/figures/count-survival.png +0 -0
  24. kernelmix-0.3.0/docs/figures/ozone-availability.csv +6 -0
  25. kernelmix-0.3.0/docs/figures/ozone-availability.json +114 -0
  26. kernelmix-0.3.0/docs/figures/ozone-availability.pdf +0 -0
  27. kernelmix-0.3.0/docs/figures/ozone-availability.png +0 -0
  28. kernelmix-0.3.0/docs/figures/ozone-diagnostics.json +108 -0
  29. kernelmix-0.3.0/docs/figures/ozone-diagnostics.pdf +0 -0
  30. kernelmix-0.3.0/docs/figures/ozone-diagnostics.png +0 -0
  31. kernelmix-0.3.0/docs/figures/ozone-observed.csv +112 -0
  32. kernelmix-0.3.0/docs/figures/ozone-observed.json +97 -0
  33. kernelmix-0.3.0/docs/figures/ozone-observed.pdf +0 -0
  34. kernelmix-0.3.0/docs/figures/ozone-observed.png +0 -0
  35. kernelmix-0.3.0/docs/figures/ozone-parameters.json +104 -0
  36. kernelmix-0.3.0/docs/figures/ozone-parameters.pdf +0 -0
  37. kernelmix-0.3.0/docs/figures/ozone-parameters.png +0 -0
  38. kernelmix-0.3.0/docs/figures/ozone-support.json +129 -0
  39. kernelmix-0.3.0/docs/figures/ozone-support.pdf +0 -0
  40. kernelmix-0.3.0/docs/figures/ozone-support.png +0 -0
  41. kernelmix-0.3.0/docs/figures/response.csv +26 -0
  42. kernelmix-0.3.0/docs/figures/response.pdf +0 -0
  43. kernelmix-0.3.0/docs/figures/response.png +0 -0
  44. kernelmix-0.3.0/docs/hooks.py +121 -0
  45. kernelmix-0.3.0/docs/installation.md +19 -0
  46. kernelmix-0.3.0/docs/manual.md +7 -0
  47. kernelmix-0.3.0/docs/manual.pdf +0 -0
  48. kernelmix-0.3.0/docs/methods.md +227 -0
  49. kernelmix-0.3.0/docs/reproduction.md +56 -0
  50. kernelmix-0.3.0/docs/results/airquality/curves.csv +60 -0
  51. kernelmix-0.3.0/docs/results/airquality/diagnostics.csv +11 -0
  52. kernelmix-0.3.0/docs/results/airquality/observations.csv +112 -0
  53. kernelmix-0.3.0/docs/results/airquality/parameters.csv +11 -0
  54. kernelmix-0.3.0/docs/results/airquality/results.json +263 -0
  55. kernelmix-0.3.0/docs/results/posterior-checks.json +3732 -0
  56. kernelmix-0.3.0/docs/structured.md +276 -0
  57. kernelmix-0.3.0/docs/tutorial.md +221 -0
  58. kernelmix-0.3.0/mkdocs.yml +44 -0
  59. kernelmix-0.3.0/pyproject.toml +37 -0
  60. kernelmix-0.3.0/setup.cfg +4 -0
  61. kernelmix-0.3.0/src/kernelmix/__init__.py +36 -0
  62. kernelmix-0.3.0/src/kernelmix/_basis.py +299 -0
  63. kernelmix-0.3.0/src/kernelmix/_clusters.py +78 -0
  64. kernelmix-0.3.0/src/kernelmix/_generalized.py +488 -0
  65. kernelmix-0.3.0/src/kernelmix/_input.py +120 -0
  66. kernelmix-0.3.0/src/kernelmix/_kernel.py +132 -0
  67. kernelmix-0.3.0/src/kernelmix/_likelihoods.py +151 -0
  68. kernelmix-0.3.0/src/kernelmix/_prediction.py +43 -0
  69. kernelmix-0.3.0/src/kernelmix/_structure.py +326 -0
  70. kernelmix-0.3.0/src/kernelmix/_structured.py +886 -0
  71. kernelmix-0.3.0/src/kernelmix/_survival.py +358 -0
  72. kernelmix-0.3.0/src/kernelmix/diagnostics.py +77 -0
  73. kernelmix-0.3.0/src/kernelmix/effects.py +332 -0
  74. kernelmix-0.3.0/src/kernelmix/model.py +677 -0
  75. kernelmix-0.3.0/src/kernelmix/plots.py +205 -0
  76. kernelmix-0.3.0/src/kernelmix/priors.py +100 -0
  77. kernelmix-0.3.0/src/kernelmix/result.py +785 -0
  78. kernelmix-0.3.0/src/kernelmix/structured_result.py +1054 -0
  79. kernelmix-0.3.0/src/kernelmix.egg-info/PKG-INFO +102 -0
  80. kernelmix-0.3.0/src/kernelmix.egg-info/SOURCES.txt +113 -0
  81. kernelmix-0.3.0/src/kernelmix.egg-info/dependency_links.txt +1 -0
  82. kernelmix-0.3.0/src/kernelmix.egg-info/requires.txt +17 -0
  83. kernelmix-0.3.0/src/kernelmix.egg-info/top_level.txt +1 -0
  84. kernelmix-0.3.0/tests/fixtures/r_cluster_reference.json +321 -0
  85. kernelmix-0.3.0/tests/fixtures/r_reference.json +367 -0
  86. kernelmix-0.3.0/tests/test_analysis_data.py +39 -0
  87. kernelmix-0.3.0/tests/test_basis_structure.py +407 -0
  88. kernelmix-0.3.0/tests/test_clusters.py +269 -0
  89. kernelmix-0.3.0/tests/test_effects_plots.py +433 -0
  90. kernelmix-0.3.0/tests/test_extension_posteriors.py +125 -0
  91. kernelmix-0.3.0/tests/test_generalized.py +337 -0
  92. kernelmix-0.3.0/tests/test_generalized_targets.py +170 -0
  93. kernelmix-0.3.0/tests/test_inputs_priors.py +245 -0
  94. kernelmix-0.3.0/tests/test_posterior_comparison.py +104 -0
  95. kernelmix-0.3.0/tests/test_posterior_target.py +61 -0
  96. kernelmix-0.3.0/tests/test_prediction_extension.py +155 -0
  97. kernelmix-0.3.0/tests/test_publication_guard.py +40 -0
  98. kernelmix-0.3.0/tests/test_reference.py +103 -0
  99. kernelmix-0.3.0/tests/test_results_diagnostics.py +208 -0
  100. kernelmix-0.3.0/tests/test_sampler.py +235 -0
  101. kernelmix-0.3.0/tests/test_structured_models.py +429 -0
  102. kernelmix-0.3.0/tests/test_structured_targets.py +90 -0
  103. kernelmix-0.3.0/tests/test_survival_extended.py +290 -0
  104. kernelmix-0.3.0/tools/analyze_airquality.py +138 -0
  105. kernelmix-0.3.0/tools/build_manual.py +87 -0
  106. kernelmix-0.3.0/tools/check_extension_posteriors.py +276 -0
  107. kernelmix-0.3.0/tools/check_public.py +74 -0
  108. kernelmix-0.3.0/tools/check_r_continuation.R +36 -0
  109. kernelmix-0.3.0/tools/check_r_posteriors.py +221 -0
  110. kernelmix-0.3.0/tools/export_airquality.R +5 -0
  111. kernelmix-0.3.0/tools/export_cluster_reference.R +60 -0
  112. kernelmix-0.3.0/tools/export_fitted_reference.R +90 -0
  113. kernelmix-0.3.0/tools/export_reference.R +57 -0
  114. kernelmix-0.3.0/tools/plot_airquality.py +79 -0
  115. kernelmix-0.3.0/tools/plot_airquality_details.py +359 -0
@@ -0,0 +1,32 @@
1
+ # Changelog
2
+
3
+ ## Unreleased
4
+
5
+ - Add reproducible fitted-posterior comparisons with R and independent extension checks.
6
+ - Add searchable documentation with grouped API pages and common questions.
7
+
8
+ - Clarify model support, priors and notation; connect the guides and reference manual around analysis tasks.
9
+ - Add a reproducible public-data ozone example, saved results and residual plots.
10
+ - Document original-study gaps and platform verification limits.
11
+
12
+ ## 0.3.0
13
+
14
+ - Matérn 3/2 and rational-quadratic kernels; predictive-process and random-Fourier GP bases.
15
+ - Random slopes with full covariance; Gaussian AR1, exponential and fixed residual correlations.
16
+ - Gaussian log-linear residual variance and variance prediction.
17
+ - Delayed entry, competing causes, piecewise-constant predictor histories and left/interval-censored survival.
18
+ - Cause-specific contrasts, cumulative incidence, path prediction and portable structured results.
19
+
20
+ ## 0.2.0
21
+
22
+ - Poisson and NB2 count models with log observation-exposure offsets.
23
+ - Right-censored proportional hazards with a piecewise-exponential baseline.
24
+ - Gaussian random intercepts, known/new-cluster prediction and intercept summaries.
25
+ - Survival/hazard predictions and plots; independent likelihood and posterior checks.
26
+
27
+ ## 0.1.0
28
+
29
+ - Gaussian and probit BKMR with component or grouped exposure selection.
30
+ - Joint predictions, exposure contrasts, diagnostics and non-pickle persistence.
31
+ - Response, surface, inclusion and trace plots.
32
+ - Fixed-state R comparisons and small independently integrated posterior checks.
@@ -0,0 +1,10 @@
1
+ cff-version: 1.2.0
2
+ message: "Please cite KernelMix and the method papers listed in the README."
3
+ title: "KernelMix: Bayesian kernel machine regression for exposure mixtures"
4
+ type: software
5
+ version: 0.3.0
6
+ authors:
7
+ - family-names: Chapagain
8
+ given-names: Nilson
9
+ repository-code: "https://github.com/nilson01/kernelmix"
10
+ license: GPL-2.0-only
@@ -0,0 +1,46 @@
1
+ # Contributing
2
+
3
+ Report bugs with a small example, package/dependency versions, the full error and
4
+ the expected behavior. Remove confidential data before sharing an example.
5
+
6
+ For a source checkout:
7
+
8
+ ```sh
9
+ python -m pip install -e ".[dev]"
10
+ python -m pytest
11
+ python -m ruff check src tests tools
12
+ ```
13
+
14
+ Include a regression test for a corrected defect. Method changes need an independent mathematical or numerical check and updated documentation. Software comparisons must state input transformations, priors and effect scales. Record example-data sources and licenses; exclude confidential data, fitted archives, credentials and local build files.
15
+
16
+ ## Build documentation
17
+
18
+ The maintained sources are the README and Markdown guides in `docs`.
19
+
20
+ Install the optional documentation tools:
21
+
22
+ ```sh
23
+ python -m pip install ".[docs]"
24
+ python -m mkdocs build --strict
25
+ ```
26
+
27
+ The static website is written to `site/`. This command builds files locally; it does not deploy them. The site groups the maintained API chapter by task, adds search and renders equations with MathJax. Browser equation rendering requires access to the pinned MathJax CDN resource.
28
+
29
+ To rebuild `docs/manual.pdf`, install a local `pdflatex` distribution, then run:
30
+
31
+ ```sh
32
+ python tools/build_manual.py
33
+ ```
34
+
35
+ Pandoc and LaTeX build the PDF; intermediate TeX is temporary. Inspect the resulting website and PDF after content changes, including links, equations, figures and page layout. Keep numerical evidence synchronized with the checks that actually ran.
36
+
37
+
38
+ ## Refresh the source example data
39
+
40
+ The ozone source CSV was exported from R 4.5.0. To export another copy for a documented comparison:
41
+
42
+ ```sh
43
+ Rscript tools/export_airquality.R destination.csv
44
+ ```
45
+
46
+ Keep the source version, license, hash, units and row exclusions with any replacement. When source data change, regenerate affected results and record the new version.
@@ -0,0 +1,339 @@
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+ Preamble
10
+
11
+ The licenses for most software are designed to take away your
12
+ freedom to share and change it. By contrast, the GNU General Public
13
+ License is intended to guarantee your freedom to share and change free
14
+ software--to make sure the software is free for all its users. This
15
+ General Public License applies to most of the Free Software
16
+ Foundation's software and to any other program whose authors commit to
17
+ using it. (Some other Free Software Foundation software is covered by
18
+ the GNU Lesser General Public License instead.) You can apply it to
19
+ your programs, too.
20
+
21
+ When we speak of free software, we are referring to freedom, not
22
+ price. Our General Public Licenses are designed to make sure that you
23
+ have the freedom to distribute copies of free software (and charge for
24
+ this service if you wish), that you receive source code or can get it
25
+ if you want it, that you can change the software or use pieces of it
26
+ in new free programs; and that you know you can do these things.
27
+
28
+ To protect your rights, we need to make restrictions that forbid
29
+ anyone to deny you these rights or to ask you to surrender the rights.
30
+ These restrictions translate to certain responsibilities for you if you
31
+ distribute copies of the software, or if you modify it.
32
+
33
+ For example, if you distribute copies of such a program, whether
34
+ gratis or for a fee, you must give the recipients all the rights that
35
+ you have. You must make sure that they, too, receive or can get the
36
+ source code. And you must show them these terms so they know their
37
+ rights.
38
+
39
+ We protect your rights with two steps: (1) copyright the software, and
40
+ (2) offer you this license which gives you legal permission to copy,
41
+ distribute and/or modify the software.
42
+
43
+ Also, for each author's protection and ours, we want to make certain
44
+ that everyone understands that there is no warranty for this free
45
+ software. If the software is modified by someone else and passed on, we
46
+ want its recipients to know that what they have is not the original, so
47
+ that any problems introduced by others will not reflect on the original
48
+ authors' reputations.
49
+
50
+ Finally, any free program is threatened constantly by software
51
+ patents. We wish to avoid the danger that redistributors of a free
52
+ program will individually obtain patent licenses, in effect making the
53
+ program proprietary. To prevent this, we have made it clear that any
54
+ patent must be licensed for everyone's free use or not licensed at all.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ GNU GENERAL PUBLIC LICENSE
60
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
+
62
+ 0. This License applies to any program or other work which contains
63
+ a notice placed by the copyright holder saying it may be distributed
64
+ under the terms of this General Public License. The "Program", below,
65
+ refers to any such program or work, and a "work based on the Program"
66
+ means either the Program or any derivative work under copyright law:
67
+ that is to say, a work containing the Program or a portion of it,
68
+ either verbatim or with modifications and/or translated into another
69
+ language. (Hereinafter, translation is included without limitation in
70
+ the term "modification".) Each licensee is addressed as "you".
71
+
72
+ Activities other than copying, distribution and modification are not
73
+ covered by this License; they are outside its scope. The act of
74
+ running the Program is not restricted, and the output from the Program
75
+ is covered only if its contents constitute a work based on the
76
+ Program (independent of having been made by running the Program).
77
+ Whether that is true depends on what the Program does.
78
+
79
+ 1. You may copy and distribute verbatim copies of the Program's
80
+ source code as you receive it, in any medium, provided that you
81
+ conspicuously and appropriately publish on each copy an appropriate
82
+ copyright notice and disclaimer of warranty; keep intact all the
83
+ notices that refer to this License and to the absence of any warranty;
84
+ and give any other recipients of the Program a copy of this License
85
+ along with the Program.
86
+
87
+ You may charge a fee for the physical act of transferring a copy, and
88
+ you may at your option offer warranty protection in exchange for a fee.
89
+
90
+ 2. You may modify your copy or copies of the Program or any portion
91
+ of it, thus forming a work based on the Program, and copy and
92
+ distribute such modifications or work under the terms of Section 1
93
+ above, provided that you also meet all of these conditions:
94
+
95
+ a) You must cause the modified files to carry prominent notices
96
+ stating that you changed the files and the date of any change.
97
+
98
+ b) You must cause any work that you distribute or publish, that in
99
+ whole or in part contains or is derived from the Program or any
100
+ part thereof, to be licensed as a whole at no charge to all third
101
+ parties under the terms of this License.
102
+
103
+ c) If the modified program normally reads commands interactively
104
+ when run, you must cause it, when started running for such
105
+ interactive use in the most ordinary way, to print or display an
106
+ announcement including an appropriate copyright notice and a
107
+ notice that there is no warranty (or else, saying that you provide
108
+ a warranty) and that users may redistribute the program under
109
+ these conditions, and telling the user how to view a copy of this
110
+ License. (Exception: if the Program itself is interactive but
111
+ does not normally print such an announcement, your work based on
112
+ the Program is not required to print an announcement.)
113
+
114
+ These requirements apply to the modified work as a whole. If
115
+ identifiable sections of that work are not derived from the Program,
116
+ and can be reasonably considered independent and separate works in
117
+ themselves, then this License, and its terms, do not apply to those
118
+ sections when you distribute them as separate works. But when you
119
+ distribute the same sections as part of a whole which is a work based
120
+ on the Program, the distribution of the whole must be on the terms of
121
+ this License, whose permissions for other licensees extend to the
122
+ entire whole, and thus to each and every part regardless of who wrote it.
123
+
124
+ Thus, it is not the intent of this section to claim rights or contest
125
+ your rights to work written entirely by you; rather, the intent is to
126
+ exercise the right to control the distribution of derivative or
127
+ collective works based on the Program.
128
+
129
+ In addition, mere aggregation of another work not based on the Program
130
+ with the Program (or with a work based on the Program) on a volume of
131
+ a storage or distribution medium does not bring the other work under
132
+ the scope of this License.
133
+
134
+ 3. You may copy and distribute the Program (or a work based on it,
135
+ under Section 2) in object code or executable form under the terms of
136
+ Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+ a) Accompany it with the complete corresponding machine-readable
139
+ source code, which must be distributed under the terms of Sections
140
+ 1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+ b) Accompany it with a written offer, valid for at least three
143
+ years, to give any third party, for a charge no more than your
144
+ cost of physically performing source distribution, a complete
145
+ machine-readable copy of the corresponding source code, to be
146
+ distributed under the terms of Sections 1 and 2 above on a medium
147
+ customarily used for software interchange; or,
148
+
149
+ c) Accompany it with the information you received as to the offer
150
+ to distribute corresponding source code. (This alternative is
151
+ allowed only for noncommercial distribution and only if you
152
+ received the program in object code or executable form with such
153
+ an offer, in accord with Subsection b above.)
154
+
155
+ The source code for a work means the preferred form of the work for
156
+ making modifications to it. For an executable work, complete source
157
+ code means all the source code for all modules it contains, plus any
158
+ associated interface definition files, plus the scripts used to
159
+ control compilation and installation of the executable. However, as a
160
+ special exception, the source code distributed need not include
161
+ anything that is normally distributed (in either source or binary
162
+ form) with the major components (compiler, kernel, and so on) of the
163
+ operating system on which the executable runs, unless that component
164
+ itself accompanies the executable.
165
+
166
+ If distribution of executable or object code is made by offering
167
+ access to copy from a designated place, then offering equivalent
168
+ access to copy the source code from the same place counts as
169
+ distribution of the source code, even though third parties are not
170
+ compelled to copy the source along with the object code.
171
+
172
+ 4. You may not copy, modify, sublicense, or distribute the Program
173
+ except as expressly provided under this License. Any attempt
174
+ otherwise to copy, modify, sublicense or distribute the Program is
175
+ void, and will automatically terminate your rights under this License.
176
+ However, parties who have received copies, or rights, from you under
177
+ this License will not have their licenses terminated so long as such
178
+ parties remain in full compliance.
179
+
180
+ 5. You are not required to accept this License, since you have not
181
+ signed it. However, nothing else grants you permission to modify or
182
+ distribute the Program or its derivative works. These actions are
183
+ prohibited by law if you do not accept this License. Therefore, by
184
+ modifying or distributing the Program (or any work based on the
185
+ Program), you indicate your acceptance of this License to do so, and
186
+ all its terms and conditions for copying, distributing or modifying
187
+ the Program or works based on it.
188
+
189
+ 6. Each time you redistribute the Program (or any work based on the
190
+ Program), the recipient automatically receives a license from the
191
+ original licensor to copy, distribute or modify the Program subject to
192
+ these terms and conditions. You may not impose any further
193
+ restrictions on the recipients' exercise of the rights granted herein.
194
+ You are not responsible for enforcing compliance by third parties to
195
+ this License.
196
+
197
+ 7. If, as a consequence of a court judgment or allegation of patent
198
+ infringement or for any other reason (not limited to patent issues),
199
+ conditions are imposed on you (whether by court order, agreement or
200
+ otherwise) that contradict the conditions of this License, they do not
201
+ excuse you from the conditions of this License. If you cannot
202
+ distribute so as to satisfy simultaneously your obligations under this
203
+ License and any other pertinent obligations, then as a consequence you
204
+ may not distribute the Program at all. For example, if a patent
205
+ license would not permit royalty-free redistribution of the Program by
206
+ all those who receive copies directly or indirectly through you, then
207
+ the only way you could satisfy both it and this License would be to
208
+ refrain entirely from distribution of the Program.
209
+
210
+ If any portion of this section is held invalid or unenforceable under
211
+ any particular circumstance, the balance of the section is intended to
212
+ apply and the section as a whole is intended to apply in other
213
+ circumstances.
214
+
215
+ It is not the purpose of this section to induce you to infringe any
216
+ patents or other property right claims or to contest validity of any
217
+ such claims; this section has the sole purpose of protecting the
218
+ integrity of the free software distribution system, which is
219
+ implemented by public license practices. Many people have made
220
+ generous contributions to the wide range of software distributed
221
+ through that system in reliance on consistent application of that
222
+ system; it is up to the author/donor to decide if he or she is willing
223
+ to distribute software through any other system and a licensee cannot
224
+ impose that choice.
225
+
226
+ This section is intended to make thoroughly clear what is believed to
227
+ be a consequence of the rest of this License.
228
+
229
+ 8. If the distribution and/or use of the Program is restricted in
230
+ certain countries either by patents or by copyrighted interfaces, the
231
+ original copyright holder who places the Program under this License
232
+ may add an explicit geographical distribution limitation excluding
233
+ those countries, so that distribution is permitted only in or among
234
+ countries not thus excluded. In such case, this License incorporates
235
+ the limitation as if written in the body of this License.
236
+
237
+ 9. The Free Software Foundation may publish revised and/or new versions
238
+ of the General Public License from time to time. Such new versions will
239
+ be similar in spirit to the present version, but may differ in detail to
240
+ address new problems or concerns.
241
+
242
+ Each version is given a distinguishing version number. If the Program
243
+ specifies a version number of this License which applies to it and "any
244
+ later version", you have the option of following the terms and conditions
245
+ either of that version or of any later version published by the Free
246
+ Software Foundation. If the Program does not specify a version number of
247
+ this License, you may choose any version ever published by the Free Software
248
+ Foundation.
249
+
250
+ 10. If you wish to incorporate parts of the Program into other free
251
+ programs whose distribution conditions are different, write to the author
252
+ to ask for permission. For software which is copyrighted by the Free
253
+ Software Foundation, write to the Free Software Foundation; we sometimes
254
+ make exceptions for this. Our decision will be guided by the two goals
255
+ of preserving the free status of all derivatives of our free software and
256
+ of promoting the sharing and reuse of software generally.
257
+
258
+ NO WARRANTY
259
+
260
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+ REPAIR OR CORRECTION.
269
+
270
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+ POSSIBILITY OF SUCH DAMAGES.
279
+
280
+ END OF TERMS AND CONDITIONS
281
+
282
+ How to Apply These Terms to Your New Programs
283
+
284
+ If you develop a new program, and you want it to be of the greatest
285
+ possible use to the public, the best way to achieve this is to make it
286
+ free software which everyone can redistribute and change under these terms.
287
+
288
+ To do so, attach the following notices to the program. It is safest
289
+ to attach them to the start of each source file to most effectively
290
+ convey the exclusion of warranty; and each file should have at least
291
+ the "copyright" line and a pointer to where the full notice is found.
292
+
293
+ <one line to give the program's name and a brief idea of what it does.>
294
+ Copyright (C) <year> <name of author>
295
+
296
+ This program is free software; you can redistribute it and/or modify
297
+ it under the terms of the GNU General Public License as published by
298
+ the Free Software Foundation; either version 2 of the License, or
299
+ (at your option) any later version.
300
+
301
+ This program is distributed in the hope that it will be useful,
302
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
303
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304
+ GNU General Public License for more details.
305
+
306
+ You should have received a copy of the GNU General Public License along
307
+ with this program; if not, write to the Free Software Foundation, Inc.,
308
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309
+
310
+ Also add information on how to contact you by electronic and paper mail.
311
+
312
+ If the program is interactive, make it output a short notice like this
313
+ when it starts in an interactive mode:
314
+
315
+ Gnomovision version 69, Copyright (C) year name of author
316
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317
+ This is free software, and you are welcome to redistribute it
318
+ under certain conditions; type `show c' for details.
319
+
320
+ The hypothetical commands `show w' and `show c' should show the appropriate
321
+ parts of the General Public License. Of course, the commands you use may
322
+ be called something other than `show w' and `show c'; they could even be
323
+ mouse-clicks or menu items--whatever suits your program.
324
+
325
+ You should also get your employer (if you work as a programmer) or your
326
+ school, if any, to sign a "copyright disclaimer" for the program, if
327
+ necessary. Here is a sample; alter the names:
328
+
329
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
331
+
332
+ <signature of Ty Coon>, 1 April 1989
333
+ Ty Coon, President of Vice
334
+
335
+ This General Public License does not permit incorporating your program into
336
+ proprietary programs. If your program is a subroutine library, you may
337
+ consider it more useful to permit linking proprietary applications with the
338
+ library. If this is what you want to do, use the GNU Lesser General
339
+ Public License instead of this License.
@@ -0,0 +1,5 @@
1
+ include LICENSE NOTICE README.md CONTRIBUTING.md CHANGELOG.md CITATION.cff mkdocs.yml
2
+ recursive-include docs *.md *.pdf *.png *.csv *.json *.py *.js *.css
3
+ recursive-include tests *.py *.json
4
+ recursive-include tools *.py *.R
5
+ prune .github
kernelmix-0.3.0/NOTICE ADDED
@@ -0,0 +1,23 @@
1
+ KernelMix
2
+ Copyright (C) 2026 Nilson Chapagain
3
+
4
+ KernelMix implements selected Bayesian kernel machine regression methods described
5
+ by Bobb et al. (2015), DOI 10.1093/biostatistics/kxu058, and Bobb et al. (2018),
6
+ DOI 10.1186/s12940-018-0413-y.
7
+
8
+ The R package bkmr 0.2.2, by Jennifer F. Bobb and contributors, is a reference for
9
+ prior conventions, likelihoods and posterior summaries. Its GPL-2 source informed
10
+ this implementation. The installed package is used in optional reference checks.
11
+ KernelMix uses distinct Python code and sampling proposals. Count/survival
12
+ fitting uses elliptical slice sampling (Murray, Adams and MacKay, 2010,
13
+ https://proceedings.mlr.press/v9/murray10a.html). Standard count and survival
14
+ likelihood references and selected priors are identified in docs/methods.md.
15
+ The original authors have not endorsed this package. Source papers and their
16
+ figures are not bundled.
17
+
18
+ KernelMix code and documentation are distributed under GNU GPL version 2 only,
19
+ without warranty. See LICENSE. NumPy, SciPy and Matplotlib retain their own licenses.
20
+
21
+ Additional kernel definitions follow Rasmussen and Williams (2006), Gaussian Processes for Machine Learning, chapter 4. Random Fourier features follow Rahimi and Recht (2007). Predictive processes follow Banerjee et al. (2008), DOI 10.1111/j.1467-9868.2008.00663.x. Residual variance/correlation and survival data conventions are separately cited in the structured-model guide. These are model ingredients, not claims of new estimators or complete upstream interfaces.
22
+
23
+ The bundled airquality CSV is exported from R 4.5.0 datasets::airquality. The original measurements are credited to the New York State Department of Conservation and the National Weather Service; see Chambers et al. (1983), Graphical Methods for Data Analysis, and the R datasets documentation. This export and its test fixture are distributed under GPL-2.0 as part of this package.
@@ -0,0 +1,102 @@
1
+ Metadata-Version: 2.4
2
+ Name: kernelmix
3
+ Version: 0.3.0
4
+ Summary: Bayesian kernel machine regression for exposure mixtures
5
+ Author: Nilson Chapagain
6
+ License-Expression: GPL-2.0-only
7
+ Project-URL: Repository, https://github.com/nilson01/kernelmix
8
+ Project-URL: Issues, https://github.com/nilson01/kernelmix/issues
9
+ Project-URL: Documentation, https://nilson01.github.io/kernelmix/
10
+ Requires-Python: >=3.10
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ License-File: NOTICE
14
+ Requires-Dist: numpy>=1.24
15
+ Requires-Dist: scipy>=1.10
16
+ Provides-Extra: docs
17
+ Requires-Dist: pypandoc_binary>=1.15; extra == "docs"
18
+ Requires-Dist: mkdocs<2,>=1.6; extra == "docs"
19
+ Requires-Dist: pymdown-extensions<11,>=10; extra == "docs"
20
+ Provides-Extra: plots
21
+ Requires-Dist: matplotlib>=3.7; extra == "plots"
22
+ Provides-Extra: dev
23
+ Requires-Dist: pytest>=7.4; extra == "dev"
24
+ Requires-Dist: ruff>=0.9; extra == "dev"
25
+ Requires-Dist: build>=1.2; extra == "dev"
26
+ Requires-Dist: twine>=5; extra == "dev"
27
+ Requires-Dist: matplotlib>=3.7; extra == "dev"
28
+ Dynamic: license-file
29
+
30
+ # KernelMix
31
+
32
+ KernelMix fits Bayesian kernel machine regression (BKMR) for exposure mixtures in Python.
33
+ It models how an outcome varies with several exposures together, allowing curved associations and interactions between exposures. Other measured variables enter as linear adjustment terms.
34
+
35
+ To handle different outcome types, the package combines this exposure function with continuous, binary, count or survival models. NumPy and SciPy handle fitting and prediction; R is not required.
36
+
37
+ | Task | Start here |
38
+ | --- | --- |
39
+ | Choose an outcome model and priors | [Models and assumptions](docs/methods.md) |
40
+ | Fit, inspect, predict and compare exposures | [Analysis tutorial](docs/tutorial.md) |
41
+ | Model clusters, kernels or detailed survival records | [Structured models](docs/structured.md) |
42
+ | Find arguments and result fields | [API reference](docs/api.md) |
43
+ | Check numerical evidence and limitations | [Evidence](docs/reproduction.md) |
44
+
45
+ ## Install
46
+
47
+ Install directly from GitHub:
48
+
49
+ ```sh
50
+ python -m pip install "kernelmix[plots] @ git+https://github.com/nilson01/kernelmix.git@main"
51
+ ```
52
+
53
+ Or, from a downloaded source folder:
54
+
55
+ ```sh
56
+ python -m pip install ".[plots]"
57
+ ```
58
+
59
+ Python 3.10 or later is required. Omit `[plots]` if plots are not needed.
60
+
61
+ ## Example
62
+
63
+ ```python
64
+ import numpy as np
65
+ from kernelmix import fit, univariate_response, plot_response
66
+
67
+ rng = np.random.default_rng(17)
68
+ Z = rng.normal(size=(24, 2))
69
+ y = np.sin(Z[:, 0]) + 0.3 * Z[:, 1] + rng.normal(0, 0.5, 24)
70
+ result = fit(y, Z, draws=200, warmup=200, chains=2, seed=17)
71
+ print(result.summary())
72
+ curve = univariate_response(result, variable=0, points=25, seed=17)
73
+ ax = plot_response(curve)
74
+ ```
75
+
76
+ Example output (first rows):
77
+
78
+ ```text
79
+ BKMRFit(family='gaussian', n=24, exposures=2, chains=2, draws=200)
80
+ 95% pointwise credible intervals
81
+ Parameter Mean SD Lower Upper
82
+ lambda 16.93 9.047 4.145 38.61
83
+ sigma2 0.2159 0.08346 0.1142 0.4188
84
+ ```
85
+
86
+ These short chains illustrate the output and trigger mixing warnings. For an analysis, use longer runs and inspect agreement between chains and effective sample sizes, which account for dependence between draws.
87
+
88
+ ![Exposure response curve with pointwise 95% credible intervals](docs/figures/response.png)
89
+
90
+ The curve varies the first exposure with the second at its median, relative to the all-median exposure profile. It describes a fitted association; a causal interpretation requires additional assumptions.
91
+
92
+ ## Documentation
93
+
94
+ Browse the [searchable documentation](https://nilson01.github.io/kernelmix/).
95
+
96
+ The [common questions](docs/faq.md) explain prediction scales, missing values, selection and diagnostics. The [observed ozone example](docs/airquality.md) includes source data and saved results. Download the [reference manual](docs/manual.pdf) for offline reading. Contributors can find [development checks](docs/development.md) separately.
97
+
98
+ ## References and license
99
+
100
+ [Bobb et al. (2015)](https://doi.org/10.1093/biostatistics/kxu058) introduced BKMR for exposure-mixture analysis. [Bobb et al. (2018)](https://doi.org/10.1186/s12940-018-0413-y) described the R software and its binary-outcome extension. KernelMix implements these methods separately in Python and adds count and survival likelihoods, defined in the [model guide](docs/methods.md).
101
+
102
+ We compare selected Gaussian and probit posterior summaries and conditional calculations, including random intercepts, with installed R [`bkmr`](https://cran.r-project.org/package=bkmr) 0.2.2. The [evidence summary](docs/reproduction.md) records results and limits. See [NOTICE](NOTICE) for attribution and [LICENSE](LICENSE) for GPL-2.0-only terms.
@@ -0,0 +1,73 @@
1
+ # KernelMix
2
+
3
+ KernelMix fits Bayesian kernel machine regression (BKMR) for exposure mixtures in Python.
4
+ It models how an outcome varies with several exposures together, allowing curved associations and interactions between exposures. Other measured variables enter as linear adjustment terms.
5
+
6
+ To handle different outcome types, the package combines this exposure function with continuous, binary, count or survival models. NumPy and SciPy handle fitting and prediction; R is not required.
7
+
8
+ | Task | Start here |
9
+ | --- | --- |
10
+ | Choose an outcome model and priors | [Models and assumptions](docs/methods.md) |
11
+ | Fit, inspect, predict and compare exposures | [Analysis tutorial](docs/tutorial.md) |
12
+ | Model clusters, kernels or detailed survival records | [Structured models](docs/structured.md) |
13
+ | Find arguments and result fields | [API reference](docs/api.md) |
14
+ | Check numerical evidence and limitations | [Evidence](docs/reproduction.md) |
15
+
16
+ ## Install
17
+
18
+ Install directly from GitHub:
19
+
20
+ ```sh
21
+ python -m pip install "kernelmix[plots] @ git+https://github.com/nilson01/kernelmix.git@main"
22
+ ```
23
+
24
+ Or, from a downloaded source folder:
25
+
26
+ ```sh
27
+ python -m pip install ".[plots]"
28
+ ```
29
+
30
+ Python 3.10 or later is required. Omit `[plots]` if plots are not needed.
31
+
32
+ ## Example
33
+
34
+ ```python
35
+ import numpy as np
36
+ from kernelmix import fit, univariate_response, plot_response
37
+
38
+ rng = np.random.default_rng(17)
39
+ Z = rng.normal(size=(24, 2))
40
+ y = np.sin(Z[:, 0]) + 0.3 * Z[:, 1] + rng.normal(0, 0.5, 24)
41
+ result = fit(y, Z, draws=200, warmup=200, chains=2, seed=17)
42
+ print(result.summary())
43
+ curve = univariate_response(result, variable=0, points=25, seed=17)
44
+ ax = plot_response(curve)
45
+ ```
46
+
47
+ Example output (first rows):
48
+
49
+ ```text
50
+ BKMRFit(family='gaussian', n=24, exposures=2, chains=2, draws=200)
51
+ 95% pointwise credible intervals
52
+ Parameter Mean SD Lower Upper
53
+ lambda 16.93 9.047 4.145 38.61
54
+ sigma2 0.2159 0.08346 0.1142 0.4188
55
+ ```
56
+
57
+ These short chains illustrate the output and trigger mixing warnings. For an analysis, use longer runs and inspect agreement between chains and effective sample sizes, which account for dependence between draws.
58
+
59
+ ![Exposure response curve with pointwise 95% credible intervals](docs/figures/response.png)
60
+
61
+ The curve varies the first exposure with the second at its median, relative to the all-median exposure profile. It describes a fitted association; a causal interpretation requires additional assumptions.
62
+
63
+ ## Documentation
64
+
65
+ Browse the [searchable documentation](https://nilson01.github.io/kernelmix/).
66
+
67
+ The [common questions](docs/faq.md) explain prediction scales, missing values, selection and diagnostics. The [observed ozone example](docs/airquality.md) includes source data and saved results. Download the [reference manual](docs/manual.pdf) for offline reading. Contributors can find [development checks](docs/development.md) separately.
68
+
69
+ ## References and license
70
+
71
+ [Bobb et al. (2015)](https://doi.org/10.1093/biostatistics/kxu058) introduced BKMR for exposure-mixture analysis. [Bobb et al. (2018)](https://doi.org/10.1186/s12940-018-0413-y) described the R software and its binary-outcome extension. KernelMix implements these methods separately in Python and adds count and survival likelihoods, defined in the [model guide](docs/methods.md).
72
+
73
+ We compare selected Gaussian and probit posterior summaries and conditional calculations, including random intercepts, with installed R [`bkmr`](https://cran.r-project.org/package=bkmr) 0.2.2. The [evidence summary](docs/reproduction.md) records results and limits. See [NOTICE](NOTICE) for attribution and [LICENSE](LICENSE) for GPL-2.0-only terms.