Title: | Gaussian Graphs Models Selection |
---|---|
Description: | Graph estimation in Gaussian Graphical Models, following the method developed by C. Giraud, S. Huet and N. Verzelen (2012) <doi:10.1515/1544-6115.1625>. The main functions return the adjacency matrix of an undirected graph estimated from a data matrix. |
Authors: | Annie Bouvier, Christophe Giraud, Sylvie Huet, Nicolas Verzelen. |
Maintainer: | Benjamin Auder <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.1-12.7.1 |
Built: | 2024-11-12 04:36:17 UTC |
Source: | CRAN |
GGMselect is a package dedicated to graph estimation in Gaussian Graphical Models. The main functions return the adjacency matrix of an undirected graph estimated from a data matrix.
This package is developed in the Applied Mathematics and Informatics (https://maiage.inrae.fr/) Lab of INRA - Jouy-en-Josas, France.
To cite GGMselect, please use citation("GGMselect")
.
Package: | GGMselect |
URL: | https://CRAN.R-project.org/package=GGMselect |
Annie Bouvier, Christophe Giraud, Sylvie Huet, Verzelen Nicolas
Maintainer: Benjamin Auder <[email protected]>
More details are available on ../doc/Notice.pdf
Please use citation("GGMselect")
.
selectFast
, selectQE
,
selectMyFam
,convertGraph
,
simulateGraph
, penalty
p=30 n=30 # simulate graph eta=0.11 Gr <- simulateGraph(p,eta) # simulate data X <- rmvnorm(n, mean=rep(0,p), sigma=Gr$C) # estimate graph ## Not run: GRest <- selectFast(X) # plot result ## Not run: library(network) ## Not run: par(mfrow=c(1,2)) ## Not run: gV <- network(Gr$G) ## Not run: plot(gV,jitter=TRUE, usearrows = FALSE, label=1:p,displaylabels=TRUE) ## Not run: g <- network(GRest$EW$G) ## Not run: plot(g, jitter=TRUE, usearrows = FALSE, label=1:p,displaylabels=TRUE)
p=30 n=30 # simulate graph eta=0.11 Gr <- simulateGraph(p,eta) # simulate data X <- rmvnorm(n, mean=rep(0,p), sigma=Gr$C) # estimate graph ## Not run: GRest <- selectFast(X) # plot result ## Not run: library(network) ## Not run: par(mfrow=c(1,2)) ## Not run: gV <- network(Gr$G) ## Not run: plot(gV,jitter=TRUE, usearrows = FALSE, label=1:p,displaylabels=TRUE) ## Not run: g <- network(GRest$EW$G) ## Not run: plot(g, jitter=TRUE, usearrows = FALSE, label=1:p,displaylabels=TRUE)
Convert into adjacency matrices NG
graphs (expressed as
lists of connected nodes)
convertGraph(Graph)
convertGraph(Graph)
Graph |
array of dimension
|
An array of dimension p x p x NG
, or,
when NG
is equal to 1, a matrix
of dimension p x p
.
The entry [,,iG]
is a symmetric matrix, with diagonal equal to
zero. The entry [a,b,iG]
is equal to 1 if a
is connected to b
,
0 otherwise.
This function is useful to generate the entry
MyFamily
of the function selectMyFam
.
Actually, the list of adjacency matrices MyFamily
can be generated from lists of connected nodes with
convertGraph
.
Bouvier A, Giraud C, Huet S, Verzelen N
Please use citation("GGMselect")
selectQE
, selectMyFam
,
selectFast
, simulateGraph
,
penalty
p=30 n=30 # simulate graph eta=0.11 Gr <- simulateGraph(p,eta) X <- rmvnorm(n, mean=rep(0,p), sigma=Gr$C) # estimate graph GRest <- selectFast(X, family="C01") # Neighb and G are 2 forms of the same result a <- convertGraph(GRest$C01$Neighb) print(all.equal(a, GRest$C01$G)) # TRUE # recalculate the graph with selectMyFam GMF <- selectMyFam(X, list(a)) print(all.equal(a,GMF$G)) # TRUE
p=30 n=30 # simulate graph eta=0.11 Gr <- simulateGraph(p,eta) X <- rmvnorm(n, mean=rep(0,p), sigma=Gr$C) # estimate graph GRest <- selectFast(X, family="C01") # Neighb and G are 2 forms of the same result a <- convertGraph(GRest$C01$Neighb) print(all.equal(a, GRest$C01$G)) # TRUE # recalculate the graph with selectMyFam GMF <- selectMyFam(X, list(a)) print(all.equal(a,GMF$G)) # TRUE
Compute the penalty function of GGMselect.
penalty(p,n, dmax=min(3,n-3,p-1), K=2.5)
penalty(p,n, dmax=min(3,n-3,p-1), K=2.5)
p |
the number of variables. |
n |
the sample size. |
dmax |
integer or |
K |
scalar or vector of real numbers larger than 1. Tuning parameter of the penalty function. |
More details are available on ../doc/Notice.pdf
A matrix of dimension (max(Dmax)+1) x length(K)
.
The entry [d+1,k]
gives the value of the penalty for the dimension d
and the parameter
K[k]
.
Bouvier A, Giraud C, Huet S, Verzelen N
Please use citation("GGMselect")
selectQE
, selectMyFam
,
selectFast
, simulateGraph
,
convertGraph
p=30 n=30 pen <- penalty(p,n, 3)
p=30 n=30 pen <- penalty(p,n, 3)
Select a graph within the (data-driven) families of graphs EW
, C01
, and LA
.
selectFast(X, dmax=min(floor(nrow(X)/3),nrow(X)-3,ncol(X)-1), K=2.5, family="EW", min.ev=10**(-8), max.iter=200, eps=0.01, beta=nrow(X)*nrow(X)/2, tau=1/sqrt(nrow(X)*(ncol(X)-1)), h=0.001, T0=10, verbose=FALSE )
selectFast(X, dmax=min(floor(nrow(X)/3),nrow(X)-3,ncol(X)-1), K=2.5, family="EW", min.ev=10**(-8), max.iter=200, eps=0.01, beta=nrow(X)*nrow(X)/2, tau=1/sqrt(nrow(X)*(ncol(X)-1)), h=0.001, T0=10, verbose=FALSE )
X |
|
dmax |
integer or |
K |
scalar or vector with values greater than 1. Tuning parameter of the penalty function. |
family |
character string or vector of character strings, among |
min.ev |
minimum eigenvalue for matrix inversion. |
max.iter , eps , beta , tau , h , T0
|
tuning parameters for the
Langevin Monte Carlo algorithm. Only used when
|
verbose |
logical. If |
More details are available on ../doc/Notice.pdf
A list with components "EW"
, "LA"
, "C01"
,
"C01.LA"
and "C01.LA.EW"
, according to the
family
argument, each one with components:
Neighb |
array of dimension |
crit.min |
vector of dimension |
G |
array of dimension |
Bouvier A, Giraud C, Huet S, Verzelen N.
Please use citation("GGMselect")
.
selectQE
, selectMyFam
,
simulateGraph
, penalty
,
convertGraph
p=30 n=30 # simulate graph eta=0.11 Gr <- simulateGraph(p,eta) # simulate data X <- rmvnorm(n, mean=rep(0,p), sigma=Gr$C) # estimate graph GRest <- selectFast(X, family="C01") # plot result library(network) par(mfrow=c(1,2)) gV <- network(Gr$G) plot(gV,jitter=TRUE, usearrows = FALSE, label=1:p,displaylabels=TRUE) g <- network(GRest$C01$G) plot(g, jitter=TRUE, usearrows = FALSE, label=1:p,displaylabels=TRUE)
p=30 n=30 # simulate graph eta=0.11 Gr <- simulateGraph(p,eta) # simulate data X <- rmvnorm(n, mean=rep(0,p), sigma=Gr$C) # estimate graph GRest <- selectFast(X, family="C01") # plot result library(network) par(mfrow=c(1,2)) gV <- network(Gr$G) plot(gV,jitter=TRUE, usearrows = FALSE, label=1:p,displaylabels=TRUE) g <- network(GRest$C01$G) plot(g, jitter=TRUE, usearrows = FALSE, label=1:p,displaylabels=TRUE)
Select a graph within a given family of graphs.
selectMyFam(X, MyFamily, K=2.5, min.ev=10**(-8))
selectMyFam(X, MyFamily, K=2.5, min.ev=10**(-8))
X |
|
MyFamily |
list of pxp adjacency matrices corresponding to
graphs with degree less or equal to |
K |
scalar or vector with values larger than 1. Tuning parameter of the penalty function. |
min.ev |
minimum eigenvalue for matrix inversion. |
More details are available on ../doc/Notice.pdf
Neighb |
array of dimension |
crit.min |
vector of dimension |
ind.min |
vector of dimension |
G |
array of dimension |
Adjacency matrices can be generated from lists of connected nodes
by using the function convertGraph
Bouvier A, Giraud C, Huet S, Verzelen N.
Please use citation("GGMselect")
.
selectFast
, selectQE
,
simulateGraph
, penalty
,
convertGraph
p=30 n=30 # generate graph eta=0.11 Gr <- simulateGraph(p,eta) # generate data X <- rmvnorm(n, mean=rep(0,p), sigma=Gr$C) # generate a family of candidate graphs with glasso library("glasso") MyFamily <- NULL for (j in 1:3){ MyFamily[[j]] <- abs(sign(glasso(cov(X),rho=j/5)$wi)) diag(MyFamily[[j]]) <- 0 } # select a graph within MyFamily GMF <- selectMyFam(X,MyFamily) # plot the result library(network) par(mfrow=c(1,2)) gV <- network(Gr$G) plot(gV,jitter=TRUE, usearrows = FALSE, label=1:p,displaylabels=TRUE) gMyFam <- network(GMF$G) plot(gMyFam, jitter=TRUE, usearrows = FALSE, label=1:p,displaylabels=TRUE)
p=30 n=30 # generate graph eta=0.11 Gr <- simulateGraph(p,eta) # generate data X <- rmvnorm(n, mean=rep(0,p), sigma=Gr$C) # generate a family of candidate graphs with glasso library("glasso") MyFamily <- NULL for (j in 1:3){ MyFamily[[j]] <- abs(sign(glasso(cov(X),rho=j/5)$wi)) diag(MyFamily[[j]]) <- 0 } # select a graph within MyFamily GMF <- selectMyFam(X,MyFamily) # plot the result library(network) par(mfrow=c(1,2)) gV <- network(Gr$G) plot(gV,jitter=TRUE, usearrows = FALSE, label=1:p,displaylabels=TRUE) gMyFam <- network(GMF$G) plot(gMyFam, jitter=TRUE, usearrows = FALSE, label=1:p,displaylabels=TRUE)
Select a graph within the family of graphs QE
selectQE(X, dmax=min(3,nrow(X)-3,ncol(X)-1), K=2.5, min.ev=10**(-8), max.iter=10**6, max.nG=10**8, max.size=10**8, verbose=FALSE)
selectQE(X, dmax=min(3,nrow(X)-3,ncol(X)-1), K=2.5, min.ev=10**(-8), max.iter=10**6, max.nG=10**8, max.size=10**8, verbose=FALSE)
X |
|
dmax |
integer or |
K |
scalar or vector with values greater than 1. Tuning parameter in the penalty function. |
min.ev |
minimum eigenvalue for matrix inversion. |
max.iter |
integer. Maximum number of stepwise iterations. |
max.nG |
integer. Maximum number of graphs considered in the exhaustive search. Stepwise procedure beyond. |
max.size |
integer. Maximum number of calculations of the residuals sums of squares. Execution stopped beyond. |
verbose |
logical. If |
More details are available on ../doc/Notice.pdf
Neighb |
array of dimension |
crit.min |
vector of dimension |
G |
array of dimension |
Bouvier A, Giraud C, Huet S, Verzelen N.
Please use citation("GGMselect")
.
selectFast
, selectMyFam
,
simulateGraph
, penalty
,
convertGraph
p=30 n=30 # simulate graph eta=0.11 Gr <- simulateGraph(p,eta) # simulate data X <- rmvnorm(n, mean=rep(0,p), sigma=Gr$C) # estimate graph ## Not run: GQE <- selectQE(X) # plot the result ## Not run: library(network) ## Not run: par(mfrow=c(1,2)) ## Not run: gV <- network(Gr$G) ## Not run: plot(gV,jitter=TRUE, usearrows = FALSE, label=1:p,displaylabels=TRUE) ## Not run: gQE <- network(GQE$G) ## Not run: plot(gQE, jitter=TRUE, usearrows = FALSE, label=1:p,displaylabels=TRUE)
p=30 n=30 # simulate graph eta=0.11 Gr <- simulateGraph(p,eta) # simulate data X <- rmvnorm(n, mean=rep(0,p), sigma=Gr$C) # estimate graph ## Not run: GQE <- selectQE(X) # plot the result ## Not run: library(network) ## Not run: par(mfrow=c(1,2)) ## Not run: gV <- network(Gr$G) ## Not run: plot(gV,jitter=TRUE, usearrows = FALSE, label=1:p,displaylabels=TRUE) ## Not run: gQE <- network(GQE$G) ## Not run: plot(gQE, jitter=TRUE, usearrows = FALSE, label=1:p,displaylabels=TRUE)
Generate random covariance matrices C
with sparse inverse. The
Gaussian law N(0,C)
is then a sparse
(non-uniform) Gaussian Graphical Model.
simulateGraph(p, eta, extraeta = eta/5)
simulateGraph(p, eta, extraeta = eta/5)
p |
integer. Number of rows and columns of |
eta |
real number in (0,1). Proportion of edges in
subgroups. Small values of |
extraeta |
real number in (0,1). Proportion of edges inter groups. |
More details are available on ../doc/Notice.pdf
G |
p x p matrix. Adjacency matrix of the graph. |
Dmax |
integer. Maximum degree of the graph. |
Neighb |
array of dimension |
Nnodes |
integer. Number of nodes. |
C |
p x p matrix. Covariance matrix. |
PCor |
p x p matrix. Partial correlation matrix. |
Bouvier A, Giraud C, Huet S, Verzelen N
Please use citation("GGMselect")
.
selectQE
, selectMyFam
,
selectFast
, penalty
,
convertGraph
# simulate a graph p=30 eta=0.13 Gr <- simulateGraph(p,eta) # plot the graph library(network) par(mfrow=c(1,1)) gV <- network(Gr$G) plot(gV,jitter=TRUE, usearrows = FALSE, label=1:p,displaylabels=TRUE)
# simulate a graph p=30 eta=0.13 Gr <- simulateGraph(p,eta) # plot the graph library(network) par(mfrow=c(1,1)) gV <- network(Gr$G) plot(gV,jitter=TRUE, usearrows = FALSE, label=1:p,displaylabels=TRUE)