Learn R Programming

BDgraph (version 2.41)

bdgraph.sim: Graph data simulation

Description

Simulating multivariate distributions with different types of underlying graph structures, including "random", "cluster", "scale-free", "hub", "fixed", "circle", "AR(1)", "AR(2)", and "star". Based on the underling graph structure, it generates four different types of datasets, including multivariate Gaussian, non-Gaussian, discrete, or mixed data. This function can be used also for only simulating graphs by option n=0, as a default.

Usage

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

Arguments

p

The number of variables (nodes).

graph

The graph structure with option "random", "cluster", "scale-free", "hub", "fixed", "circle", "AR(1)", "AR(2)", and "star". It also could be an adjacency matrix corresponding to a graph structure (an upper triangular matrix in which \(g_{ij}=1\) if there is a link between notes \(i\) and \(j\), otherwise \(g_{ij}=0\)).

n

The number of samples required. Note that for the case n = 0, only graph is generated.

type

Type of data with four options "Gaussian" (default), "non-Gaussian", "discrete", and "mixed". For option "Gaussian", data are generated from multivariate normal distribution. For option "non-Gaussian", data are transfered multivariate normal distribution to continuous multivariate non-Gaussian distribution. For option "discrete", data are transfered from multivariate normal distribution to discrete multivariat distribution. For option "mixed", data are transfered from multivariate normal distribution to mixture of 'count', 'ordinal', 'non-Gaussian', 'binary' and 'Gaussian', respectively.

prob

If graph="random", it is the probability that a pair of nodes has a link.

size

The number of links in the true graph (graph size).

mean

A vector specifies the mean of the variables.

class

If graph="cluster", it is the number of classes.

cut

If type="discrete", it is the number of categories for simulating discrete data.

b

The degree of freedom for G-Wishart distribution, \(W_G(b, D)\).

D

The positive definite \((p \times p)\) "scale" matrix for G-Wishart distribution, \(W_G(b, D)\). The default is an identity matrix.

K

If graph="fixed", it is a positive-definite symmetric matrix specifies as a true precision matrix.

sigma

If graph="fixed", it is a positive-definite symmetric matrix specifies as a true covariance matrix.

vis

Visualize the true graph structure.

Value

An object with S3 class "sim" is returned:

data

Generated data as an (\(n \times p\)) matrix.

sigma

The covariance matrix of the generated data.

K

The precision matrix of the generated data.

G

The 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.05108

Mohammadi, A. et al (2017). Bayesian modelling of Dupuytren disease by using Gaussian copula graphical models, Journal of the Royal Statistical Society: Series C

Mohammadi, A., Massam H., and G. Letac (2017). The Ratio of Normalizing Constants for Bayesian Graphical Gaussian Model Selection, arXiv preprint arXiv:1706.04416

See Also

bdgraph

Examples

Run this code
# NOT RUN {
# Generating multivariate normal data from a 'random' graph
data.sim <- bdgraph.sim( p = 10, n = 50, prob = 0.3, vis = TRUE )
print( data.sim )
     
# Generating multivariate normal data from a 'hub' graph
data.sim <- bdgraph.sim( p = 6, n = 3, graph = "hub", vis = FALSE )
round( data.sim $ data, 2 )
     
# Generating mixed data from a 'hub' graph 
data.sim <- bdgraph.sim( p = 8, n = 10, graph = "hub", type = "mixed" )
round( data.sim $ data, 2 )

# Generating only a 'hub' graph (with no data) 
graph.sim <- bdgraph.sim( p = 8, graph = "scale-free" )
plot( graph.sim )
graph.sim $ G
# }

Run the code above in your browser using DataLab