mixingm | R Documentation |
Creating network mixing matrices (mixingm()
) and data frames (mixingdf()
).
mixingm(object, ...) ## S3 method for class 'igraph' mixingm( object, rattr, cattr = rattr, full = FALSE, directed = is.directed(object), loops = any(is.loop(object)), ... ) mixingdf(object, ...) ## S3 method for class 'table' mixingdf(object, ...) ## S3 method for class 'igraph' mixingdf(object, ...)
object |
R object, see Details for available methods |
... |
other arguments passed to/from other methods |
rattr |
name of the vertex attribute or an attribute itself as a vector.
If |
cattr |
name of the vertex attribute or an attribute itself as a vector. If supplied, used for columns in the mixing matrix. |
full |
logical, whether two- or three-dimensional mixing matrix should be returned. |
directed |
logical, whether the network is directed. By default,
directedness of the network is determined with |
loops |
logical, whether loops are allowed. By default it is |
Network mixing matrix is, traditionally, a two-dimensional cross-classification of edges depending on the values of a specified vertex attribute for tie sender and tie receiver. It is an important tool for assessing network homophily or segregation.
Let G be the number of distinct values of the vertex attribute in question. We may say that we have G mutually exclusive groups in the network. The mixing matrix is a GxG matrix such that m[ij] is the number of ties send by vertices in group i to vertices in group j. The diagonal of that matrix is of special interest as, say, m[ii] is the number of ties within group i.
A full mixing matrix is a three-dimensional array that cross-classifies all network dyads depending on:
the value of the vertex attribute for tie sender
the value of the vertex attribute for tie receiver
the status of the dyad, i.e. whether it is connected or not
The two-dimensional version is a so-called "contact layer" of the three-dimensional version.
If object
is of class "igraph," mixing matrix is created for the
network in object
based on vertex attributes supplied in arguments
rattr
and optionally cattr
.
If only rattr
is specified (or, equivalently, rattr
and cattr
are
identical), the result will be a mixing matrix G \times G if full
is FALSE
or GxGx2 if full
is TRUE
. Where
G is the number of categories of vertex attribute specified by
rattr
.
If rattr
and cattr
can be used to specify different vertex attributes
for tie sender and tie receiver.
Function mixingm()
, depending on full
argument, a two- or
three-dimensional array crossclassifying connected or all dyads in
object
. For undirected network and if foldit
is TRUE
(default), the
matrix is folded onto the upper triangle (entries in lower triangle are 0).
Function mixingdf()
returns non-zero entries of a mixing matrix (as
returned by mixingm()
), but organized in a data frame with columns:
ego
, alter
– group membership of ego an alter
tie
– present only if full=TRUE
, with TRUE
or FALSE
for connected
and disconnected dyads respectively
n
– counts
if(requireNamespace("igraph", quietly = TRUE)) { # some directed network net <- igraph::make_graph(c(1,2, 1,3, 2,3, 4,5, 1,4, 1,5, 4,2, 5,3)) igraph::V(net)$type <- c(1,1,1, 2,2) mixingm(net, "type") mixingm(net, "type", full=TRUE) # as undirected mixingm( igraph::as.undirected(net), "type") mixingm(net, "type") mixingm(net, "type", full=TRUE) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.