library(MASS)
library(glmnet)
library(cvTools)
set.seed(1)
## Generate the covariance matrix for the AR(1) process
phi <- 0.5
p <- 50
n <- 50
Sigma <- diag(rep(1,p))
Sigma <- phi^(abs(row(Sigma)-col(Sigma)))/(1-phi^2)
## The inverse covariance matrix is sparse
Omega <- solve(Sigma)
## Generate multivariate normal data
x <- mvrnorm(n, mu=rep(0, p), Sigma=Omega)
## Covariance selection with external information
cv.fit <- cv.covsel(x, lambda=seq(0.1,0.3,0.1), nfolds=5)
Run the code above in your browser using DataLab