haldensify
haldensify: Highly adaptive lasso conditional density estimation in R - Published in JOSS (2022)
Science Score: 95.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 13 DOI reference(s) in README and JOSS metadata -
✓Academic publication links
Links to: arxiv.org, joss.theoj.org, zenodo.org -
✓Committers with academic emails
1 of 3 committers (33.3%) from academic institutions -
○Institutional organization owner
-
✓JOSS paper metadata
Published in Journal of Open Source Software
Keywords
causal-inference
conditional-density-estimates
density-estimation
highly-adaptive-lasso
inverse-probability-weights
machine-learning
nonparametric-regression
propensity-score
Keywords from Contributors
cross-validation
lasso-regression
Scientific Fields
Engineering
Computer Science -
40% confidence
Last synced: 6 months ago
·
JSON representation
Repository
:package: R/haldensify: Highly Adaptive Lasso Conditional Density Estimation
Basic Info
- Host: GitHub
- Owner: nhejazi
- License: other
- Language: R
- Default Branch: master
- Homepage: https://codex.nimahejazi.org/haldensify
- Size: 8.64 MB
Statistics
- Stars: 18
- Watchers: 2
- Forks: 6
- Open Issues: 3
- Releases: 4
Topics
causal-inference
conditional-density-estimates
density-estimation
highly-adaptive-lasso
inverse-probability-weights
machine-learning
nonparametric-regression
propensity-score
Created about 7 years ago
· Last pushed 6 months ago
Metadata Files
Readme
Changelog
Contributing
License
README.Rmd
---
output:
rmarkdown::github_document
always_allow_html: yes
bibliography: "inst/REFERENCES.bib"
---
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
out.width = "100%",
fig.path = "README-"
)
```
# R/`haldensify`
[](https://github.com/nhejazi/haldensify/actions)
[](https://app.codecov.io/github/nhejazi/haldensify?branch=master)
[](https://www.r-pkg.org/pkg/haldensify)
[](https://CRAN.R-project.org/package=haldensify)
[](https://CRAN.R-project.org/package=haldensify)
[](https://www.repostatus.org/#active)
[](https://opensource.org/licenses/MIT)
[](https://doi.org/10.5281/zenodo.3698329)
[](https://doi.org/10.21105/joss.04522)
> Highly Adaptive Lasso Conditional Density Estimation
__Authors:__ [Nima Hejazi](https://nimahejazi.org), [David
Benkeser](https://sph.emory.edu/profile/faculty/david-benkeser), and Mark
van der Laan](https://vanderlaan-lab.org/about/)
---
## What's `haldensify`?
The `haldensify` R package is designed to provide facilities for nonparametric
conditional density estimation based on a flexible procedure proposed initially
by @diaz2011super. The core of the implemented methodology involves recovering
conditional density estimates by performing pooled hazards regressions so as to
assess the conditional hazard that an observed value falls in a given bin over
the (conditional) support of the variable of interest. Such conditional density
estimates are useful, for example, in causal inference problems in which the
_generalized propensity score_ (for continuous-valued exposures) must be
estimated [@diaz2012population; @diaz2018stochastic; @diaz2020causal].
`haldensify` implements this conditional density estimation strategy for use
only with the highly adaptive lasso (HAL) [@benkeser2016highly;
@vdl2017generally; @vdl2018highly; @coyle2022hal9001-rpkg;
@hejazi2020hal9001-joss]. Since the generalized propensity score is a key
ingredient in inverse probability weighting (IPW) methods, `haldensify` builds
on the advances of @ertefaie2020nonparametric and @hejazi2022efficient to
provide non-parametric IPW estimators of the causal effects for continuous
treatments, which achieve the semi-parametric efficiency bound by
undersmoothing along a family of HAL conditional density estimators.
---
## Installation
For standard use, we recommend installing the package from
[CRAN](https://CRAN.R-project.org/package=haldensify) via
```{r cran-installation, eval = FALSE}
install.packages("haldensify")
```
To contribute, install the _development version_ of `haldensify` from GitHub
via [`remotes`](https://CRAN.R-project.org/package=remotes):
```{r gh-master-installation, eval = FALSE}
remotes::install_github("nhejazi/haldensify")
```
---
## Example
A simple example illustrates how `haldensify` may be used to train a highly
adaptive lasso model to obtain conditional density estimates:
```{r example-fit}
library(haldensify)
set.seed(76924)
# simulate data: W ~ U[-4, 4] and A|W ~ N(mu = W, sd = 0.25)
n_train <- 100
w <- runif(n_train, -4, 4)
a <- rnorm(n_train, w, 0.25)
# HAL-based density estimate of A|W
haldensify_fit <- haldensify(
A = a, W = w,
n_bins = 10, grid_type = "equal_range",
lambda_seq = exp(seq(-1, -10, length = 100)),
# arguments passed to hal9001::fit_hal()
max_degree = 3,
reduce_basis = 1 / sqrt(n_train)
)
haldensify_fit
```
We can also visualize the empirical risk (with respect to density loss) in terms
of the solution path of the lasso regularization parameter:
```{r example-plot, out.width = "80%", fig.path = "man/figures/", fig.alt = "CV-risk of regularized conditional density estimators"}
plot(haldensify_fit)
```
Finally, we can obtain conditional density estimates from the trained model on
the training (or on new) data:
```{r example-predict}
# use the built-in predict method to get predictions
pred_haldensify <- predict(haldensify_fit, new_A = a, new_W = w)
head(pred_haldensify)
```
For more details, check out the [package
vignette](https://codex.nimahejazi.org/haldensify/articles/intro_haldensify) on
the corresponding `pkgdown` site.
---
## Issues
If you encounter any bugs or have any specific feature requests, please [file
an issue](https://github.com/nhejazi/haldensify/issues).
---
## Contributions
Contributions are very welcome. Interested contributors should consult our
[contribution
guidelines](https://github.com/nhejazi/haldensify/blob/master/CONTRIBUTING.md)
prior to submitting a pull request.
---
## Citation
After using the `haldensify` R package, please cite the following:
@article{hejazi2022efficient,
author = {Hejazi, Nima S and Benkeser, David and D{\'\i}az, Iv{\'a}n
and {van der Laan}, Mark J},
title = {Efficient estimation of modified treatment policy effects
based on the generalized propensity score},
year = {2022},
journal = {},
publisher = {},
volume = {},
number = {},
pages = {},
doi = {},
url = {https://arxiv.org/abs/2205.05777}
}
@article{hejazi2022haldensify-joss,
author = {Hejazi, Nima S and {van der Laan}, Mark J and Benkeser,
David C},
title = {{haldensify}: Highly adaptive lasso conditional density
estimation in {R}},
year = {2022},
doi = {10.21105/joss.04522},
url = {https://doi.org/10.21105/joss.04522},
journal = {Journal of Open Source Software},
publisher = {The Open Journal}
}
@software{hejazi2022haldensify-rpkg,
author = {Hejazi, Nima S and Benkeser, David C and {van der Laan},
Mark J},
title = {{haldensify}: Highly adaptive lasso conditional density
estimation},
year = {2022},
howpublished = {\url{https://github.com/nhejazi/haldensify}},
doi = {10.5281/zenodo.3698329},
url = {https://doi.org/10.5281/zenodo.3698329},
note = {{R} package version 0.2.5}
}
---
## Related
* [R/`hal9001`](https://github.com/tlverse/hal9001) -- The highly adaptive
lasso estimator used internally to constructed conditional density estimates.
---
## Funding
The development of this software was supported in part through grants from the
National Library of Medicine (award number [T32
LM012417](https://reporter.nih.gov/project-details/9248418)), the
National Institute of Allergy and Infectious Diseases (award number
[R01 AI074345](https://reporter.nih.gov/project-details/9926564)) of the
National Institutes of Health, and the National Science Foundation (award
number [DMS 2102840](https://www.nsf.gov/awardsearch/showAward?AWD_ID=2102840)).
---
## License
© 2019-2025 [Nima S. Hejazi](https://nimahejazi.org)
The contents of this repository are distributed under the MIT license. See below
for details:
```
MIT License
Copyright (c) 2019-2025 Nima S. Hejazi
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
---
## References
Owner
- Name: nima hejazi
- Login: nhejazi
- Kind: user
- Location: Boston, Massachusetts
- Company: Harvard Chan School of Public Health
- Website: https://nimahejazi.org
- Twitter: nshejazi
- Repositories: 19
- Profile: https://github.com/nhejazi
Assistant Professor of Biostatistics at the Harvard School of Public Health
JOSS Publication
haldensify: Highly adaptive lasso conditional density estimation in R
Published
September 23, 2022
Volume 7, Issue 77, Page 4522
Authors
Tags
machine learning causal inference conditional density estimation generalized propensity score inverse probability weighting semiparametric inferenceGitHub Events
Total
- Issues event: 5
- Watch event: 2
- Issue comment event: 1
- Push event: 5
- Pull request event: 1
- Fork event: 2
Last Year
- Issues event: 5
- Watch event: 2
- Issue comment event: 1
- Push event: 5
- Pull request event: 1
- Fork event: 2
Committers
Last synced: 7 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Nima Hejazi | nh@n****g | 180 |
| rachaelvp | r****s@g****m | 5 |
| Benkeser | b****r@e****u | 3 |
Committer Domains (Top 20 + Academic)
emory.edu: 1
nimahejazi.org: 1
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 14
- Total pull requests: 31
- Average time to close issues: over 1 year
- Average time to close pull requests: about 1 month
- Total issue authors: 6
- Total pull request authors: 3
- Average comments per issue: 1.5
- Average comments per pull request: 0.06
- Merged pull requests: 27
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 2
- Pull requests: 3
- Average time to close issues: about 1 month
- Average time to close pull requests: 8 months
- Issue authors: 1
- Pull request authors: 1
- Average comments per issue: 1.0
- Average comments per pull request: 0.0
- Merged pull requests: 1
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- nhejazi (7)
- benkeser (2)
- jeremyrcoyle (2)
- tdhock (1)
- adibender (1)
- HenrikBengtsson (1)
Pull Request Authors
- nhejazi (29)
- benkeser (2)
- rachaelvp (1)
Top Labels
Issue Labels
enhancement (5)
bug (4)
question (3)
TODO (1)
Pull Request Labels
enhancement (17)
bug (6)
TODO (1)
Dependencies
DESCRIPTION
cran
- R >= 3.2.0 depends
- Rdpack * imports
- assertthat * imports
- data.table * imports
- dplyr * imports
- future.apply * imports
- ggplot2 * imports
- hal9001 >= 0.4.1 imports
- matrixStats * imports
- origami >= 1.0.3 imports
- rlang * imports
- scales * imports
- stats * imports
- stringr * imports
- tibble * imports
- utils * imports
- covr * suggests
- future * suggests
- knitr * suggests
- rmarkdown * suggests
- testthat * suggests
.github/workflows/R-CMD-check.yml
actions
- actions/checkout v4 composite
- r-lib/actions/check-r-package v2 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
- r-lib/actions/setup-tinytex v2 composite
.github/workflows/draft-pdf.yml
actions
- actions/checkout v4 composite
- actions/upload-artifact v4 composite
- openjournals/openjournals-draft-action master composite
