Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

rgnmix

Draw Mixing-Conditioned Random Graphs


Description

rgnmix generates random draws from a mixing-conditioned uniform random graph distribution.

Usage

rgnmix(n, tv, mix, mode = "digraph", diag = FALSE, 
    method = c("probability", "exact"), return.as.edgelist = FALSE)

Arguments

n

the number of graphs to generate.

tv

a vector of types or classes (one entry per vertex), corresponding to the rows and columns of mix. (Note that the total number of vertices generated will be length(tv).)

mix

a class-by-class mixing matrix, containing either mixing rates (for method=="probability") or edge counts (for method=="exact").

mode

"digraph" for directed graphs, or "graph" for undirected graphs.

diag

logical; should loops be allowed?

method

the generation method to use. "probability" results in a Bernoulli edge distribution (conditional on the underlying rates), while "exact" results in a uniform draw conditional on the exact per-block edge distribution.

return.as.edgelist

logical; should the resulting graphs be returned in sna edgelist form?

Details

The generated graphs (in either adjacency or edgelist form).

Value

rgnmix draws from a simple generalization of the Erdos-Renyi N,M family (and the related N,p family), generating graphs with fixed expected or realized mixing rates. Mixing is determined by the mix argument, which must contain a class-by-class matrix of mixing rates (either edge probabilities or number of realized edges). The class for each vertex is specified in tv, whose entries must correspond to the rows and columns of mix. The resulting functionality is much like blockmodel.expand, although more general (and in some cases more efficient).

Author(s)

Carter T. Butts buttsc@uci.edu

References

Wasserman, S. and Faust, K. (1994). Social Network Analysis: Methods and Applications. Cambridge: Cambridge University Press.

See Also

Examples

#Draw a random mixing matrix
mix<-matrix(runif(9),3,3)

#Generate a graph with 4 members per class
g<-rgnmix(1,rep(1:3,each=4),mix)
plot.sociomatrix(g)                                 #Visualize the result

#Repeat the exercise, using the exact method
mix2<-round(mix*8)                                  #Draw an exact matrix
g<-rgnmix(1,rep(1:3,each=4),mix2,method="exact")
plot.sociomatrix(g)

sna

Tools for Social Network Analysis

v2.6
GPL (>= 2)
Authors
Carter T. Butts [aut, cre, cph]
Initial release
2020-10-5

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.