Description Usage Arguments Value Examples
Given contact layer of the mixing matrix compute a full 3-dimensional mixing matrix by rebuilding the non-contact layer from supplied group sizes and other arguments.
1 |
cl |
numeric matrix with contact layer of the mixing matrix |
gsizes |
numeric vector or matrix with group sizes, see Details. |
directed |
logical, whether the network is directed |
loops |
logical, whether loops (self-ties) are allowed Contact layer of the mixing matrix is a cross-classification of ties
according to the attributes of tie sender (ego) and tie receiver (alter).
Classically, the same attribute is used for ego and alter resulting in a
square mixing matrix. In such cases In more general case we can use different node attributes for ego and
alter. Then |
full_mm
returns a full three-dimenstional mixing matrix as an array
with dim
attribute equal to c( nrow(cl), ncol(cl), 2 )
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | ### Square example
# Contact layer of the mixing matrix
mm1 <- matrix( c( 20, 10, 5,
12, 30, 10,
3, 11, 25 ),
byrow=TRUE, ncol=3, nrow=3)
dimnames(mm1) <- list(ego=letters[1:3], alter=letters[1:3])
mm1
# Assuming some group sizes
gs1 <- c(a=9, b=12, c=10)
# Full mixing matrix
full_mm( mm1, gs1)
### Non-square example
# Mixing matrix
# Now using different attributes for ego and alter
mm2 <- cbind(mm1, c(20, 10, 5))
colnames(mm2) <- LETTERS[1:4]
names(dimnames(mm2)) <- c("ego", "alter")
mm2
# Create artificial distribution of attributes
set.seed(123)
a1 <- sample(letters[1:3], sum(gs1), replace=TRUE, prob=gs1/sum(gs1))
table(a1)
a2 <- sample(LETTERS[1:4], sum(gs1), replace=TRUE)
table(a2)
(x <- table(a1, a2)) # Cross-tablulation
# Full mixing matrix
full_mm( mm2, gsizes=x)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.