require(mvtnorm)
nVar <- 50 ## number of variables
maxCon <- 5 ## maximum connectivity per variable
nObs <- 30 ## number of observations to simulate
set.seed(123)
A <- qpRndGraph(p=nVar, d=maxCon)
Sigma <- qpG2Sigma(A, rho=0.5)
X <- rmvnorm(nObs, sigma=as.matrix(Sigma))
## the higher the q the sparser the qp-graph
nrr.estimates <- qpNrr(X, q=1, verbose=FALSE)
qpGraphDensity(nrr.estimates, plot=FALSE)$sparseness
nrr.estimates <- qpNrr(X, q=5, verbose=FALSE)
qpGraphDensity(nrr.estimates, plot=FALSE)$sparseness
Run the code above in your browser using DataLab