SimulateAdjacency {fake} | R Documentation |
Simulation of undirected graph with block structure
Description
Simulates the adjacency matrix of an unweighted, undirected graph with no
self-loops. If topology="random"
, different densities in diagonal
(nu_within
) compared to off-diagonal (nu_between
) blocks can be
used.
Usage
SimulateAdjacency(
pk = 10,
implementation = HugeAdjacency,
topology = "random",
nu_within = 0.1,
nu_between = 0,
nu_mat = NULL,
...
)
Arguments
pk |
vector of the number of variables per group in the simulated
dataset. The number of nodes in the simulated graph is |
implementation |
function for simulation of the graph. By default,
algorithms implemented in |
topology |
topology of the simulated graph. If using
|
nu_within |
probability of having an edge between two nodes belonging to
the same group, as defined in |
nu_between |
probability of having an edge between two nodes belonging
to different groups, as defined in |
nu_mat |
matrix of probabilities of having an edge between nodes
belonging to a given pair of node groups defined in |
... |
additional arguments passed to the graph simulation function
provided in |
Details
Random graphs are simulated using the Erdos-Renyi algorithm.
Scale-free graphs are simulated using a preferential attachment algorithm.
More details are provided in huge.generator
.
Value
A symmetric adjacency matrix encoding an unweighted, undirected graph with no self-loops, and with different densities in diagonal compared to off-diagonal blocks.
References
Bodinier B, Filippi S, Nost TH, Chiquet J, Chadeau-Hyam M (2021). “Automated calibration for stability selection in penalised regression and graphical models: a multi-OMICs network application exploring the molecular response to tobacco smoking.” https://arxiv.org/abs/2106.02521.
Jiang H, Fei X, Liu H, Roeder K, Lafferty J, Wasserman L, Li X, Zhao T (2021). huge: High-Dimensional Undirected Graph Estimation. R package version 1.3.5, https://CRAN.R-project.org/package=huge.
See Also
Other simulation functions:
SimulateClustering()
,
SimulateComponents()
,
SimulateCorrelation()
,
SimulateGraphical()
,
SimulateRegression()
,
SimulateStructural()
Examples
# Simulation of a scale-free graph with 20 nodes
adjacency <- SimulateAdjacency(pk = 20, topology = "scale-free")
plot(adjacency)
# Simulation of a random graph with three connected components
adjacency <- SimulateAdjacency(
pk = rep(10, 3),
nu_within = 0.7, nu_between = 0
)
plot(adjacency)
# Simulation of a random graph with block structure
adjacency <- SimulateAdjacency(
pk = rep(10, 3),
nu_within = 0.7, nu_between = 0.03
)
plot(adjacency)
# User-defined function for graph simulation
CentralNode <- function(pk, hub = 1) {
theta <- matrix(0, nrow = sum(pk), ncol = sum(pk))
theta[hub, ] <- 1
theta[, hub] <- 1
diag(theta) <- 0
return(theta)
}
simul <- SimulateAdjacency(pk = 10, implementation = CentralNode)
plot(simul) # star
simul <- SimulateAdjacency(pk = 10, implementation = CentralNode, hub = 2)
plot(simul) # variable 2 is the central node