bdgraph.sim {BDgraph}R Documentation

Graph data simulation

Description

Simulating multivariate distributions with different types of underlying graph structures, including "random", "cluster", "smallworld", "scale-free", "lattice", "hub", "star", "circle", "AR(1)", and "AR(2)". Based on the underlying graph structure, the function generates different types of multivariate data, including "Gaussian", "non-Gaussian", "categorical", "pois" (Poisson), "nbinom" (negative binomial), "dweibull" (discrete Weibull), "binary", "t" (t-distribution), "alternative-t", or "mixed" data. This function can be used also for simulating only graphs by setting the option n=0 (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, 
             q = exp(-1), beta = 1, vis = FALSE, rewire = 0.05,
             range.mu = c( 3, 5 ), range.dispersion = c( 0.01, 0.1 ), nu = 1 )

Arguments

p

number of variables (nodes).

graph

graph structure with options "random", "cluster", "smallworld", "scale-free", "lattice", "hub", "star", "circle", "AR(1)", and "AR(2)". It could also be an adjacency matrix corresponding to a graph structure (an upper triangular matrix in which gij=1g_{ij}=1 if there is a link between nodes ii and jj, otherwise gij=0g_{ij}=0).

n

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

type

type of data with options "Gaussian" (default), "non-Gaussian", "categorical", "pois", "nbinom", "dweibull", "binary", "mixed", "t", and "alternative-t". For the option "Gaussian", data are generated from a multivariate normal distribution. For the option "non-Gaussian", data are transfered from a multivariate normal distribution to a continuous multivariate non-Gaussian distribution via Exponential marginals. For the option "categorical", data are transfered from a multivariate normal distribution to multivariate 'categorical' data. For the option "pois", data are transfered from a multivariate normal distribution to a multivariate Poisson distribution. For the option "nbinom", data are transfered from a multivariate normal distribution to a multivariate Negative Binomial distribution. For the option "dweibull", data are transfered from a multivariate normal distribution to a multivariate discrete Weibull distribution with parameters q and beta. For the option "binary", data are generated directly from the joint distribution, in this case pp must be less than 1717. For the option "mixed", data are transfered from a multivariate normal distribution to a mixture of 'categorical', 'non-Gaussian', 'binary' and 'Gaussian', respectively.

prob

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

size

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

mean

vector specifying the mean of the variables.

class

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

cut

if type = "categorical", it is the number of categories for simulating 'categorical' data.

b

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

D

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

K

if graph = "fixed", it is a positive-definite symmetric matrix, corresponding to the true precision matrix.

sigma

if graph = "fixed", it is a positive-definite symmetric matrix corresponding to the true covariance matrix.

q, beta

if type = "dweibull", they are the parameters of the discrete Weibull distribution with density

p(x,q,β)=qxβq(x+1)β,x={0,1,2,}.p( x, q, \beta ) = q^{x^{\beta}}-q^{(x+1)^{\beta}}, \quad \forall x = \{ 0, 1, 2, \ldots \}.

They can be given either as a vector of length p or as an (n×pn \times p) matrix, e.g. if covariates are available and a regression model is used.

vis

visualize the true graph structure.

rewire

rewiring probability for smallworld network. Must be between 0 and 1.

range.mu, range.dispersion

if type = "nbinom", vector with two elements specifying the range of parameters for the Negative Binomial distribution.

nu

if type = "t" or "alternative-t", it is the parameter of the t distribution with density.

Value

An object with S3 class "sim" is returned:

data

generated data as an (n×pn \times p) matrix.

sigma

covariance matrix of the generated data.

K

precision matrix of the generated data.

G

adjacency matrix corresponding to the true graph structure.

Author(s)

Reza Mohammadi a.mohammadi@uva.nl, Pariya Behrouzi, Veronica Vinciotti, Ernst Wit, and Alexander Christensen

References

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, doi:10.18637/jss.v089.i03

See Also

graph.sim, bdgraph, bdgraph.mpl

Examples

## 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 'scale-free' graph (with no data) 
graph.sim <- bdgraph.sim( p = 8, graph = "scale-free" )

plot( graph.sim )

graph.sim $ G

## End(Not run)

[Package BDgraph version 2.72 Index]