Skip to content

Commit 94d8c8d

Browse files
authored
Merge pull request #118 from NSAPH-Software/release_0.2.1
Release 0.2.1
2 parents ff62ee5 + 0538ae3 commit 94d8c8d

112 files changed

Lines changed: 1628 additions & 1087 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.Rbuildignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ index.md
1717
^docker_singularity/*$
1818
^functional_tests/*$
1919
^CRAN-SUBMISSION$
20+
^paper/*$
21+
^CODE_OF_CONDUCT\.md$

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ src-i386
1313
*.ipynb
1414
*.pdf
1515
*.log
16+
.Rdata
17+
.httr-oauth

CODE_OF_CONDUCT.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
We as members, contributors, and leaders pledge to make participation in our
6+
community a harassment-free experience for everyone, regardless of age, body
7+
size, visible or invisible disability, ethnicity, sex characteristics, gender
8+
identity and expression, level of experience, education, socio-economic status,
9+
nationality, personal appearance, race, caste, color, religion, or sexual
10+
identity and orientation.
11+
12+
We pledge to act and interact in ways that contribute to an open, welcoming,
13+
diverse, inclusive, and healthy community.
14+
15+
## Our Standards
16+
17+
Examples of behavior that contributes to a positive environment for our
18+
community include:
19+
20+
* Demonstrating empathy and kindness toward other people
21+
* Being respectful of differing opinions, viewpoints, and experiences
22+
* Giving and gracefully accepting constructive feedback
23+
* Accepting responsibility and apologizing to those affected by our mistakes,
24+
and learning from the experience
25+
* Focusing on what is best not just for us as individuals, but for the overall
26+
community
27+
28+
Examples of unacceptable behavior include:
29+
30+
* The use of sexualized language or imagery, and sexual attention or advances of
31+
any kind
32+
* Trolling, insulting or derogatory comments, and personal or political attacks
33+
* Public or private harassment
34+
* Publishing others' private information, such as a physical or email address,
35+
without their explicit permission
36+
* Other conduct which could reasonably be considered inappropriate in a
37+
professional setting
38+
39+
## Enforcement Responsibilities
40+
41+
Community leaders are responsible for clarifying and enforcing our standards of
42+
acceptable behavior and will take appropriate and fair corrective action in
43+
response to any behavior that they deem inappropriate, threatening, offensive,
44+
or harmful.
45+
46+
Community leaders have the right and responsibility to remove, edit, or reject
47+
comments, commits, code, wiki edits, issues, and other contributions that are
48+
not aligned to this Code of Conduct, and will communicate reasons for moderation
49+
decisions when appropriate.
50+
51+
## Scope
52+
53+
This Code of Conduct applies within all community spaces, and also applies when
54+
an individual is officially representing the community in public spaces.
55+
Examples of representing our community include using an official e-mail address,
56+
posting via an official social media account, or acting as an appointed
57+
representative at an online or offline event.
58+
59+
## Enforcement
60+
61+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
62+
reported to the community leaders responsible for enforcement at nkhoshnevis@g.harvard.edu.
63+
All complaints will be reviewed and investigated promptly and fairly.
64+
65+
All community leaders are obligated to respect the privacy and security of the
66+
reporter of any incident.
67+
68+
## Enforcement Guidelines
69+
70+
Community leaders will follow these Community Impact Guidelines in determining
71+
the consequences for any action they deem in violation of this Code of Conduct:
72+
73+
### 1. Correction
74+
75+
**Community Impact**: Use of inappropriate language or other behavior deemed
76+
unprofessional or unwelcome in the community.
77+
78+
**Consequence**: A private, written warning from community leaders, providing
79+
clarity around the nature of the violation and an explanation of why the
80+
behavior was inappropriate. A public apology may be requested.
81+
82+
### 2. Warning
83+
84+
**Community Impact**: A violation through a single incident or series of
85+
actions.
86+
87+
**Consequence**: A warning with consequences for continued behavior. No
88+
interaction with the people involved, including unsolicited interaction with
89+
those enforcing the Code of Conduct, for a specified period of time. This
90+
includes avoiding interactions in community spaces as well as external channels
91+
like social media. Violating these terms may lead to a temporary or permanent
92+
ban.
93+
94+
### 3. Temporary Ban
95+
96+
**Community Impact**: A serious violation of community standards, including
97+
sustained inappropriate behavior.
98+
99+
**Consequence**: A temporary ban from any sort of interaction or public
100+
communication with the community for a specified period of time. No public or
101+
private interaction with the people involved, including unsolicited interaction
102+
with those enforcing the Code of Conduct, is allowed during this period.
103+
Violating these terms may lead to a permanent ban.
104+
105+
### 4. Permanent Ban
106+
107+
**Community Impact**: Demonstrating a pattern of violation of community
108+
standards, including sustained inappropriate behavior, harassment of an
109+
individual, or aggression toward or disparagement of classes of individuals.
110+
111+
**Consequence**: A permanent ban from any sort of public interaction within the
112+
community.
113+
114+
## Attribution
115+
116+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
117+
version 2.1, available at
118+
<https://www.contributor-covenant.org/version/2/1/code_of_conduct.html>.
119+
120+
Community Impact Guidelines were inspired by
121+
[Mozilla's code of conduct enforcement ladder][https://github.com/mozilla/inclusion].
122+
123+
For answers to common questions about this code of conduct, see the FAQ at
124+
<https://www.contributor-covenant.org/faq>. Translations are available at <https://www.contributor-covenant.org/translations>.
125+
126+
[homepage]: https://www.contributor-covenant.org

DESCRIPTION

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Type: Package
22
Package: CRE
33
Title: Interpretable Subgroups Identification Through Ensemble Learning of
44
Causal Rules
5-
Version: 0.2.0
5+
Version: 0.2.1
66
Authors@R: c(
77
person("Naeem", "Khoshnevis", , "nkhoshnevis@g.harvard.edu", role = c("aut", "cre"),
88
comment = c(ORCID = "0000-0003-4315-1426", AFFILIATION = "FASRC")),
@@ -50,7 +50,6 @@ Imports:
5050
stabs,
5151
stringr,
5252
SuperLearner,
53-
dplyr,
5453
magrittr,
5554
ggplot2,
5655
bcf,

NEWS.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
# CRE 0.2.1 (2023-3-17)
2+
3+
## Changed
4+
* Replace BATE with ATE in CATE Linear Decomposition.
5+
* Update `plot()` function (remove ATE, old BATE, and explicit AATEs).
6+
7+
## Added
8+
* Code of Conduct.
9+
10+
## Removed
11+
* Causal Tree benchmark in functional tests.
12+
13+
## Bug fixes
14+
* Rank-Deficient Rule Matrix Issue (redundant rules).
15+
* Intervention Variables Filtering (ordered filtering).
16+
17+
118
# CRE 0.2.0 (2023-1-19)
219

320
## Changed

R/CRE_package.R

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,23 @@
22
#' The 'CRE' package
33
#'
44
#' @description
5-
#' Provides an interpretable identification of subgroups with
6-
#' heterogeneous causal effect. The heterogeneous subgroups are
7-
#' discovered through ensemble learning of causal rules. Causal rules are
8-
#' highly interpretable if-then statement that recursively partition the
9-
#' features space into heterogeneous subgroups. A small number of
10-
#' significant causal rules are selected through Stability Selection to
11-
#' control for family-wise error rate in the finite sample setting. It
12-
#' proposes various estimation methods for the conditional causal effects
13-
#' for each discovered causal rule. It is highly flexible and multiple
14-
#' causal estimands and imputation methods are implemented.
5+
#' In health and social sciences, it is critically important to
6+
#' identify subgroups of the study population where a treatment
7+
#' has notable heterogeneity in the causal effects with respect
8+
#' to the average treatment effect. Data-driven discovery of
9+
#' heterogeneous treatment effects (HTE) via decision tree methods
10+
#' has been proposed for this task. Despite its high interpretability,
11+
#' the single-tree discovery of HTE tends to be highly unstable and to
12+
#' find an oversimplified representation of treatment heterogeneity.
13+
#' To accommodate these shortcomings, we propose Causal Rule Ensemble
14+
#' (CRE), a new method to discover heterogeneous subgroups through an
15+
#' ensemble-of-trees approach. CRE has the following features:
16+
#' 1) provides an interpretable representation of the HTE; 2) allows
17+
#' extensive exploration of complex heterogeneity patterns; and 3)
18+
#' guarantees high stability in the discovery. The discovered subgroups
19+
#' are defined in terms of interpretable decision rules, and we develop
20+
#' a general two-stage approach for subgroup-specific conditional
21+
#' causal effects estimation, providing theoretical guarantees.
1522
#'
1623
#' @docType package
1724
#' @name CRE-package
@@ -23,6 +30,7 @@
2330
#' @author Falco Joannes Bargagli Stoffi
2431
#' @import xtable
2532
#' @import data.table
33+
#' @import SuperLearner
2634
#' @importFrom RRF RRF
2735
#' @importFrom RRF getTree
2836
#' @importFrom gbm pretty.gbm.tree
@@ -31,9 +39,8 @@
3139
#' @importFrom methods as
3240
#'
3341
#' @references
34-
#' Lee, K.,
35-
#' Bargagli-Stoffi, F. J., & Dominici, F. (2020). Causal rule ensemble:
36-
#' Interpretable inference of heterogeneous treatment effects. arXiv
37-
#' preprint arXiv:2009.09036.
42+
#' Bargagli-Stoffi, F. J., Cadei, R., Lee, K. and Dominici, F. (2023).
43+
#' Causal rule ensemble: Interpretable Discovery and Inference of
44+
#' Heterogeneous Treatment Effects,arXiv preprint arXiv:2009.09036
3845
#'
3946
NULL

R/check_hyper_params.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,13 @@ check_hyper_params <- function(X_names, params) {
100100
if (!inherits(t_ext, "numeric")) {
101101
stop("Invalid 't_ext' input. Please input a number.")
102102
}
103+
if (t_ext > 0.5 || t_ext < 0){
104+
stop(paste("t_ext should be defind in [0, 0.5) range. ",
105+
"Current provided value: ", t_ext))
106+
}
103107
}
108+
109+
104110
params[["t_ext"]] <- t_ext
105111

106112
t_corr <- getElement(params, "t_corr")

R/check_input_data.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ check_input_data <- function(y, z, X, ite = NULL) {
2020

2121
# Observed Outcome
2222
if (is.matrix(y)) {
23-
if (ncol(y)!=1 || !(is.numeric(y[,1]) || is.integer(y[,1]))) {
23+
if (ncol(y) != 1 || !(is.numeric(y[, 1]) || is.integer(y[, 1]))) {
2424
stop("Observed response vector (y) input values should be a numerical
2525
vector, not a matrix")
2626
}
@@ -34,14 +34,14 @@ check_input_data <- function(y, z, X, ite = NULL) {
3434

3535
# Treatment
3636
if (is.matrix(z)) {
37-
if (ncol(z)!=1 || !(is.numeric(z[,1]) || is.integer(z[,1]))
38-
| length(unique(z)) != 2) {
37+
if (ncol(z) != 1 || !(is.numeric(z[, 1]) || is.integer(z[, 1]))
38+
|| length(unique(z)) != 2) {
3939
stop("Treatment vector (z) input values should be a numerical binary
4040
vector, not a matrix")
4141
}
4242
N_check <- nrow(z)
43-
} else if (is.vector(z) & (is.numeric(z) || is.integer(z))
44-
& length(unique(z)) == 2) {
43+
} else if (is.vector(z) && (is.numeric(z) || is.integer(z))
44+
&& length(unique(z)) == 2) {
4545
N_check <- length(z)
4646
} else {
4747
stop(paste0("Treatment vector (z) input values should be",

R/check_method_params.R

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ check_method_params <- function(y, ite, params) {
2323
if (length(ratio_dis) == 0) {
2424
ratio_dis <- 0.5
2525
} else {
26-
if (!inherits(ratio_dis, "numeric") | (ratio_dis < 0) | (ratio_dis > 1)) {
26+
if (!inherits(ratio_dis, "numeric") || (ratio_dis < 0) || (ratio_dis > 1)) {
2727
stop("Invalid 'ratio_dis' input. Please input a number between 0 and 1.")
2828
}
2929
}
@@ -35,10 +35,10 @@ check_method_params <- function(y, ite, params) {
3535
if (length(ite_method_dis) == 0) {
3636
ite_method_dis <- "aipw"
3737
} else {
38-
if (!(ite_method_dis %in% c("aipw", "slearner","tlearner","xlearner",
39-
"bart","bcf","cf","tpoisson"))) {
38+
if (!(ite_method_dis %in% c("aipw", "slearner", "tlearner", "xlearner",
39+
"bart", "bcf", "cf", "tpoisson"))) {
4040
stop(paste(
41-
"Invalid ITE method for Discovery Subsample. Please choose ",
41+
"Invalid ITE method for discovery subsample. Please choose ",
4242
"from the following:\n", "'aipw', 'bart', 'slearner','tlearner', ",
4343
"'xlearner', 'bcf', 'cf', or 'tpoisson'"
4444
))
@@ -50,10 +50,10 @@ check_method_params <- function(y, ite, params) {
5050
if (length(ite_method_inf) == 0) {
5151
ite_method_inf <- "aipw"
5252
} else {
53-
if (!(ite_method_dis %in% c("aipw", "slearner","tlearner","xlearner",
54-
"bart","bcf", "cf", "tpoisson"))) {
53+
if (!(ite_method_inf %in% c("aipw", "slearner", "tlearner", "xlearner",
54+
"bart", "bcf", "cf", "tpoisson"))) {
5555
stop(paste(
56-
"Invalid ITE method for Inference Subsample. Please choose ",
56+
"Invalid ITE method for inference subsample. Please choose ",
5757
"from the following:\n", "'aipw', 'bart', 'slearner','tlearner', ",
5858
"'xlearner', 'bcf', 'cf', or 'tpoisson'"
5959
))
@@ -65,7 +65,8 @@ check_method_params <- function(y, ite, params) {
6565
# Propensity Score Estimation Parameters Check--------------------------------
6666

6767
ps_method_dis <- getElement(params, "ps_method_dis")
68-
if (!(ite_method_dis %in% c("slearner", "tlearner", "xlearner", "tpoisson"))) {
68+
if (!(ite_method_dis %in% c("slearner", "tlearner",
69+
"xlearner", "tpoisson"))) {
6970
if (length(ps_method_dis) == 0) {
7071
ps_method_dis <- "SL.xgboost"
7172
} else {
@@ -80,7 +81,8 @@ check_method_params <- function(y, ite, params) {
8081
params[["ps_method_dis"]] <- ps_method_dis
8182

8283
ps_method_inf <- getElement(params, "ps_method_inf")
83-
if (!(ite_method_inf %in% c("slearner", "tlearner", "xlearner", "tpoisson"))) {
84+
if (!(ite_method_inf %in% c("slearner", "tlearner",
85+
"xlearner", "tpoisson"))) {
8486
if (length(ps_method_inf) == 0) {
8587
ps_method_inf <- "SL.xgboost"
8688
} else {

0 commit comments

Comments
 (0)