Learn R Programming

BDgraph (version 2.19)

bdgraph.sim: Synthetic graph data generator

Description

This function implements a synthetic graph data generation for multivariate distributions with different types of underlying graph structures, including "random", "cluster", "scale-free", "hub", "fixed", and "circle". Based on the underling graph structure, it generates four different types of datasets, including multivariate Gaussian, non-Gaussian, discrete, or mixed data.

Usage

bdgraph.sim( n = 2, p = 10, graph = "random", size = NULL, prob = 0.2, 
             class = NULL, type = "Gaussian", cut = 4, b = 3, D = diag(p), 
             K = NULL, sigma = NULL, mean = 0, vis = FALSE )

Arguments

n
The number of samples required. The default value is 2.
p
The number of variables (nodes). The default value is 10.
graph
The graph structure with option "random" (as a default), "cluster", "scale-free", "hub", "fixed", and "circle". It also could be adjacency matrix corresponding to a graph
size
The number of links in the true graph (graph size).
prob
For a "random" graph, it is the probability that a pair of nodes has a link. The default value is 0.2.
class
Number of classes for option "cluster".
type
Type of data with four options "Gaussian" (as a default), "non-Gaussian", "discrete", and "mixed". For option "Gaussian", data are generated from multivariate normal distribution. For
cut
Number of categories for simulating discrete data (type = "discrete"). The default value is 4.
b
The degree of freedom for G-Wishart distribution, $W_G(b, D)$. The default is 3.
D
The positive definite $(p \times p)$ "scale" matrix for G-Wishart distribution, $W_G(b, D)$. The default is an identity matrix.
K
A positive-definite symmetric matrix specifying the precision matrix. It is for option graph = "fixed".
sigma
A positive-definite symmetric matrix specifying the covariance matrix. It is for option graph = "fixed".
mean
A vector specifying the mean of the variables. The default value is a zero vector.
vis
Visualize the true graph pattern. The default value is FALSE.

Value

  • An object with S3 class "simulate" is returned:
  • dataGenerated data as a $n \times p$ matrix.
  • sigmaThe covariance matrix of the generated data.
  • KThe precision matrix of the generated data.
  • GThe adjacency matrix corresponding to the true graph structure.

References

Mohammadi, A. and E. Wit (2015). Bayesian Structure Learning in Sparse Gaussian Graphical Models, Bayesian Analysis, 10(1):109-138 Mohammadi, A. and E. Wit (2015). BDgraph: An R Package for Bayesian Structure Learning in Graphical Models, Arxiv preprint arXiv:1501.05108v2 Mohammadi, A., F. Abegaz Yazew, E. van den Heuvel, and E. Wit (2015). Bayesian Modeling of Dupuytren Disease Using Gaussian Copula Graphical Models, Arxiv preprint arXiv:1501.04849v2

See Also

bdgraph

Examples

Run this code
# generating multivariate normal data from a 'random' graph
data.sim <- bdgraph.sim( n = 50, p = 10, prob = 0.3, vis = TRUE )
print(data.sim)

# generating multivariate normal data from a 'hub' graph
data.sim <- bdgraph.sim( n = 3, p = 6, graph = "hub", vis = FALSE )
data.sim $ data

# generating mixed data from a 'hub' graph 
data.sim <- bdgraph.sim( n = 10, p = 8, graph = "hub", type = "mixed" )
data.sim $ data

Run the code above in your browser using DataLab