Learn R Programming

simone (version 1.0-4)

rNetwork: Simulation of (clustered) Gaussian networks

Description

Simulates a network with various structures.

Usage


rNetwork(p,
         pi,
         alpha    = c(1),
         directed = FALSE, 
         name     = "a network",
         signed   = TRUE)

Arguments

p

the number of nodes of the simulated network.

pi

a matrix of cluster connectivity (see details).

alpha

a vector of cluster proportions.

directed

a logical indicating the directedness of the network.

name

a character string indicating the name of the network.

signed

a logical indicating whether partial correlations should be signed or all kept positive.

Value

Returns an object of class simone.network, that is, a list comprising

A

the \(p \times p\) adjacency matrix of the network, filled with 0 and 1's, which is symmetric if directed is FALSE.

Theta

a \(p \times p\) matrix of parameters of the associated Gaussian model, which depends on the directedness of the network: if directed, Theta contains the parameters of a VAR(1) model; if undirected, Theta is the concentration matrix (inverse of the covariance matrix) of a Gaussian vector

directed

a logicial indicating the directedness of the network.

clusters

a size-\(p\) factor indicating the node class. The number of levels is determined by the number of columns of the matrix of connectivity pi: the levels are labeled \(1,\dots,Q\) where \(Q\) is the number of clusters.

name

a character string containing the name of the network.

Details

Matrix pi should be a square matrix of the same size as vector alpha. When the network is not directed, pi should be symmetric. When the graph is directed, entry _ql corresponds to edges heading from class \(q\) to class \(\ell\).

Entries of pi can be either integers or real numbers. If they are integers, they are considered as the exact number of edges required from one class to another. Otherwise, they are considered as connectivity probabilities between classes. They should therefore sum up to at most 1. If they do not sum up to one excatly, the remaining value is considered as the probability for a node to belong to the dust class (connected to no other node).

See Also

coNetwork, plot.simone.network.

Examples

Run this code
# NOT RUN {
## generate an Erdos-Renyi network with 50 nodes and Pr of edges = 0.1
plot(rNetwork(p = 50, pi = 0.1, name = "an Erdos-Renyi network"))

## generate an network with 15 nodes and 25 randomly selected edges
plot(rNetwork(p = 15, pi = 25, name = "a 25 edges network"))

## generate an undirected network with an affiliation structure
PI <- matrix(c(15,2,2,50),2,2)
alpha <- c(1/3,2/3)
plot(rNetwork(p = 20, pi = PI, alpha = alpha,
                      name = "Affiliation, fixed num of edges"))

## generate a directed network with hubs
PI <- t(matrix(c(0.2,0.1,0.4,0,0.05,0.15,0,0.4,rep(0,8)),4,4))
alpha <- c(1/20,1/20,9/20,9/20)
plot(rNetwork(p = 55, pi = PI, alpha = alpha, directed = TRUE,
                      name = "Hubs structured network"))
# }

Run the code above in your browser using DataLab