Title: | Bayesian Graph Structure Learning using Spike-and-Slab Priors |
---|---|
Description: | Bayesian estimation for undirected graphical models using spike-and-slab priors. The package handles continuous, discrete, and mixed data. |
Authors: | Reza Mohammadi [aut, cre] |
Maintainer: | Reza Mohammadi <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.15 |
Built: | 2024-11-03 04:20:43 UTC |
Source: | https://github.com/cran/ssgraph |
The R
package ssgraph is for Bayesian estimation of graphical models by using spike-and-slab priors.
The package is implemented the recent improvements in the Bayesian graphical models' literature, including Wang (2015).
To speed up the computations, the computationally intensive tasks of the package are implemented in C++
in parallel using OpenMP.
To cite ssgraph in publications use:
Mohammadi R. (2020). ssgraph: Bayesian Graphical Estimation using Spike-and-Slab Priors, R package version 1.11, https://cran.r-project.org/package=ssgraph
Reza Mohammadi [email protected]
Wang, H. (2015). Scaling it up: Stochastic search structure learning in graphical models, Bayesian Analysis, 10(2):351-377
George, E. I. and McCulloch, R. E. (1993). Variable selection via Gibbs sampling. Journal of the American Statistical Association, 88(423):881-889
Griffin, J. E. and Brown, P. J. (2010) Inference with normal-gamma prior distributions in regression problems. Bayesian Analysis, 5(1):171-188
Mohammadi, A. et al (2017). Bayesian modelling of Dupuytren disease by using Gaussian copula graphical models, Journal of the Royal Statistical Society: Series C, 66(3):629-645
Mohammadi, R. and Wit, E. C. (2019). BDgraph: An R
Package for Bayesian Structure Learning in Graphical Models, Journal of Statistical Software, 89(3):1-30
Mohammadi, A. and Wit, E. C. (2015). Bayesian Structure Learning in Sparse Gaussian Graphical Models, Bayesian Analysis, 10(1):109-138
## Not run: library( ssgraph ) # Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 100, p = 8, size = 10, vis = TRUE ) # Running algorithm based on GGMs ssgraph.obj <- ssgraph( data = data.sim, iter = 5000, save = TRUE ) summary( ssgraph.obj ) # To compare the result with true graph compare( pred = ssgraph.obj, actual = data.sim, main = c( "Target", "ssgraph" ), vis = TRUE ) plotroc( pred = sgraph.obj, actual = data.sim ) ## End(Not run)
## Not run: library( ssgraph ) # Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 100, p = 8, size = 10, vis = TRUE ) # Running algorithm based on GGMs ssgraph.obj <- ssgraph( data = data.sim, iter = 5000, save = TRUE ) summary( ssgraph.obj ) # To compare the result with true graph compare( pred = ssgraph.obj, actual = data.sim, main = c( "Target", "ssgraph" ), vis = TRUE ) plotroc( pred = sgraph.obj, actual = data.sim ) ## End(Not run)
S3
class "ssgraph"
Visualizes structure of the selected graphs which could be a graph with links for which their estimated posterior probabilities are greater than 0.5 or graph with the highest posterior probability.
## S3 method for class 'ssgraph' plot( x, cut = 0.5, ... )
## S3 method for class 'ssgraph' plot( x, cut = 0.5, ... )
x |
An object of |
cut |
Threshold for including the links in the selected graph based on the estimated posterior probabilities of the links; See the examples. |
... |
System reserved (no specific usage). |
Reza Mohammadi [email protected]
Mohammadi, R. and Wit, E. C. (2019). BDgraph: An R
Package for Bayesian Structure Learning in Graphical Models, Journal of Statistical Software, 89(3):1-30
Mohammadi, A. and Wit, E. C. (2015). Bayesian Structure Learning in Sparse Gaussian Graphical Models, Bayesian Analysis, 10(1):109-138
Mohammadi, A. et al (2017). Bayesian modelling of Dupuytren disease by using Gaussian copula graphical models, Journal of the Royal Statistical Society: Series C, 66(3):629-645
## Not run: # Generating multivariate normal data from a 'scale-free' graph data.sim <- bdgraph.sim( n = 60, p = 7, graph = "scale-free", vis = TRUE ) ssgraph.obj <- ssgraph( data = data.sim ) plot( ssgraph.obj ) plot( ssgraph.obj, cut = 0.3 ) ## End(Not run)
## Not run: # Generating multivariate normal data from a 'scale-free' graph data.sim <- bdgraph.sim( n = 60, p = 7, graph = "scale-free", vis = TRUE ) ssgraph.obj <- ssgraph( data = data.sim ) plot( ssgraph.obj ) plot( ssgraph.obj, cut = 0.3 ) ## End(Not run)
S3
class "bdgraph
" Provides predict values of the results for function ssgraph
.
## S3 method for class 'ssgraph' predict( object, iter = 1, ... )
## S3 method for class 'ssgraph' predict( object, iter = 1, ... )
object |
object of |
iter |
number of predictions. |
... |
additional parameters. |
Reza Mohammadi [email protected]
Wang, H. (2015). Scaling it up: Stochastic search structure learning in graphical models, Bayesian Analysis, 10(2):351-377
Mohammadi, A. et al (2017). Bayesian modelling of Dupuytren disease by using Gaussian copula graphical models, Journal of the Royal Statistical Society: Series C, 66(3):629-645
## Not run: # Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 50, p = 6, size = 7, vis = TRUE ) ssgraph.obj <- ssgraph( data = data.sim ) predict( ssgraph.obj, iter = 20 ) ## End(Not run)
## Not run: # Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 50, p = 6, size = 7, vis = TRUE ) ssgraph.obj <- ssgraph( data = data.sim ) predict( ssgraph.obj, iter = 20 ) ## End(Not run)
S3
class "ssgraph"
Prints the information about the selected graph which could be a graph with links for which their estimated posterior probabilities are greater than 0.5 or graph with the highest posterior probability. It provides adjacency matrix, size and posterior probability of the selected graph.
## S3 method for class 'ssgraph' print( x, ... )
## S3 method for class 'ssgraph' print( x, ... )
x |
An object of |
... |
System reserved (no specific usage). |
Reza Mohammadi [email protected]
Mohammadi, R. and Wit, E. C. (2019). BDgraph: An R
Package for Bayesian Structure Learning in Graphical Models, Journal of Statistical Software, 89(3):1-30
Mohammadi, A. and Wit, E. C. (2015). Bayesian Structure Learning in Sparse Gaussian Graphical Models, Bayesian Analysis, 10(1):109-138
Mohammadi, A. et al (2017). Bayesian modelling of Dupuytren disease by using Gaussian copula graphical models, Journal of the Royal Statistical Society: Series C, 66(3):629-645
## Not run: # Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 50, p = 6, size = 7, vis = TRUE ) ssgraph.obj <- ssgraph( data = data.sim ) print( ssgraph.obj ) ## End(Not run)
## Not run: # Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 50, p = 6, size = 7, vis = TRUE ) ssgraph.obj <- ssgraph( data = data.sim ) print( ssgraph.obj ) ## End(Not run)
This function has a sampling algorithm for Bayesian model determination in undirected graphical models, based on spike-and-slab priors.
ssgraph( data, n = NULL, method = "ggm", not.cont = NULL, iter = 5000, burnin = iter / 2, var1 = 4e-04, var2 = 1, lambda = 1, g.prior = 0.2, g.start = "full", sig.start = NULL, save = FALSE, cores = NULL, verbose = TRUE )
ssgraph( data, n = NULL, method = "ggm", not.cont = NULL, iter = 5000, burnin = iter / 2, var1 = 4e-04, var2 = 1, lambda = 1, g.prior = 0.2, g.start = "full", sig.start = NULL, save = FALSE, cores = NULL, verbose = TRUE )
data |
There are two options: (1) an ( |
n |
The number of observations. It is needed if the |
method |
A character with two options |
not.cont |
For the case |
iter |
The number of iteration for the sampling algorithm. |
burnin |
The number of burn-in iteration for the sampling algorithm. |
var1 |
Value for the variance of the the prior of precision matrix for the places that there is no link in the graph. |
var2 |
Value for the variance of the the prior of precision matrix for the places that there is link in the graph. |
lambda |
Value for the parameter of diagonal element of the prior of precision matrix. |
g.prior |
For determining the prior distribution of each edge in the graph.
There are two options: a single value between |
g.start |
Corresponds to a starting point of the graph. It could be an ( |
sig.start |
Corresponds to a starting point of the covariance matrix. It must be positive definite matrix. |
save |
Logical: if FALSE (default), the adjacency matrices are NOT saved. If TRUE, the adjacency matrices after burn-in are saved. |
cores |
The number of cores to use for parallel execution.
The default is to use |
verbose |
logical: if TRUE (default), report/print the MCMC running time. |
An object with S3
class "ssgraph"
is returned:
p_links |
An upper triangular matrix which corresponds the estimated posterior probabilities of all possible links. |
K_hat |
The posterior estimation of the precision matrix. |
For the case "save = TRUE" is also returned:
sample_graphs |
A vector of strings which includes the adjacency matrices of visited graphs after burn-in. |
graph_weights |
A vector which includes the counted numbers of visited graphs after burn-in. |
all_graphs |
A vector which includes the identity of the adjacency matrices for all iterations after burn-in. It is needed for monitoring the convergence of the MCMC sampling algorithm. |
all_weights |
A vector which includes the waiting times for all iterations after burn-in. It is needed for monitoring the convergence of the MCMC sampling algorithm. |
Reza Mohammadi [email protected]
Wang, H. (2015). Scaling it up: Stochastic search structure learning in graphical models, Bayesian Analysis, 10(2):351-377
George, E. I. and McCulloch, R. E. (1993). Variable selection via Gibbs sampling. Journal of the American Statistical Association, 88(423):881-889
Griffin, J. E. and Brown, P. J. (2010) Inference with normal-gamma prior distributions in regression problems. Bayesian Analysis, 5(1):171-188
Mohammadi, A. et al (2017). Bayesian modelling of Dupuytren disease by using Gaussian copula graphical models, Journal of the Royal Statistical Society: Series C, 66(3):629-645
Mohammadi, R. and Wit, E. C. (2019). BDgraph: An R
Package for Bayesian Structure Learning in Graphical Models, Journal of Statistical Software, 89(3):1-30
Mohammadi, A. and Wit, E. C. (2015). Bayesian Structure Learning in Sparse Gaussian Graphical Models, Bayesian Analysis, 10(1):109-138
bdgraph
, bdgraph.mpl
, summary.ssgraph
, compare
# Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 80, p = 6, size = 6, vis = TRUE ) # Running algorithm based on GGMs ssgraph.obj <- ssgraph( data = data.sim, iter = 1000 ) summary( ssgraph.obj ) # To compare the result with true graph compare( pred = ssgraph.obj, actual = data.sim, main = c( "Target", "ssgraph" ), vis = TRUE ) plotroc( pred = ssgraph.obj, actual = data.sim ) ## Not run: # Running algorithm with starting points from previous run ssgraph.obj2 <- ssgraph( data = data.sim, iter=5000, g.start = ssgraph.obj ) compare( pred = list( ssgraph.obj, ssgraph.obj2 ), actual = data.sim, main = c( "Target", "Frist run", "Second run" ), vis = TRUE ) plotroc( pred = list ( ssgraph.obj, ssgraph.obj2 ), actual = data.sim, label = c( "Frist run", "Second run" ) ) ## End(Not run)
# Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 80, p = 6, size = 6, vis = TRUE ) # Running algorithm based on GGMs ssgraph.obj <- ssgraph( data = data.sim, iter = 1000 ) summary( ssgraph.obj ) # To compare the result with true graph compare( pred = ssgraph.obj, actual = data.sim, main = c( "Target", "ssgraph" ), vis = TRUE ) plotroc( pred = ssgraph.obj, actual = data.sim ) ## Not run: # Running algorithm with starting points from previous run ssgraph.obj2 <- ssgraph( data = data.sim, iter=5000, g.start = ssgraph.obj ) compare( pred = list( ssgraph.obj, ssgraph.obj2 ), actual = data.sim, main = c( "Target", "Frist run", "Second run" ), vis = TRUE ) plotroc( pred = list ( ssgraph.obj, ssgraph.obj2 ), actual = data.sim, label = c( "Frist run", "Second run" ) ) ## End(Not run)
S3
class "ssgraph"
Provides a summary of the results for function ssgraph
.
## S3 method for class 'ssgraph' summary( object, round = 2, vis = TRUE, ... )
## S3 method for class 'ssgraph' summary( object, round = 2, vis = TRUE, ... )
object |
An object of |
round |
A value for rounding all probabilities to the specified number of decimal places. |
vis |
Visualize the results. |
... |
System reserved (no specific usage). |
selected_g |
The adjacency matrix corresponding to the selected graph which has the highest posterior probability. |
p_links |
An upper triangular matrix corresponding to the posterior probabilities of all possible links. |
K_hat |
The estimated precision matrix. |
Reza Mohammadi [email protected]
Mohammadi, R. and Wit, E. C. (2019). BDgraph: An R
Package for Bayesian Structure Learning in Graphical Models, Journal of Statistical Software, 89(3):1-30
Mohammadi, A. and Wit, E. C. (2015). Bayesian Structure Learning in Sparse Gaussian Graphical Models, Bayesian Analysis, 10(1):109-138
Mohammadi, A. et al (2017). Bayesian modelling of Dupuytren disease by using Gaussian copula graphical models, Journal of the Royal Statistical Society: Series C, 66(3):629-645
## Not run: # Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 50, p = 6, size = 7, vis = TRUE ) ssgraph.obj <- ssgraph( data = data.sim, save = TRUE ) summary( ssgraph.obj ) ## End(Not run)
## Not run: # Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 50, p = 6, size = 7, vis = TRUE ) ssgraph.obj <- ssgraph( data = data.sim, save = TRUE ) summary( ssgraph.obj ) ## End(Not run)