<center> ssgraph with simple example <center>

knitr::opts_chunk$set( collapse = TRUE, comment = ">", fig.width = 7, fig.height = 7, fig.align = "center" )

The R package ssgraph is designed for Bayesian structure learning in graphical models using spike-and-slab priors. To speed up the computations, the computationally intensive tasks of the package are implemented in C++ in parallel using OpenMP.

Install ssgraph using

install.packages( "ssgraph" )

First, we install ssgraph

library( ssgraph )

Example

This is a simple example to see the performance of the package for the Gaussian graphical models. First, by using the function bdgraph.sim(), we simulate 100 observations (n = 100) from a multivariate Gaussian distribution with 8 variables (p = 8) and “scale-free” graph structure, as follows:

set.seed( 10 )

data.sim <- bdgraph.sim( n = 100, p = 8, graph = "scale-free", vis = TRUE )

round( head( data.sim $ data, 4 ), 2 )

Since the generated data are Gaussian, we run ssgraph function by choosing method = "ggm", as follows:

ssgraph.obj <- ssgraph( data = data.sim, method = "ggm", iter = 5000, 
                        save = TRUE, verbose = FALSE )

summary( ssgraph.obj )

To compare the result with true graph

compare( data.sim, ssgraph.obj, main = c( "Target", "ssgraph" ), vis = TRUE )
plotroc( ssgraph.obj, data.sim, cut = 200 )


Try the ssgraph package in your browser

Any scripts or data that you put into this service are public.

ssgraph documentation built on Dec. 28, 2022, 2:37 a.m.