get_causaleffect {BCDAG} R Documentation

## Estimate total causal effects from the MCMC output

### Description

This function provides causal effect estimates from the output of learn_DAG

### Usage

get_causaleffect(
learnDAG_output,
targets,
response,
BMA = FALSE,
verbose = TRUE
)


### Arguments

 learnDAG_output object of class bcdag targets numerical (p,1) vector with labels of target nodes response numerical label of response variable BMA boolean; if TRUE, the Bayesian model averaging (BMA) estimate of the total causal effect is returned; if FALSE, samples from the posterior distribution of causal effect coefficients are returned verbose if TRUE, progress bar of MCMC sampling is displayed

### Details

Output of learn_dag function consists of S draws from the joint posterior of DAGs and DAG-parameters in a zero-mean Gaussian DAG-model; see the documentation of learn_DAG for more details.

The total causal effect on a given variable of interest (response) consequent to a joint intervention on a set of variables (targets) is defined according to Pearl's do-calculus theory and under the Gaussian assumption can be expressed as a function of parameters (D,L), representing a (Cholesky) reparameterization of the covariance matrix.

Specifically, to each intervened variable a causal effect coefficient is associated and the posterior distribution of the latter can be recovered from posterior draws of the DAG parameters returned by learn_DAG. For each coefficient a sample of size S from its posterior is available. If required, the only Bayesian Model Average (BMA) estimate (obtained as the sample mean of the S draws) can be returned by setting BMA = TRUE.

Notice that, whenever implemented with collapse = FALSE, learn_DAG returns the marginal posterior distribution of DAGs only. In this case, get_causaleffect preliminarily performs posterior inference of DAG parameters by drawing samples from the posterior of (D,L).

### Value

Either a (p,1) vector containing BMA causal effect estimates, or a (S,p) matrix collecting S draws from the posterior of the p causal effect coefficients.

### Author(s)

Federico Castelletti and Alessandro Mascaro

### References

J. Pearl (2000). Causality: Models, Reasoning, and Inference. Cambridge University Press, Cambridge.

F. Castelletti and A. Mascaro (2021) Structural learning and estimation of joint causal effects among network-dependent variables. Statistical Methods and Applications, Advance publication.

P. Nandy, M.H. Maathuis and T. Richardson (2017). Estimating the effect of joint interventions from observational data in sparse high-dimensional settings. Annals of Statistics 45(2), 647-674.

### Examples

# Randomly generate a DAG and the DAG-parameters
q = 8
w = 0.2
set.seed(123)
DAG = rDAG(q = q, w = w)
outDL = rDAGWishart(n = 1, DAG = DAG, a = q, U = diag(1, q))
L = outDL$L; D = outDL$D
Sigma = solve(t(L))%*%D%*%solve(L)
n = 200
# Generate observations from a Gaussian DAG-model
X = mvtnorm::rmvnorm(n = n, sigma = Sigma)
# Run the MCMC (set S = 5000 and burn = 1000 for better results)
out_mcmc = learn_DAG(S = 500, burn = 100, a = q, U = diag(1,q)/n, data = X, w = w,
fast = TRUE, save.memory = FALSE)
head(out_mcmc$Graphs) head(out_mcmc$L)
# Compute the BMA estimate of coefficients representing
# the causal effect on node 1 of an intervention on {3,4}
get_causaleffect(learnDAG_output = out_mcmc, targets = c(3,4), response = 1, BMA = TRUE)


[Package BCDAG version 1.0.0 Index]