generateToyData: Generate toy data for running GADAG

View source: R/generateToyData.R

generateToyDataR Documentation

Generate toy data for running GADAG

Description

This function generates toy data that can be used to run GADAG: the adjacency matrix of a DAG with p nodes and the design matrix with n observations of the distribution of the p nodes.

Usage

generateToyData(n, p, edgemin = 0, Cov = diag(p), type = "star", seed = 42)

Arguments

n

Number of samples in the design matrix.

p

Number of nodes of the DAG.

edgemin

Minimal value for the non-null edges of the DAG (between 0 and 1).

Cov

(optional) Covariance matrix for the noise variables (identity matrix by default)

type

Form of the DAG. It can be chosen between 7 alternatives: "star", "bistar", "full", "path", "quadristar", "sixstar" (see details below).

seed

Fix the seed.

Details

One of the following seven alternatives can be chosen for the DAG form:

"star"

star-shaped DAG (all active edges start from node 1),

"bistar"

half of the edges start from node 1 and the other half from node 2,

"full"

full DAG (all the edges are active),

"path"

path-shaped DAG (all the nodes are connected by a single path),

"quadristar"

node 1 is connected to nodes 2 to 4, each being connected to 1/3 of the rest of the nodes,

"sixstar"

same as "quadristar", with 6 nodes.

Value

A list containing the design nxp matrix X (with samples in rows and variables in columns) and the adjacency matrix G associated to the DAG with p nodes.

Author(s)

Magali Champion [aut, cre], Victor Picheny [aut], Matthieu Vignes [aut].

See Also

GADAG, GADAG_Run.

Examples

 #############################################################
 # Generating toy data
 #############################################################
 toy_data <- generateToyData(n=100, p=10)

 # toy_data is a list of two matrices corresponding to a "star"
 # DAG (node 1 activates all other nodes):
 # - toy_data$X is a 100x10 design matrix
 # - toy_data$G is the 10x10 adjacency matrix (ground trough)

 ## Not run: 
 # generate another type of data: a DAG with 100 nodes in a path form
 toy_data <- generateToyData(n=100, p=100,type="path")
 
## End(Not run)

 ## Not run: 
 # set the minimal edge value to 1
 toy_data <- generateToyData(n=100, p=10, edgemin=1) # all edges are set to 1
 
## End(Not run)

 ## Not run: 
 # non-independent noises
 A <- matrix(runif(10^2)*2-1, ncol=10)
 Sigma <- t(A) %*% A
 toy_data <- generateToyData(n=100, p=10, edgemin=1, Cov = Sigma)
 
## End(Not run)

GADAG documentation built on Sept. 10, 2026, 5:07 p.m.