| rgnmix {sna} | R Documentation |
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 |
a class-by-class mixing matrix, containing either mixing rates (for |
mode |
|
diag |
logical; should loops be allowed? |
method |
the generation method to use. |
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
rguman, rgnm, blockmodel.expand
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)