get_edgeprobs {BCDAG} R Documentation

## Compute posterior probabilities of edge inclusion from the MCMC output

### Description

This function computes the posterior probability of inclusion for each edge u -> v given the MCMC output of learn_DAG;

### Usage

get_edgeprobs(learnDAG_output)


### Arguments

 learnDAG_output object of class bcdag

### 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 posterior probability of inclusion of u -> v is estimated as the frequency of DAGs visited by the MCMC which contain the directed edge u -> v. Posterior probabilities are collected in a (q,q) matrix with (u,v)-element representing the estimated posterior probability of edge u -> v.

### Value

A (q,q) matrix with posterior probabilities of edge inclusion

### Author(s)

Federico Castelletti and Alessandro Mascaro

### References

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

### 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)
# Generate observations from a Gaussian DAG-model
n = 200
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 = 0.1,
fast = TRUE, save.memory = FALSE)
# Compute posterior probabilities of edge inclusion
get_edgeprobs(out_mcmc)



[Package BCDAG version 1.0.0 Index]