ggm: construct and visualize Gaussian Graphical Models.

Description Usage Arguments Details Value Additional arguments Author(s) References Examples

View source: R/ggm.R

Description

Fit a Gaussian Graphical Model to continuous-valued dataset employing a subset of methods from stepwise AIC, stepwise BIC, stepwise significance test, partial correlation thresholding, edgewise significance test, or glasso. Also visualizes the fitted Graphical Model.

Usage

1
2
ggm(data, methods = c("glasso"), community = TRUE,
  betweenness = TRUE, plot = FALSE, levels = NULL, ...)

Arguments

data

A normalized dataframe or matrix with no missing data of continuous measurements.

methods

A string or list of strings indicate methods used to construct the model. See the details for more information. (default = "glasso")

community

A logical value to show if the node communities should be detected and colored in the returned graph. (default = TRUE)

betweenness

A logical value to show if the node betweenness measurements should be computed and returned from the function. (default = TRUE)

plot

A logical value to show if the graph should be plotted. (default = FALSE)

levels

An integer value indicating the maximum number of levels of a categorical variable. To be used to distinguish the categorical variable. Defaults to NULL because it is supposed that data has been preprocessed using data_preproc and the categorical variables are specified. If it is set, first will run data_preproc to specify categorical and continuous variables.

...

Any additional arguments.

Details

The function combines the methods to construct the model, that is, the edge set is the intersection of all edge sets each of which is found by a method. The package gRim is used to implement AIC, BIC, and stepwise significance test. The method glasso from the package glasso is used to provide a sparse estimation of the inverse covariance matrix.

Value

A list in which each element is the details of a specific fitting method.

significance

A data.frame containing edges with p.values.

graph

an igraph object of the graphical model.

betweenness

betweenness measurements of each node.

network

a visNetwork plot of the graph.

communities

a named vector indicating the community of each node.

Additional arguments

threshold

A threshold for partial correlation thresholding method (default = 0.05). To be used only when the method "threshold" is used.

significance

A cutoff for edge significance (default = 0.05). To be used only when the method "significance" is used.

rho

(Non-negative) regularization parameter for glasso (default = 0.1). To be used only when the method "glasso" is used.

Author(s)

Elyas Heidari

References

Højsgaard, S., Edwards, D., & Lauritzen, S. (2012). Graphical Models with R. Springer US. https://doi.org/10.1007/978-1-4614-2299-0

Friedman, J., Hastie, T., & Tibshirani, R. (2007). Sparse inverse covariance estimation with the graphical lasso. Biostatistics, 9(3), 432–441. https://doi.org/10.1093/biostatistics/kxm045

Abreu, G. C. G., Edwards, D., & Labouriau, R. (2010). High-Dimensional Graphical Model Search with thegRapHDRPackage. Journal of Statistical Software, 37(1). https://doi.org/10.18637/jss.v037.i01

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
data("NHANES")
## Using raw data
## No need to choose the continuous variables (They will be detected automatically)
glasso_ggm <- ggm(data = NHANES[1:1000, ], methods = c("glasso"), levels = 15)

## Using preprocessed data
data <- data_preproc(NHANES, levels = 15)
data$SEQN <- NULL
glasso_sin_ggm <- ggm(data = data[1:1000, 1:74], methods = c("glasso", "sin"),
plot = TRUE, rho = 0.2, significance = 0.03)

bAIo-lab/Questools documentation built on Nov. 9, 2019, 3:59 a.m.