get_MAPdag {BCDAG}R Documentation

Compute the maximum a posteriori DAG model from the MCMC output


This function computes the maximum a posteriori DAG model estimate (MAP) from the MCMC output of learn_DAG





object of class bcdag


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 Maximum A Posteriori (MAP) model estimate is defined as the DAG visited by the MCMC with the highest associated posterior probability. Each DAG posterior probability is estimated as the frequency of visits of the DAG in the MCMC chain. The MAP estimate is represented through its (q,q) adjacency matrix, with (u,v)-element equal to one whenever the MAP contains u -> v, zero otherwise.


The (q,q) adjacency matrix of the maximum a posteriori DAG model


Federico Castelletti and Alessandro Mascaro


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

G. Garcia-Donato and M.A. Martinez-Beneito (2013). On sampling strategies in Bayesian variable selection problems with large model spaces. Journal of the American Statistical Association 108 340-352.


# Randomly generate a DAG and the DAG-parameters
q = 8
w = 0.2
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)
# Produce the MAP DAG estimate

[Package BCDAG version 1.0.0 Index]