Learn R Programming

SparseLearner (version 1.0-2)

SGraph: Graphic Modeling Using LASSO-Type Sparse Learning Algorithm.

Description

This function builds a gaussian or binary graph based on the bootstrap ranking LASSO regression method.

Usage

SGraph(x, graphtype = c("gaussian"), B = 5, Boots = 100, edgerule = c("AND"), kfold = 10, 
  plot = TRUE, seed = 0123)

Arguments

x
the matrix of gaussian or binary variables
graphtype
the type of gaussian or binary graph, with the default value gaussian
B
the external loop for intersection operation, with the default value 5
Boots
the internal loop for bootstrap sampling, with the default value 100
edgerule
the AND or OR rule for estimating the edge set, with the default value AND
kfold
the K-fold cross validation, with the default value 10
plot
the indication of whether to show the graph or not, with the default value TRUE
seed
the random seed for bootstrap sampling, with the default value 0123

Value

  • AdjmatrixThe adjacency matrix of variables.

References

[1] Guo, P., Zeng, F., Hu, X., Zhang, D., Zhu, S., Deng, Y., & Hao, Y. (2015). Improved Variable Selection Algorithm Using a LASSO-Type Penalty, with an Application to Assessing Hepatitis B Infection Relevant Factors in Community Residents. PLoS One, 27;10(7):e0134151. [2] Strobl, R., Grill, E., Mansmann, U. (2012). Graphical modeling of binary data using the LASSO: a simulation study. BMC Medical Research Methodology, 12:16. [3] Meinshausen, N., Buehlmann, P. (2006). High-dimensional graphs and variable selection with the Lasso. Ann Stat, 34:1436-1462.

Examples

Run this code
# Example 1: Gaussian graph with AND-rule.
library(datasets)
head(iris)
X <- as.matrix(subset(iris,iris$Species=="setosa")[, -5])
# Build a sparse gaussian graph using the bootstrap ranking LASSO model.
# The parameters of B and Boots in the following example are set as small values to 
# reduce the running time, however the default values are proposed. 
SGraph.and <- SGraph(x=X, graphtype=c("gaussian"), B=2, Boots=2, edgerule=c("AND"), 
plot=FALSE)
# Give out the adjacency matrix of variables.
SGraph.and$Adjmatrix
# Plot the graph based on the adjacency matrix of variables using the qgraph package.
library(qgraph)
qgraph(SGraph.and$Adjmatrix, directed=FALSE, color="blue", negCol="red",  
edge.labels=TRUE, layout="circle")
# Example 2: Gene network estimation using the bootstrap ranking LASSO method.
library(SIS)
data(leukemia.train)
# Genes screened by the LASSO algorithm as candidates for graphical modeling.
set.seed(0123)
x <- as.matrix(leukemia.train[, -7130])
y <- as.factor(leukemia.train[, 7130])
cvfit <- cv.glmnet(x=x, y=y, type.measure="deviance", nfolds=3, family="binomial")
model.final <- cvfit$glmnet.fit
nzero <- as.matrix(coef(model.final, s=cvfit$lambda.min))
var_nz <- names(nzero[nzero[,1]!=0, ])[-1]
sub_data <- leukemia.train[, c(var_nz, "V7130")]
# Gene expression data subset from patients with acute myeloid leukemia.
subset_1 <- subset(sub_data, sub_data$V7130==1)
subset_1 <- as.matrix(subset_1[, -dim(subset_1)[2]])
# The parameters of B and Boots in the following example are set as small values to
# reduce the running time, however the default values are proposed.
SGraph.fit <- SGraph(subset_1, graphtype=c("gaussian"), B=2, Boots=2, edgerule=c("OR"))

Run the code above in your browser using DataLab