Using a categorical vertex attribute, construct a matrix depicting network mixing patterns.
as_mixing_matrix(g, dim1, dim2 = NULL, direction = c("all", "out", "in"))
g |
|
---|---|
dim1 | Either the name of a node/vertex attribute or vector of same
length as the number of nodes in |
dim2 | If not provided, the same as |
direction |
|
<dtrMatrix>
g
is undirected and dim1
and dim2
refer to same dimension.
<dgeMatrix>
g
is directed or dim1
and dim2
refer to different dimensions.
<ddiMatrix>
g
exhibits 100
If g
is undirected, dim1
corresponds to the rows of the returned
mixing matrix and dim2
corresponds to the columns.
If dim1
and dim2
refer to the same dimension/attribute, only the
upper triangle of the returned mixing matrix is used.
If g
is directed, the rows of the returned mixing matrix correspond
to the source of ties while the columns correspond to the target of ties.
as_mixing_matrix(jemmah_islamiyah, dim1 = "role")#> 5 x 5 Matrix of class "dtrMatrix" #> #> command team operation assistant bomb maker #> command team 6 16 30 #> operation assistant . 2 10 #> bomb maker . . 20 #> suicide bomber . . . #> Team Lima . . . #> #> suicide bomber Team Lima #> command team 2 8 #> operation assistant 2 0 #> bomb maker 10 0 #> suicide bomber 0 8 #> Team Lima . 12as_mixing_matrix(jemmah_islamiyah, dim1 = "name", dim2 = "role")#> 17 x 5 Matrix of class "dgeMatrix" #> #> command team operation assistant bomb maker suicide bomber Team Lima #> MUKLAS 2 2 5 0 0 #> AMROZI 3 1 0 0 0 #> IMRON 3 0 5 1 0 #> SAMUDRA 2 3 5 1 4 #> DULMATIN 3 1 4 1 0 #> IDRIS 2 3 5 0 0 #> MUBAROK 2 1 0 0 0 #> AZAHARI 3 1 4 1 0 #> GHONI 3 1 4 1 0 #> ARNASAN 1 0 0 0 4 #> RAUF 1 0 0 1 3 #> OCTAVIA 1 0 0 1 3 #> HIDAYAT 1 0 0 1 3 #> JUNAEDI 1 0 0 1 3 #> PATEK 3 1 4 1 0 #> FERI 0 1 5 0 0 #> SARIJO 3 1 4 1 0data("sampson", package = "ergm") as_mixing_matrix(samplike, dim1 = "vertex.names", dim2 = "group", direction = "all")#> 18 x 3 Matrix of class "dgeMatrix" #> #> Turks Outcasts Loyal #> John Bosco 9 3 5 #> Gregory 11 3 1 #> Basil 3 5 0 #> Peter 0 0 9 #> Bonaventure 3 2 8 #> Berthold 1 0 5 #> Mark 8 2 1 #> Victor 4 0 7 #> Ambrose 2 0 6 #> Romauld 1 1 6 #> Louis 3 0 5 #> Winfrid 10 0 1 #> Amand 1 4 3 #> Hugh 8 0 3 #> Boniface 8 0 1 #> Albert 6 0 2 #> Elias 1 5 0 #> Simplicius 3 6 0as_mixing_matrix(samplike, dim1 = "vertex.names", dim2 = "group", direction = "out")#> 18 x 3 Matrix of class "dgeMatrix" #> #> Turks Outcasts Loyal #> John Bosco 3 1 2 #> Gregory 5 0 0 #> Basil 2 3 0 #> Peter 0 0 4 #> Bonaventure 1 1 3 #> Berthold 1 0 3 #> Mark 4 0 1 #> Victor 2 0 4 #> Ambrose 2 0 2 #> Romauld 1 1 4 #> Louis 2 0 3 #> Winfrid 4 0 0 #> Amand 1 1 1 #> Hugh 4 0 1 #> Boniface 5 0 1 #> Albert 5 0 0 #> Elias 1 3 0 #> Simplicius 3 3 0as_mixing_matrix(samplike, dim1 = "vertex.names", dim2 = "group", direction = "in")#> 3 x 18 Matrix of class "dgeMatrix" #> #> John Bosco Gregory Basil Peter Bonaventure Berthold Mark Victor #> Turks 6 6 1 0 2 0 4 2 #> Outcasts 2 3 2 0 1 0 2 0 #> Loyal 3 1 0 5 5 2 0 3 #> #> Ambrose Romauld Louis Winfrid Amand Hugh Boniface Albert Elias #> Turks 0 0 1 6 0 4 3 1 0 #> Outcasts 0 0 0 0 3 0 0 0 2 #> Loyal 4 2 2 1 2 2 0 2 0 #> #> Simplicius #> Turks 0 #> Outcasts 3 #> Loyal 0