Learn R Programming

huge (version 2.0.0)

huge.generator: Data generator

Description

Implements the data generation from multivariate normal distributions with different graph structures, including "random", "hub", "cluster", "band" and "scale-free".

Usage

huge.generator(
  n = 200,
  d = 50,
  graph = "random",
  v = NULL,
  u = NULL,
  g = NULL,
  prob = NULL,
  vis = FALSE,
  verbose = TRUE
)

Value

An object with S3 class "sim" is returned:

data

The n by d matrix for the generated data

sigma

The covariance matrix for the generated data

omega

The precision matrix for the generated data

sigmahat

The empirical correlation matrix for the generated data

theta

The adjacency matrix of true graph structure (in sparse matrix representation) for the generated data

sparsity

The proportion of possible off-diagonal entries present in the graph; zero when d=1

Arguments

n

The number of observations (sample size), as an integer of at least 2. The default value is 200.

d

The positive integer number of variables (dimension). The default value is 50.

graph

The graph structure with 5 options: "random", "hub", "cluster", "band" and "scale-free".

v

A finite positive number used for the off-diagonal elements of the precision matrix, controlling the magnitude of partial correlations with u. The default value is 0.3.

u

A finite positive number added to the diagonal elements of the precision matrix to control the magnitude of partial correlations. The default value is 0.1.

g

A finite positive integer. For "cluster" or "hub" graph, g is the number of clusters or hubs; values above d are treated as d. The default is about d/20 if d >= 40 and min(2, d) otherwise. For "band" graph, g is the bandwidth and defaults to 1; values above d - 1 add no edges. Not applicable to "random" or "scale-free" graph.

prob

For "random" or "cluster" graph, a finite number in [0, 1] giving the probability that a pair of nodes has an edge. The default is min(1, 3/d) for "random". For "cluster", the default is min(1, 6*g/d) if d/g <= 30 and 0.3 otherwise. Not applicable to "hub", "band", or "scale-free" graph.

vis

A single non-missing logical. If TRUE, visualize the adjacency matrix, graph pattern, covariance matrix, and empirical correlation matrix. The default is FALSE.

verbose

A single non-missing logical. If FALSE, tracing output is disabled. The default is TRUE.

Details

Given the adjacency matrix theta, the graph patterns are generated as below:

(I) "random": Each pair of off-diagonal elements are randomly set theta[i,j]=theta[j,i]=1 for i!=j with probability prob, and 0 otherwise. It results in about d*(d-1)*prob/2 edges in the graph.

(II)"hub":The row/columns are evenly partitioned into g disjoint groups. Each group is associated with a "center" row i in that group. Each pair of off-diagonal elements are set theta[i,j]=theta[j,i]=1 for i!=j if j also belongs to the same group as i and 0 otherwise. It results in d - g edges in the graph.

(III)"cluster":The row/columns are evenly partitioned into g disjoint groups. Each pair of off-diagonal elements are set theta[i,j]=theta[j,i]=1 for i!=j with the probability probif both i and j belong to the same group, and 0 otherwise. It results in about g*(d/g)*(d/g-1)*prob/2 edges in the graph.

(IV)"band": Let b=min(g,d-1). The off-diagonal elements are set to be theta[i,j]=1 if 1<=|i-j|<=b and 0 otherwise. It results in (2d-1-b)*b/2 edges in the graph.

(V) "scale-free": The graph is generated using B-A algorithm. The initial graph has two connected nodes and each new node is connected to only one node in the existing graph with the probability proportional to the degree of the each node in the existing graph. It results in d-1 edges for d>=2; for d=1, the graph is empty.

The adjacency matrix theta has all diagonal elements equal to 0. To obtain a positive definite precision matrix, the smallest eigenvalue of theta*v (denoted by e) is computed. Then we set the precision matrix equal to theta*v+(|e|+0.1+u)I. The covariance matrix is then computed to generate multivariate normal data. Every graph type returns an empty graph with zero sparsity when d=1.

See Also

huge and huge-package

Examples

Run this code
## band graph with bandwidth 3
L = huge.generator(graph = "band", g = 3)
plot(L)

## random sparse graph
L = huge.generator(vis = TRUE)

## random dense graph
L = huge.generator(prob = 0.5, vis = TRUE)

## hub graph with 6 hubs
L = huge.generator(graph = "hub", g = 6, vis = TRUE)

## hub graph with 8 clusters
L = huge.generator(graph = "cluster", g = 8, vis = TRUE)

## scale-free graphs
L = huge.generator(graph="scale-free", vis = TRUE)

Run the code above in your browser using DataLab