Inferring Causal Effects on Collective Outcomes under Interference

In networks, treatments may spill over from the treated individual to his or her social contacts and outcomes may be contagious over time. Under this setting, causal inference on the collective outcome observed over all network is often of interest. We use chain graph models approximating the projection of the full longitudinal data onto the observed data to identify the causal effect of the intervention on the whole outcome. Justification of such approximation is demonstrated in Ogburn et al. (2018) .

Travis-CI Build Status arXiv shield

netchain is a R package for causal inference on collective outcomes under social network. Our paper proposed and justified a parsimonious parametrization for social network data generated from causal directed acyclic graph (DAG), approximating a particular family of graphical models known as chain graphs under some conditions.

We provide a function simGibbs() to generate binary outcomes, treatments, and confounders from chain graph model. A function chain.causal.multi() is to infer parameters in the conditional log-linear models that feature hybrid graphical models of undirected graphs and directed acyclic graphs (DAG). This function generates counterfactual outcomes using Gibbs sampling given treatment assignment and the estimated parameters to derive the probability associated with collective outcomes. We also provide a function of causal.influence() to identify the most (causally) influential subjects in social network based on the their causal effect on the collective outcomes.

Package information


You can download the package by:


# or you can directly download the development version from author's Github


Here is a R vignettes for guidance. Or you can access to vignettes via:

install_github("youjin1207/netchain", build_vignettes = TRUE)
vignette("chainapprox", package = "netchain")


# set direct effect and two-way interaction effect on undirected graphs (weight.matrix)
weight.matrix = matrix(c(0.5, 1, 0, 1, 0.3, 0.5, 0, 0.5, -0.5), 3, 3)
simobs = simGibbs(n.unit = 3, n.gibbs = 10, n.sample = 10, 
                   treat.matrix = 0.5*diag(3), cov.matrix= (-0.3)*diag(3) )
inputY = simobs$inputY
inputA = simobs$inputA
inputC = simobs$inputC

# define relational matrix (R.matrix)
R.matrix = ifelse(weight.matrix==0, 0, 1)      
diag(R.matrix) = 0

# infer conditional log-linear model following chain graph models.
result = chain.causal.multi(targetoutcome = "mean", treatment = c(1,0,0), inputY, inputA, listC = inputC, R.matrix = R.matrix, E.matrix = diag(3), edgeinfo = list(rbind(c("Y", 1), c("C", 1)), rbind(c("Y", 2), c("C", 2)), rbind(c("Y", 3), c("C", 3))), n.obs = 1000, n.burn = 100)

# measure influence for each node by evaluating average of collective outcomes under each treatment.
influence = causal.influence(targetoutcome = "mean", Avalues = c(1,0), 
                            inputY, inputA, listC = inputC, R.matrix, E.matrix = diag(3), 
                            edgeinfo = list(rbind(c("Y", 1), c("C", 1)), rbind(c("Y", 2), c("C", 2)), rbind(c("Y", 3), c("C", 3))), n.obs = 100, n.burn = 10)


Ogburn, E. L., Shpitser, I., & Lee, Y. (2018). Causal inference, social networks, and chain graphs. arXiv preprint arXiv:1812.04990.


Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


0.1.0 by Youjin Lee, 2 months ago

Browse source code at

Authors: Elizabeth Ogburn [aut] , Ilya Shpitser [aut] , Youjin Lee [aut, cre]

Documentation:   PDF Manual  

GPL (>= 3) | file LICENSE license

Imports Rcpp, Matrix, gtools, stringr, stats, igraph

Suggests knitr, rmarkdown, testthat, R.rsp

Linking to Rcpp

See at CRAN