mix_matrix: Mixing matrix

View source: R/homophily.R

mix_matrixR Documentation

Mixing matrix

Description

Create a mixing matrix from node attributes. The mixing matrix is a two-dimensional matrix that cross-classifies the edges depending on the values of their attributes. This matrix allowed identifying segregation and homophily at the network level.

Usage

mix_matrix(A, att = NULL)

Arguments

A

A symmetric matrix object

att

Categorical attribute of the nodes

Details

Values in the diagonal are the number of ties within groups, and off-diagonal are the number of relations between groups.

Value

This function returns a mixing matrix.

Author(s)

Alejandro Espinosa-Rada

Examples


n <- 100
A <- matrix(c(rbinom(n, 1, 0.5)),
  ncol = sqrt(n), nrow = sqrt(n), byrow = TRUE
)
rownames(A) <- letters[1:nrow(A)]
colnames(A) <- letters[1:ncol(A)]
att <- rbinom(sqrt(n), 3, 0.5)
mix_matrix(A, att = att)

anespinosa/netmem documentation built on April 5, 2025, 5:02 p.m.