Skip to content
R package for likelihood estimation and inference of a directed acyclic graph
Branch: master
Clone or download
Latest commit 60022a8 Jun 12, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
.old add estimate under null, bug corrected Apr 30, 2019
.vignettes CRAN v0.5.7 May 7, 2019
.vscode/ipch/d0f3f8e43a6102d4 minor update May 1, 2019
examples added examples May 6, 2019
pkg CRAN v0.6.0 Jun 9, 2019
LICENSE Initial commit May 2, 2019 update readme Jun 12, 2019
clrdag-slides.Rmd add intro slides May 2, 2019
clrdag-slides.pdf add intro slides May 2, 2019


clrdag is an R package for likelihood estimation and inference of a Gaussian directed acyclic graph. See clrdag-slides.pdf for the introduction slides to the package. The complete reference for the methodology is

Li, C., Shen, X., and Pan, W. (2019). Likelihood ratio tests for a large directed acyclic graph. Journal of the American Statistical Association. Accepted. DOI:10.1080/01621459.2019.1623042.

See also the package vignette by vignette('clrdag') in R.


It is strongly recommended to install clrdag from CRAN.

To achieve best performance, you may want to install the latest version of OpenBLAS or Intel Math Kernel Library. You are also recommended to use a compiler that fully supports OpenMP.


In this example, a 50 by 50 random adjacency matrix is generated, where there are 43 edges in the graph. For each edge, the strength is uniformly distributed in [-1,-0.7] U [0.7,1]. The random error is standard normal.

p <- 50; n <- 1000; sparsity <- 2/p

## generate a random lower triangular adjacnecy matrix
A <- matrix(rbinom(p*p, 1, sparsity)*sign(runif(p*p, -1, 1))*runif(p*p, 0.7, 1), p, p)
A[upper.tri(A, diag=TRUE)] <- 0

## permute the order of adjacency matrix
idx <- sample(1:p)
A <- A[idx,idx]

## num of edges in A
sum(A != 0) # 43

## data matrix
X <- matrix(rnorm(n*p), n, p) %*% t(solve(diag(p) - A))

## estimate the graph
t <- proc.time()
out <- MLEdag(X=X, tau=0.3, mu=1, rho=1.2)
proc.time() - t 

## Frobenius distance to the truth adjacency matrix
sum((out$A - A)^2) # 0.0285789

## Hamming distance to the truth graph
sum(abs((out$A != 0) - (A != 0))) # 0

## test edge 1 --> 3
D <- matrix(0, p, p)
D[3,1] <- 1
out <- MLEdag(X=X, D=D, tau=0.3, mu=1, rho=1.2)
out$pval # 0.7496623

## test edge 7 --> 4
D <- matrix(0, p, p)
D[4,7] <- 1
out <- MLEdag(X=X, D=D, tau=0.3, mu=1, rho=1.2)
out$pval # 8.827349e-155

The examples directory contains Examples 1-2 in Li et al. (2019). You can reproduce the other examples in the paper by changing the variables n, p, sparsity, A, and D, accordingly.


Cross-validation functions, information criterion functions (AIC, BIC), and diagnostic plots.

More about clrdag

The program was originally written in July 2018. Ziyue Zhu and I refactored the R code and wrote a vignette in December 2018 as part of the final project for the optimization course EE 5239. As of May 1, 2019, this R package is publicly available. It is still in development and be cautious.

Special thanks to Prof Charles Geyer and Prof Mingyi Hong for their comments.

To report an issue, please file one at here.

You can’t perform that action at this time.