The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

ssgraph with simple example

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 )
>       [,1]  [,2]  [,3]  [,4]  [,5]  [,6]  [,7] [,8]
> [1,] -0.83  0.72 -0.26 -0.29  0.46  0.08 -0.85 0.35
> [2,] -0.40 -0.38  0.78  1.90  0.35  0.51 -0.97 0.38
> [3,] -0.65  0.21 -0.80 -0.64 -0.72  0.40  0.89 0.94
> [4,]  0.74 -0.38  0.18 -0.95  0.23 -1.44 -0.85 0.03

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 )

> $selected_g
>      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
> [1,]    0    0    0    1    0    0    1    1
> [2,]    0    0    1    0    1    1    0    0
> [3,]    0    0    0    0    0    0    0    0
> [4,]    0    0    0    0    0    0    0    0
> [5,]    0    0    0    0    0    0    0    0
> [6,]    0    0    0    0    0    0    0    0
> [7,]    0    0    0    0    0    0    0    0
> [8,]    0    0    0    0    0    0    0    0
> 
> $p_links
>      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
> [1,]    0 0.12 0.04 0.96 0.05 0.07 0.57 0.99
> [2,]    0 0.00 1.00 0.04 0.98 1.00 0.05 0.11
> [3,]    0 0.00 0.00 0.45 0.04 0.04 0.03 0.06
> [4,]    0 0.00 0.00 0.00 0.02 0.07 0.08 0.04
> [5,]    0 0.00 0.00 0.00 0.00 0.06 0.15 0.02
> [6,]    0 0.00 0.00 0.00 0.00 0.00 0.14 0.03
> [7,]    0 0.00 0.00 0.00 0.00 0.00 0.00 0.05
> [8,]    0 0.00 0.00 0.00 0.00 0.00 0.00 0.00
> 
> $K_hat
>       [,1]  [,2]  [,3]  [,4]  [,5]  [,6]  [,7]  [,8]
> [1,]  1.21 -0.03  0.00 -0.36 -0.01 -0.02 -0.17 -0.42
> [2,] -0.03  2.14 -1.03  0.01 -0.45 -0.59 -0.01 -0.03
> [3,]  0.00 -1.03  1.87 -0.14  0.00 -0.01  0.00 -0.01
> [4,] -0.36  0.01 -0.14  1.25  0.00 -0.02  0.02  0.00
> [5,] -0.01 -0.45  0.00  0.00  1.15  0.02  0.04  0.00
> [6,] -0.02 -0.59 -0.01 -0.02  0.02  1.05 -0.03 -0.01
> [7,] -0.17 -0.01  0.00  0.02  0.04 -0.03  1.11  0.01
> [8,] -0.42 -0.03 -0.01  0.00  0.00 -0.01  0.01  1.22

To compare the result with true graph

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

>                Target ssgraph
> True Positive       6   6.000
> True Negative      22  21.000
> False Positive      0   1.000
> False Negative      0   0.000
> F1-score            1   0.923
> Specificity         1   0.955
> Sensitivity         1   1.000
> MCC                 1   0.905
plotroc( ssgraph.obj, data.sim, cut = 200 )

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.