The NetworkCausalTree package introduces a machine learning method that uses tree-based algorithms and an Horvitz-Thompson estimator to assess the heterogeneity of treatment and spillover effects in clustered network interference. Causal inference studies typically assume no interference between individuals, but in real-world scenarios where individuals are interconnected through social, physical, or virtual ties, the effect of a treatment can spill over to other connected individuals in the network. To avoid biased estimates of treatment effects, interference should be considered. Understanding the heterogeneity of treatment and spillover effects can help policy-makers scale up interventions, target strategies more effectively, and generalize treatment spillover effects to other populations.
NetworkCausalTree is intended for researchers analyzing randomized interventions in populations with observed network ties and clustered network interference. Standard tools for discovering heterogeneous treatment effects, such as causalTree and grf, do not directly model spillover from treated neighbors. Conversely, software for causal inference under interference generally focuses on average effects rather than discovering interpretable subgroups with different direct and spillover responses.
The package addresses this gap by combining honest, cluster-level tree discovery with design-based estimation of leaf-specific treatment and spillover effects. Users should consider it when interference is confined within clusters, neighborhood exposure can be represented by having at least one treated neighbor, and individual treatment assignment follows a known independent Bernoulli design. For designs or exposure mappings outside these assumptions, methods tailored to those settings are more appropriate.
Installing the latest developing version:
library(devtools)
install_github("fbargaglistoffi/NetworkCausalTree", ref="master")Import + set seed:
library("NetworkCausalTree")
set.seed(123)The package uses a binary neighborhood exposure mapping:
[ G_i = \mathbb{1}\left{\sum_{j=1}^{N} A_{ij}W_j > 0\right} ]
Here, (A_{ij}) indicates whether units (i) and (j) are connected, and (W_j) indicates whether unit (j) receives treatment.
Thus, (G_i = 1) if unit (i) has at least one treated neighbor, and (G_i = 0) otherwise.
A must be a finite binary, symmetric adjacency matrix with a zero diagonal and no between-cluster edges. Assignment positivity ((0<p_i<1)) is distinct from exposure positivity: an isolated unit can never have (G_i=1). Because NetworkCausalTree() reports all four contrasts, it rejects networks containing isolated units, including when the splitting criterion targets only effect 1000. It does not silently remove units or change the target population. Under independent Bernoulli assignment, the supported no-isolates input domain gives each unit positive marginal probability of all four exposure states; zero joint probabilities for pairs remain possible and are handled by the variance routines.
Data generated using Erdos-Renyi networks.
## Examples
dataset_direct <- data_generator_direct(N = 4000,
M = 4,
k = 80,
p = rep(0.2,4000),
het = TRUE,
h = 2,
method_networks = "er",
param_er = 0.1)Singular splitting based on the main treatment effect only
result <- NetworkCausalTree(X = dataset_direct[["X"]],
Y = dataset_direct[["Y"]],
W = dataset_direct[["W"]],
A = dataset_direct[["A"]],
K = dataset_direct[["K"]],
p = dataset_direct[["p"]],
effect_weights = c(1,0,0,0),
ratio_disc = 0.5,
depth = 2,
minsize = 5,
method = "singular",
output = "estimation")
title <- expression(paste("CAUSAL TREE TARGETED TO ",tau,"(1,0;0,0)"),sep="")
cov_names <- colnames(dataset_direct[["X"]])
plot_NCT(NCT = result,
cov_names = cov_names,
title = title)Data generated using Barabasi-Albert networks.
dataset_direct_indirect <- data_generator_direct_indirect(N = 4000,
M = 4,
k = 80,
p = rep(0.2,4000),
het = TRUE,
h = 3,
method_networks = "sf")Composite splitting (NCT based on all the four effects)
result <- NetworkCausalTree(X = dataset_direct_indirect[["X"]],
Y = dataset_direct_indirect[["Y"]],
W = dataset_direct_indirect[["W"]],
A = dataset_direct_indirect[["A"]],
K = dataset_direct_indirect[["K"]],
p = dataset_direct_indirect[["p"]],
effect_weights = c(0.25, 0.25, 0.25, 0.25),
ratio_disc = 0.5,
depth = 2,
minsize = 5,
method = "composite",
output = "estimation")
title <- expression(paste("CAUSAL TREE TARGETED TO ",tau,"(0.25,0.25;0.25,0.25)"),sep="")
cov_names <- colnames(dataset_direct_indirect[["X"]])
plot_NCT(NCT = result,
cov_names = cov_names,
title = title,
effect_color_nodes = "0100")Please note that the NetworkCausalTree project follows the Contributor Covenant Code of Conduct. By contributing to this project, you agree to abide by its terms.
@article{bargagli2025heterogeneous,
title={Heterogeneous treatment and spillover effects under clustered network interference},
author={Bargagli-Stoffi, Falco J. and Tort{\'u}, Costanza and Forastiere, Laura},
journal={The Annals of Applied Statistics},
volume={19},
number={1},
pages={28},
year={2025},
publisher={Institute of Mathematical Statistics}
}