Title: | Social Network Measures using Matrices |
---|---|
Description: | Measures to describe and manipulate networks using matrices. |
Authors: | Alejandro Espinosa-Rada [cre, aut]
|
Maintainer: | Alejandro Espinosa-Rada <[email protected]> |
License: | GPL-3 + file LICENSE |
Version: | 1.0-3 |
Built: | 2025-03-11 14:56:37 UTC |
Source: | https://github.com/anespinosa/netmem |
This function transforms an adjacency matrix into an incidence matrix.
adj_to_incidence(A, loops = TRUE, directed = TRUE, weighted = TRUE)
adj_to_incidence(A, loops = TRUE, directed = TRUE, weighted = TRUE)
A |
A square numeric matrix representing the adjacency matrix of a graph. The matrix should have non-negative values, where 'A[i, j]' represents the weight of the edge from node 'i' to node 'j'. |
loops |
Logical. If 'TRUE', self-loops (edges from a node to itself) are included in the incidence matrix. If 'FALSE', they are removed. Default is 'TRUE'. |
directed |
Logical. If 'TRUE', the graph is treated as directed, meaning each edge has a specific source and target. If 'FALSE', the graph is treated as undirected, and edges are symmetrically represented. Default is 'TRUE'. |
weighted |
Logical. If 'TRUE', edge weights from 'A' are included in the incidence matrix. If 'FALSE', all edges are treated as having weight '1'. Default is 'TRUE'. |
A numeric matrix where rows represent nodes and columns represent edges. - In a **directed** network, a source node has a negative value (-weight), and a target node has a positive value (+weight). - In an **undirected** network, both nodes involved in an edge share the weight (positive values). - If 'weighted = FALSE', all edges have a weight of '1'.
# Define an adjacency matrix (directed and weighted) A <- matrix(c( 1, 3, 0, 0, 2, 0, 0, 2, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 4, 0, 0, 0 ), byrow = TRUE, nrow = 5) # Convert to an incidence matrix (directed, weighted) (inc_matrix <- adj_to_incidence(A)) # Undirected, weighted graph (inc_matrix_undirected <- adj_to_incidence(A, directed = FALSE)) # Directed, unweighted graph (inc_matrix_unweighted <- adj_to_incidence(A, weighted = FALSE)) # Ignore loops (inc_matrix_no_loops <- adj_to_incidence(A, loops = FALSE))
# Define an adjacency matrix (directed and weighted) A <- matrix(c( 1, 3, 0, 0, 2, 0, 0, 2, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 4, 0, 0, 0 ), byrow = TRUE, nrow = 5) # Convert to an incidence matrix (directed, weighted) (inc_matrix <- adj_to_incidence(A)) # Undirected, weighted graph (inc_matrix_undirected <- adj_to_incidence(A, directed = FALSE)) # Directed, unweighted graph (inc_matrix_unweighted <- adj_to_incidence(A, weighted = FALSE)) # Ignore loops (inc_matrix_no_loops <- adj_to_incidence(A, loops = FALSE))
Transform an adjacency list into a matrix
adj_to_matrix(A, type = c("adjacency", "incidence", "weighted"), loops = FALSE)
adj_to_matrix(A, type = c("adjacency", "incidence", "weighted"), loops = FALSE)
A |
An adjacent list |
type |
Transform the adjacent list into an |
loops |
Whether to include loops into the matrix |
This function transforms an adjacency list into a matrix
Alejandro Espinosa-Rada
adj_groups <- rbind( c("a", "b", "c"), c("a", "c", NA), c("b", "c", NA), c("c", NA, NA), c("c", "a", NA) ) M <- adj_to_matrix(adj_groups, type = "adjacency", loops = TRUE) M
adj_groups <- rbind( c("a", "b", "c"), c("a", "c", NA), c("b", "c", NA), c("c", NA, NA), c("c", "a", NA) ) M <- adj_to_matrix(adj_groups, type = "adjacency", loops = TRUE) M
The function provide a normalisation provided by Bonacich (1972).
bonacich_norm(A, projection = c("rows", "columns"), normalisation = FALSE)
bonacich_norm(A, projection = c("rows", "columns"), normalisation = FALSE)
A |
An incidence matrix |
projection |
Whether to normalise by |
normalisation |
Normalise the measure |
This function returns the Bonacich normalisation.
Adapted from Borgatti, S., Everett, M., Johnson, J. and Agneessens, P. (2022) Analyzing Social Networks Using R. Sage.
Bonacich, P. (1972). Factoring and weighting approaches to status scores and clique identification. Journal of Mathematical Sociology, 2: 112-120.
A <- matrix( c( 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0 ), byrow = TRUE, ncol = 14 ) bonacich_norm(A)
A <- matrix( c( 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0 ), byrow = TRUE, ncol = 14 ) bonacich_norm(A)
Exploration of a 3-cliques, as the maximum number of three or more actors who have all possible ties present among themselves
clique_table(A, list_cliques = FALSE, number = FALSE)
clique_table(A, list_cliques = FALSE, number = FALSE)
A |
A symmetric matrix object. |
list_cliques |
Whether to return the list of cliques. |
number |
Number of triangles |
This function return an edge list of actors participating in 3-cliques.
If list_cliques = TRUE
it also return the list of cliques per nodes.
If number = TRUE
the output returns the number of 3-cliques in the matrix.
Alejandro Espinosa-Rada
Luce, R.D. and Perry, A.D. (1949). A method of matrix analysis of group structure. Psychometrika, 14: 95-116.
Roethlisberger, F.J. and Dickson, W.J. (1939). Management and the Worker. Harvard University Press, Cambridge, MA.
Wasserman, S. and Faust, K. (1994). Social network analysis: Methods and applications. Cambridge University Press.
A <- matrix(c( 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ), byrow = TRUE, ncol = 9) rownames(A) <- letters[1:nrow(A)] colnames(A) <- rownames(A) clique_table(A, list_cliques = TRUE, number = TRUE)
A <- matrix(c( 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ), byrow = TRUE, ncol = 9) rownames(A) <- letters[1:nrow(A)] colnames(A) <- rownames(A) clique_table(A, list_cliques = TRUE, number = TRUE)
Co‐occurrence matrix based on overlap function
co_ocurrence( A, similarity = c("ochiai", "cosine"), occurrence = TRUE, projection = FALSE )
co_ocurrence( A, similarity = c("ochiai", "cosine"), occurrence = TRUE, projection = FALSE )
A |
A matrix |
similarity |
The similarities available are either |
occurrence |
Whether to treat the matrix as a two-mode structure (a.k.a. rectangular matrix, occurrence matrix, affiliation matrix, bipartite network) |
projection |
Whether to apply a projection (inner product multiplication) to the matrix |
This function returns the normalisation of a matrix into a symmetrical co‐occurrence matrix
Alejandro Espinosa-Rada
Borgatti, S. P., Halgin, D. S., 2011. Analyzing affiliation networks. In: J. Scott and P. J. Carrington (Eds.) The Sage handbook of social network analysis (pp. 417-433), Sage.
Zhou, Q., & Leydesdorff, L. (2016). The normalization of occurrence and Co-occurrence matrices in bibliometrics using Cosine similarities and Ochiai coefficients. Journal of the Association for Information Science and Technology, 67(11), 2805–2814. https://doi.org/10.1002/asi.23603
A <- matrix( c( 2, 0, 2, 1, 1, 0, 0, 3, 3, 0, 2, 2, 0, 0, 1 ), nrow = 5, byrow = TRUE ) co_ocurrence(A)
A <- matrix( c( 2, 0, 2, 1, 1, 0, 0, 3, 3, 0, 2, 2, 0, 0, 1 ), nrow = 5, byrow = TRUE ) co_ocurrence(A)
This function assigns an id to the components that each of the nodes of the matrix belongs
components_id(A)
components_id(A)
A |
A matrix |
A vector assigning an id the components that each of the nodes of the matrix belongs
Alejandro Espinosa-Rada
Wasserman, S. and Faust, K. (1994). Social network analysis: Methods and applications. Cambridge University Press.
A <- matrix(c( 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0 ), byrow = TRUE, ncol = 5) rownames(A) <- letters[1:ncol(A)] colnames(A) <- rownames(A) components_id(A)
A <- matrix(c( 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0 ), byrow = TRUE, ncol = 5) rownames(A) <- letters[1:ncol(A)] colnames(A) <- rownames(A) components_id(A)
This function returns the relational composition of the given matrices. The compound relations define the paths and the social process flows of the given matrices (Pattison, 1993). However, those whom they link may or may not be aware of them. The compound relations allow us to identify "the possibly very long and devious chains of effects propagating withing concrete social systems through links of various kinds" (Lorrain & White, 1971: 50).
compound_relation(l = list(), comp = 3, matrices = FALSE, equate = FALSE)
compound_relation(l = list(), comp = 3, matrices = FALSE, equate = FALSE)
l |
A list of matrices. |
comp |
A number with the length of paths to form the compound relation. |
matrices |
Whether to return the resulting matrices of the compound relations. |
equate |
Whether to return the semigroup equations. |
This function provides the composition or concatenation of compound relations and the primitives of the matrices.
Alejandro Espinosa-Rada
Boorman, Scott A. and White, Harrison C. (1976) Social Structure from Multiple Networks. II. Role Structures. American Journal of Sociology. 81(6): 1384-1446.
Lorrain, Francois and White, Harrison C. (1971) Structural Equivalence of Individuals in Social Networks. Journal of Mathematical Sociology. 1: 49-80
Pattison, Philippa (1993) Algebraic Models for Social Networks. Cambridge University Press.
A <- matrix(c( 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0 ), byrow = TRUE, ncol = 4) rownames(A) <- letters[1:NCOL(A)] colnames(A) <- rownames(A) B <- matrix(c( 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0 ), byrow = TRUE, ncol = 4) rownames(B) <- letters[1:NCOL(B)] colnames(B) <- rownames(B) cmp <- compound_relation(list(A, B), comp = 2, matrices = TRUE, equate = TRUE) cmp$compound_relations cmp$compound_matrices cmp$equated
A <- matrix(c( 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0 ), byrow = TRUE, ncol = 4) rownames(A) <- letters[1:NCOL(A)] colnames(A) <- rownames(A) B <- matrix(c( 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0 ), byrow = TRUE, ncol = 4) rownames(B) <- letters[1:NCOL(B)] colnames(B) <- rownames(B) cmp <- compound_relation(list(A, B), comp = 2, matrices = TRUE, equate = TRUE) cmp$compound_relations cmp$compound_matrices cmp$equated
Cumulative sum of matrices
cumulativeSumMatrices(matrixList)
cumulativeSumMatrices(matrixList)
matrixList |
A list of matrices |
This function returns the cumulative sum of matrices
Alejandro Espinosa-Rada
A <- matrix(c( 0, 1, 1, 0, 0, 0, 0, 1, 0 ), byrow = TRUE, ncol = 3) B <- matrix(c( 0, 0, 1, 0, 0, 0, 0, 0, 0 ), byrow = TRUE, ncol = 3) C <- matrix(c( 0, 0, 0, 1, 0, 0, 0, 0, 0 ), byrow = TRUE, ncol = 3) matrixList <- list(A, B, C) cumulativeSumMatrices(matrixList)
A <- matrix(c( 0, 1, 1, 0, 0, 0, 0, 1, 0 ), byrow = TRUE, ncol = 3) B <- matrix(c( 0, 0, 1, 0, 0, 0, 0, 0, 0 ), byrow = TRUE, ncol = 3) C <- matrix(c( 0, 0, 0, 1, 0, 0, 0, 0, 0 ), byrow = TRUE, ncol = 3) matrixList <- list(A, B, C) cumulativeSumMatrices(matrixList)
This function calculate some geographical distances considering a list of places specifying their latitud and longitud. The function currently works for degree decimal or radians formats.
dist_geographic( latitude, longitud, method = c("spherical", "harvesine", "manhattan", "minkowski"), places = NULL, dd_to_radians = FALSE, p = NULL )
dist_geographic( latitude, longitud, method = c("spherical", "harvesine", "manhattan", "minkowski"), places = NULL, dd_to_radians = FALSE, p = NULL )
latitude |
A vector with latitude |
longitud |
A vector with longitud |
method |
Whether to use the Spherical Law of Cosines |
places |
A vector with the names of the places |
dd_to_radians |
Whether to transform degree decimal format to radians |
p |
Parameter p for the estimation of Minkowski distance (default = 2, which is equivalent to an Euclidian Distance) |
This function return a distance matrix.
Adapted from Mario Pineda-Krch (Great-circle distance calculations in R)
set.seed(1234) x <- cbind(latitud = rnorm(5, -90), longitud = rnorm(5, 45)) dist_geographic(x[, 1], x[, 2], method = "harvesine")
set.seed(1234) x <- cbind(latitud = rnorm(5, -90), longitud = rnorm(5, 45)) dist_geographic(x[, 1], x[, 2], method = "harvesine")
In the literature of social network, Euclidean distance (Burt, 1976) or correlations (Wasserman and Faust, 1994) were considered as measures of structural equivalence.
dist_sim_matrix( A, method = c("euclidean", "hamming", "jaccard"), bipartite = FALSE )
dist_sim_matrix( A, method = c("euclidean", "hamming", "jaccard"), bipartite = FALSE )
A |
A matrix |
method |
The similarities/distance currently available are either |
bipartite |
Whether the object is an incidence matrix |
This function returns a distance matrix between nodes of the same matrix.
Alejandro Espinosa-Rada
Burt, Ronald S. (1976) Positions in networks. Social Forces, 55(1): 93-122.
Wasserman, S. and Faust, K. (1994). Social network analysis: Methods and applications. Cambridge University Press.
A <- matrix(c( 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0 ), nrow = 5, ncol = 5, byrow = TRUE) rownames(A) <- letters[1:nrow(A)] colnames(A) <- rownames(A) dist_sim_matrix(A, method = "jaccard") A <- matrix(c( 0, 0, 3, 0, 5, 0, 0, 2, 0, 4, 5, 4, 0, 4, 0, 0, 3, 0, 1, 0, 0, 0, 0, 0, 2 ), nrow = 5, ncol = 5, byrow = TRUE) dist_sim_matrix(A, method = "euclidean")
A <- matrix(c( 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0 ), nrow = 5, ncol = 5, byrow = TRUE) rownames(A) <- letters[1:nrow(A)] colnames(A) <- rownames(A) dist_sim_matrix(A, method = "jaccard") A <- matrix(c( 0, 0, 3, 0, 5, 0, 0, 2, 0, 4, 5, 4, 0, 4, 0, 0, 3, 0, 1, 0, 0, 0, 0, 0, 2 ), nrow = 5, ncol = 5, byrow = TRUE) dist_sim_matrix(A, method = "euclidean")
Distances between nodes using breadth-first search (BFS) or Dijkstra's algorithm to find shortest path distances.
bfs_ugraph(A, from = NULL) count_geodesics(A) short_path(A, from = NULL, to = NULL) wlocal_distances(A, select = c("all", "in", "out"), from, to, path = c()) wall_distances(A, select = c("all", "in", "out"))
bfs_ugraph(A, from = NULL) count_geodesics(A) short_path(A, from = NULL, to = NULL) wlocal_distances(A, select = c("all", "in", "out"), from, to, path = c()) wall_distances(A, select = c("all", "in", "out"))
A |
A symmetric matrix object |
from |
Node in which the path start |
to |
Node in which the path end |
select |
Whether to consider all sender and receiver ties of ego ( |
path |
Path of the nodes |
This function returns the distances o shortest path distance between two nodes for unweighted graph (bfs_ugraph
, count_geodesics
and short_path
respectively) and weighted graphs (wlocal_distances
or wall_distances
)
Alejandro Espinosa-Rada
Dijkstra, E. W. (1959). A note on two problems in connexion with graphs. Numerische Mathematik. 1: 269–271.
A <- matrix(c( 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 ), byrow = TRUE, nrow = 6) rownames(A) <- letters[1:nrow(A)] colnames(A) <- letters[1:ncol(A)] bfs_ugraph(A, from = "a") A <- matrix(c( 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 ), byrow = TRUE, nrow = 6) rownames(A) <- letters[1:nrow(A)] colnames(A) <- letters[1:ncol(A)] count_geodesics(A) A <- matrix(c( 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 ), byrow = TRUE, nrow = 6) rownames(A) <- letters[1:nrow(A)] colnames(A) <- letters[1:ncol(A)] short_path(A, from = "a", to = "d") A <- matrix( c( 0, 3, 3, 10, 15, 0, 0, 0, 1, 0, 5, 2, 7, 0, 0, 0, 3, 5, 0, 0, 0, 0, 0, 0, 10, 2, 0, 0, 2, 7, 12, 0, 11, 3, 0, 3, 0, 11, 2, 0, 0, 0, 0, 7, 11, 0, 3, 2, 0, 0, 0, 12, 2, 3, 0, 2, 0, 0, 0, 0, 0, 2, 2, 0 ), byrow = TRUE, ncol = 8, nrow = 8 ) rownames(A) <- c("a", "b", "s", "c", "d", "e", "f", "z") colnames(A) <- rownames(A) wlocal_distances(A, from = "a", to = "d") A <- matrix( c( 0, 3, 3, 10, 15, 0, 0, 0, 1, 0, 5, 2, 7, 0, 0, 0, 3, 5, 0, 0, 0, 0, 0, 0, 10, 2, 0, 0, 2, 7, 12, 0, 11, 3, 0, 3, 0, 11, 2, 0, 0, 0, 0, 7, 11, 0, 3, 2, 0, 0, 0, 12, 2, 3, 0, 2, 0, 0, 0, 0, 0, 2, 2, 0 ), byrow = TRUE, ncol = 8, nrow = 8 ) rownames(A) <- c("a", "b", "s", "c", "d", "e", "f", "z") colnames(A) <- rownames(A) wall_distances(A, select = "in")
A <- matrix(c( 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 ), byrow = TRUE, nrow = 6) rownames(A) <- letters[1:nrow(A)] colnames(A) <- letters[1:ncol(A)] bfs_ugraph(A, from = "a") A <- matrix(c( 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 ), byrow = TRUE, nrow = 6) rownames(A) <- letters[1:nrow(A)] colnames(A) <- letters[1:ncol(A)] count_geodesics(A) A <- matrix(c( 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 ), byrow = TRUE, nrow = 6) rownames(A) <- letters[1:nrow(A)] colnames(A) <- letters[1:ncol(A)] short_path(A, from = "a", to = "d") A <- matrix( c( 0, 3, 3, 10, 15, 0, 0, 0, 1, 0, 5, 2, 7, 0, 0, 0, 3, 5, 0, 0, 0, 0, 0, 0, 10, 2, 0, 0, 2, 7, 12, 0, 11, 3, 0, 3, 0, 11, 2, 0, 0, 0, 0, 7, 11, 0, 3, 2, 0, 0, 0, 12, 2, 3, 0, 2, 0, 0, 0, 0, 0, 2, 2, 0 ), byrow = TRUE, ncol = 8, nrow = 8 ) rownames(A) <- c("a", "b", "s", "c", "d", "e", "f", "z") colnames(A) <- rownames(A) wlocal_distances(A, from = "a", to = "d") A <- matrix( c( 0, 3, 3, 10, 15, 0, 0, 0, 1, 0, 5, 2, 7, 0, 0, 0, 3, 5, 0, 0, 0, 0, 0, 0, 10, 2, 0, 0, 2, 7, 12, 0, 11, 3, 0, 3, 0, 11, 2, 0, 0, 0, 0, 7, 11, 0, 3, 2, 0, 0, 0, 12, 2, 3, 0, 2, 0, 0, 0, 0, 0, 2, 2, 0 ), byrow = TRUE, ncol = 8, nrow = 8 ) rownames(A) <- c("a", "b", "s", "c", "d", "e", "f", "z") colnames(A) <- rownames(A) wall_distances(A, select = "in")
This function explores dyads and triads (Simmel, 1950), building from the 'forbidden triad' (Granovetter, 1973). First, the minimum structure is an isolated node, then dyads. Afterwards, different combinations of 'forbidden triads' are explored.
dyad_triad_table(A, adjacency_list = FALSE, min = NULL, max = NULL)
dyad_triad_table(A, adjacency_list = FALSE, min = NULL, max = NULL)
A |
A symmetric matrix object. |
adjacency_list |
Whether to return the adjacency list of triads 201 per node. |
min |
Numeric constant, lower limit on the size of the triads 201 to find. NULL means no limit, ie. it is the same as 0. |
max |
Numeric constant, upper limit on the size of the triads 201 to find. NULL means no limit. |
This function return the list of triads that each node belong.
If adjacency_list = TRUE
it also return the adjacency list of
the 'forbidden triads' per node.
Alejandro Espinosa-Rada
Granovetter, M.S. (1973). The Strength of Weak Ties. American Journal of Sociology. 78 (6): 1360–80. https://doi.org/10.1086/225469.
Simmel, G. (1950). Individual and Society. In K. H. Wolff (Ed.), The Sociology of George Simmel. New York: Free Press.
Wasserman, S. and Faust, K. (1994). Social network analysis: Methods and applications. Cambridge University Press.
A <- matrix(c( 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0 ), byrow = TRUE, ncol = 5) rownames(A) <- letters[1:nrow(A)] colnames(A) <- letters[1:ncol(A)] dyad_triad_table(A, adjacency_list = TRUE, min = 3)
A <- matrix(c( 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0 ), byrow = TRUE, ncol = 5) rownames(A) <- letters[1:nrow(A)] colnames(A) <- letters[1:ncol(A)] dyad_triad_table(A, adjacency_list = TRUE, min = 3)
Dyad census
dyadic_census(G, directed = TRUE, loops = FALSE)
dyadic_census(G, directed = TRUE, loops = FALSE)
G |
A symmetric matrix object. |
directed |
Whether the matrix is directed or not |
loops |
Whether to expect nonzero elements in the diagonal of the matrix |
This function return the counts of the dyad census.
Alejandro Espinosa-Rada
Wasserman, S. and Faust, K. (1994). Social network analysis: Methods and applications. Cambridge University Press.
data(krackhardt_friends) dyadic_census(krackhardt_friends) data(FIFAin) dyadic_census(FIFAin[[1]], directed = FALSE)
data(krackhardt_friends) dyadic_census(krackhardt_friends) data(FIFAin) dyadic_census(FIFAin[[1]], directed = FALSE)
Everett and Borgatti specification of the constraint measure for binary matrices
eb_constraint(A, ego = NULL, digraph = FALSE, weighted = FALSE)
eb_constraint(A, ego = NULL, digraph = FALSE, weighted = FALSE)
A |
A symmetric matrix object |
ego |
Name of ego in the matrix |
digraph |
Whether the matrix is directed or undirected |
weighted |
Whether the matrix is weighted or not |
This function returns term 1, 2 and 3, the normalization and the maximum value of the specification of Everett and Borgatti (2020), and the constraint of Burt (1992).
Alejandro Espinosa-Rada
Burt, R.S., 1992. Structural Holes: the Social Structure of Competition. Harvard University Press, Cambridge.
Everett, M.G. and Borgatti, S., 2020. Unpacking Burt's constraint measure. Social Networks 62, pp. 50-57. doi: https://doi.org/10.1016/j.socnet.2020.02.001
A <- matrix(c( 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0 ), ncol = 6, byrow = TRUE) rownames(A) <- letters[1:nrow(A)] colnames(A) <- letters[1:ncol(A)] eb_constraint(A, ego = "f")
A <- matrix(c( 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0 ), ncol = 6, byrow = TRUE) rownames(A) <- letters[1:nrow(A)] colnames(A) <- letters[1:ncol(A)] eb_constraint(A, ego = "f")
Transform an edgelist to a matrix
edgelist_to_matrix( E, digraph = TRUE, label = NULL, label2 = NULL, bipartite = FALSE )
edgelist_to_matrix( E, digraph = TRUE, label = NULL, label2 = NULL, bipartite = FALSE )
E |
An edge list |
digraph |
Whether the matrix is directed or not |
label |
A vector with the names of the nodes |
label2 |
A vector with the names of a different set of nodes |
bipartite |
Whether the matrix is bipartite |
This function transform the edgelist into a matrix
Alejandro Espinosa-Rada
A <- matrix(c( 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ), byrow = TRUE, ncol = 9) rownames(A) <- letters[1:nrow(A)] colnames(A) <- rownames(A) E <- matrix_to_edgelist(A) edgelist_to_matrix(E, label = c("i"), digraph = FALSE)
A <- matrix(c( 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ), byrow = TRUE, ncol = 9) rownames(A) <- letters[1:nrow(A)] colnames(A) <- rownames(A) E <- matrix_to_edgelist(A) edgelist_to_matrix(E, label = c("i"), digraph = FALSE)
Submatrix of ego's neighbourhoods
ego_net( A, ego = NULL, bipartite = FALSE, addEgo = FALSE, select = c("all", "in", "out") )
ego_net( A, ego = NULL, bipartite = FALSE, addEgo = FALSE, select = c("all", "in", "out") )
A |
A symmetric matrix object |
ego |
Name of ego in the matrix |
bipartite |
Whether the matrix is a two-mode network |
addEgo |
Whether to retain ego in the submatrix or not |
select |
Whether to consider all sender and receiver ties of ego ( |
This function returns redundancy, effective size and efficincy measures (Burt, 1992).
Alejandro Espinosa-Rada
Burt, R.S., 1992. Structural Holes: the Social Structure of Competition. Harvard University Press, Cambridge.
Borgatti, S., 1997. Unpacking Burt's redundancy measure. Connections, 20(1): 35-38. doi: http://www.analytictech.com/connections/v20(1)/holes.htm
A <- matrix(c( 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0 ), ncol = 7, byrow = TRUE) rownames(A) <- letters[1:nrow(A)] colnames(A) <- letters[1:ncol(A)] ego_net(A, ego = "g")
A <- matrix(c( 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0 ), ncol = 7, byrow = TRUE) rownames(A) <- letters[1:nrow(A)] colnames(A) <- letters[1:ncol(A)] ego_net(A, ego = "g")
This index was proposed by Krackhardt and Stern (1988) to distinguish between the relative prevalence of between and within-group ties. This measure can be interpreted as homophily at the network level.
ei_index(A, mixed = TRUE, att = NULL)
ei_index(A, mixed = TRUE, att = NULL)
A |
A symmetric matrix object |
mixed |
Whether the matrix provided is already a mixed matrix or not |
att |
Categorical attribute of the nodes |
Numerical value of the E-I index.
set.seed(18051889) 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) ei_index(A, mixed = FALSE, att = att)
set.seed(18051889) 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) ei_index(A, mixed = FALSE, att = att)
Expand Matrix
expand_matrix(A, label = NULL, loops = FALSE, normalize = FALSE)
expand_matrix(A, label = NULL, loops = FALSE, normalize = FALSE)
A |
A square matrix |
label |
Duplicated labels to expand the matrix |
loops |
Whether the loops are retained or not |
normalize |
Whether to normalize the matrix considering the fractional counting per group |
Return an expanded matrix
Alejandro Espinosa-Rada
A <- matrix(c( 0, 1, 1, 0, 0, 1, 1, 0, 0 ), byrow = TRUE, ncol = 3, nrow = 3) rownames(A) <- letters[1:NROW(A)] colnames(A) <- rownames(A) label <- sort(rep(rownames(A), 2)) expand_matrix(A, label, loops = FALSE, normalize = TRUE)
A <- matrix(c( 0, 1, 1, 0, 0, 1, 1, 0, 0 ), byrow = TRUE, ncol = 3, nrow = 3) rownames(A) <- letters[1:NROW(A)] colnames(A) <- rownames(A) label <- sort(rep(rownames(A), 2)) expand_matrix(A, label, loops = FALSE, normalize = TRUE)
This function extract the matrix of different components
extract_component(A, maximum = TRUE, position = NULL)
extract_component(A, maximum = TRUE, position = NULL)
A |
A matrix |
maximum |
Whether to extract the maximum component |
position |
Whether to extract the component in the ith size position |
A matrix or a list of matrices with the required components
Alejandro Espinosa-Rada
Wasserman, S. and Faust, K. (1994). Social network analysis: Methods and applications. Cambridge University Press.
A <- FIFAex$Matrix rownames(A) <- FIFAex$label colnames(A) <- rownames(A) extract_component(A, maximum = TRUE) extract_component(A, maximum = FALSE, position = 2)
A <- FIFAex$Matrix rownames(A) <- FIFAex$label colnames(A) <- rownames(A) extract_component(A, maximum = TRUE) extract_component(A, maximum = FALSE, position = 2)
Multilevel Network of the regulatory transnational regime of the International Federation of Association Football (FIFA)
data(FIFAego)
data(FIFAego)
A list of a 48 x 48 symmetric matrix of the ego network of FIFA as a different entity, and a string vector with the label of the actors
Espinosa, Alejandro & Ortiz, Francisca (2016). "Jurisdictional autonomy in the regulatory transnational regime of FIFA". REDES- Revista Hispana para el Analisis de Redes Sociales, 27(1), 100- 112. (Original title in Spanish: "Autonomia jurisdiccional en el reegimen regulatorio transnacional de la FIFAFA") <doi: https://doi.org/10.5565/rev/redes.595>
Multilevel Network of the regulatory transnational regime of the International Federation of Association Football (FIFA)
data(FIFAex)
data(FIFAex)
A list of a 7 x 7 symmetric matrix of non-FIFA organizations, and a string vector with the label of the actors
Espinosa, Alejandro & Ortiz, Francisca (2016). "Jurisdictional autonomy in the regulatory transnational regime of FIFA". REDES- Revista Hispana para el Analisis de Redes Sociales, 27(1), 100- 112. (Original title in Spanish: "Autonomia jurisdiccional en el reegimen regulatorio transnacional de la FIFAFA") <doi: https://doi.org/10.5565/rev/redes.595>#'
Multilevel Network of the regulatory transnational regime of the International Federation of Association Football (FIFA)
data(FIFAin)
data(FIFAin)
A list of a 41 x 41 symmetric matrix of roles and organizations inside FIFA, and a string vector with the label of the actors
Espinosa, Alejandro & Ortiz, Francisca (2016). "Jurisdictional autonomy in the regulatory transnational regime of FIFA". REDES- Revista Hispana para el Analisis de Redes Sociales, 27(1), 100- 112. (Original title in Spanish: "Autonomia jurisdiccional en el reegimen regulatorio transnacional de la FIFAFA") <doi: https://doi.org/10.5565/rev/redes.595>
Matrix transformation from incidence matrices to citation networks, fractional counting for co-citation or fractional counting for bibliographic coupling
fractional_approach( A1, A2, approach = c("citation", "cocitation", "bcoupling") )
fractional_approach( A1, A2, approach = c("citation", "cocitation", "bcoupling") )
A1 |
From incidence matrix (e.g. paper and authors) |
A2 |
To incidence matrix (e.g. author to paper) |
approach |
Character string, “citation”, “cocitation” and “bcoupling” |
Return a type of "citation network"
Alejandro Espinosa-Rada
Batagelj, V. (2020). Analysis of the Southern women network using fractional approach. Social Networks, 68, 229-236 https://doi.org/10.1016/j.socnet.2021.08.001
Batagelj, V., & Cerinšek, M. (2013). On bibliographic networks. Scientometrics, 96(3), 845–864. https://doi.org/10.1007/s11192-012-0940-1
A1 <- matrix(c( 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1 ), byrow = TRUE, ncol = 4) A2 <- matrix(c( 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1 ), byrow = TRUE, ncol = 5) fractional_approach(A1, A2)
A1 <- matrix(c( 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1 ), byrow = TRUE, ncol = 4) A2 <- matrix(c( 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1 ), byrow = TRUE, ncol = 5) fractional_approach(A1, A2)
Generalized degree centrality for one-mode and bipartite networks
gen_degree( A, weighted = FALSE, type = "out", normalized = FALSE, loops = TRUE, digraph = TRUE, alpha = 0.5, bipartite = FALSE )
gen_degree( A, weighted = FALSE, type = "out", normalized = FALSE, loops = TRUE, digraph = TRUE, alpha = 0.5, bipartite = FALSE )
A |
A matrix object |
weighted |
Whether the matrix is weighted or not |
type |
Character string, “out” (outdegree), “in” (indegree) and “all” (degree) |
normalized |
Whether normalize the measure for the one-mode network (Freeman, 1978) or a bipartite network (Borgatti and Everett, 1997) |
loops |
Whether the diagonal of the matrix is considered or not |
digraph |
Whether the matrix is directed or undirected |
alpha |
Sets the alpha parameter in the generalised measures from Opsahl et al. (2010) |
bipartite |
Whether the matrix is bipartite or not. |
This function returns term 1, 2 and 3, the normalization and the maximum value of the specification of Everett and Borgatti (2020), and the constraint of Burt (1992)
Alejandro Espinosa-Rada
Borgatti, S. P., and Everett, M. G. (1997). Network analysis of 2-mode data. Social Networks, 19(3), 243–269.
Freeman, L. C. (1978). Centrality in social networks conceptual clarification. Social Networks, 1(3), 215–239.
Opsahl, T., Agneessens, F., and Skvoretz, J. (2010). Node centrality in weighted networks: Generalizing degree and shortest paths. Social Networks, 32(3), 245–251.
A3 <- matrix(c( 0, 4, 4, 0, 0, 0, 4, 0, 2, 1, 1, 0, 4, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 7, 0, 0, 0, 0, 7, 0 ), byrow = TRUE, ncol = 6) gen_degree(A3, digraph = FALSE, weighted = TRUE)
A3 <- matrix(c( 0, 4, 4, 0, 0, 0, 4, 0, 2, 1, 1, 0, 4, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 7, 0, 0, 0, 0, 7, 0 ), byrow = TRUE, ncol = 6) gen_degree(A3, digraph = FALSE, weighted = TRUE)
Generalized density
gen_density( A, directed = TRUE, bipartite = FALSE, loops = FALSE, weighted = FALSE, multilayer = FALSE )
gen_density( A, directed = TRUE, bipartite = FALSE, loops = FALSE, weighted = FALSE, multilayer = FALSE )
A |
A symmetric or incidence matrix object |
directed |
Whether the matrix is directed |
bipartite |
Whether the matrix is bipartite |
loops |
Whether to consider the loops |
weighted |
Whether the matrix is weighted |
multilayer |
Whether the matrix is multilayer (i.e., multiplex and/or multilevel) |
This function returns the density of the matrix(es)
Alejandro Espinosa-Rada
Wasserman, S., and Faust, K. (1994). Social Network Analysis: Methods and Applications. Cambridge: Cambridge University Press.
# A bipartite matrix B <- matrix(c( 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1 ), byrow = TRUE, ncol = 3) gen_density(B, bipartite = TRUE) # A multilevel network A1 <- matrix(c( 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0 ), byrow = TRUE, ncol = 5) B1 <- matrix(c( 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1 ), byrow = TRUE, ncol = 3) A2 <- matrix(c( 0, 1, 1, 1, 0, 0, 1, 0, 0 ), byrow = TRUE, nrow = 3) B2 <- matrix(c( 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1 ), byrow = TRUE, ncol = 4) A3 <- matrix(c( 0, 1, 3, 1, 1, 0, 0, 0, 3, 0, 0, 5, 1, 0, 5, 0 ), byrow = TRUE, ncol = 4) matrices <- list(A1, B1, A2, B2, A3) gen_density(matrices, multilayer = TRUE) # A multiplex network A <- matrix(c( 0, 1, 3, 6, 4, 2, 0, 4, 5, 2, 4, 1, 0, 6, 1, 5, 6, 3, 0, 6, 1, 1, 2, 3, 0 ), byrow = TRUE, ncol = 5) gen_density(A, multilayer = TRUE)
# A bipartite matrix B <- matrix(c( 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1 ), byrow = TRUE, ncol = 3) gen_density(B, bipartite = TRUE) # A multilevel network A1 <- matrix(c( 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0 ), byrow = TRUE, ncol = 5) B1 <- matrix(c( 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1 ), byrow = TRUE, ncol = 3) A2 <- matrix(c( 0, 1, 1, 1, 0, 0, 1, 0, 0 ), byrow = TRUE, nrow = 3) B2 <- matrix(c( 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1 ), byrow = TRUE, ncol = 4) A3 <- matrix(c( 0, 1, 3, 1, 1, 0, 0, 0, 3, 0, 0, 5, 1, 0, 5, 0 ), byrow = TRUE, ncol = 4) matrices <- list(A1, B1, A2, B2, A3) gen_density(matrices, multilayer = TRUE) # A multiplex network A <- matrix(c( 0, 1, 3, 6, 4, 2, 0, 4, 5, 2, 4, 1, 0, 6, 1, 5, 6, 3, 0, 6, 1, 1, 2, 3, 0 ), byrow = TRUE, ncol = 5) gen_density(A, multilayer = TRUE)
This index was used by Blau (1977) to distinguish between the relative prevalence of between and within-group ties. This measure can be interpreted as heterogeneity at the network level.
heterogeneity(att, normalized = FALSE)
heterogeneity(att, normalized = FALSE)
att |
Categorical attribute of the nodes |
normalized |
Whether to return IQV index |
Numerical value of the Blau index.
If normalized = TRUE
, then the function also return IQV index.
Agresti, A. and Agresti, B. (1978). Statistical Analysis of Qualitative Variation. Sociological Methodology, 9, 204-237. doi: https://doi.org/10.2307/270810
Blau, P. M. (1977). Inequality and heterogeneity. New York: Free Press.
a <- rep(1:10, 10) heterogeneity(a, normalized = TRUE) a <- rep(1:2, 10) heterogeneity(a, normalized = TRUE)
a <- rep(1:10, 10) heterogeneity(a, normalized = TRUE) a <- rep(1:2, 10) heterogeneity(a, normalized = TRUE)
Hypergraph consist of a set of objects and a collection of subsets of objects, in which each object belongs to at least one subset, and no subset is empy (Berge, 1989)
hypergraph(A, dual = TRUE, both = TRUE)
hypergraph(A, dual = TRUE, both = TRUE)
A |
An incidence matrix. |
dual |
Whether to return the dual hypergraph (which rever the role of the pointes and the edges) |
both |
Whether to return the hypergraph and the dual hypergraph |
This function returns an adjacent list of the subsets of entities in the hypergraph.
Alejandro Espinosa-Rada
Berge, C. (1973). Graphs and hypergraphs.Amsterdam: North-Holland.
Berge, C. (1989). Hypergraphs: Combinatorics of finite sets. Amsterdam: North-Holland.
Wasserman, S. and Faust, K. (1994). Social network analysis: Methods and applications. Cambridge University Press.
A <- matrix(c( 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0 ), byrow = TRUE, ncol = 3) colnames(A) <- letters[1:ncol(A)] rownames(A) <- letters[(ncol(A) + 1):(nrow(A) + ncol(A))] hypergraph(A, both = TRUE)
A <- matrix(c( 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0 ), byrow = TRUE, ncol = 3) colnames(A) <- letters[1:ncol(A)] rownames(A) <- letters[(ncol(A) + 1):(nrow(A) + ncol(A))] hypergraph(A, both = TRUE)
The function creates random matrices following a uniform probability over the space of networks having exactly m fixed number of edges (Moreno and Jennings, 1938; Rapoport, 1948; Solomonoff and Rapoport, 1951; Erdos and Renyi, 1959) or following a probability of the formation of the ties (Gilbert, 1959) assuming ties independency.
ind_rand_matrix( n, m = NULL, type = c("edges", "probability"), digraph = TRUE, loops = FALSE, l = NULL, p = NULL, trials = 1, multilevel = FALSE )
ind_rand_matrix( n, m = NULL, type = c("edges", "probability"), digraph = TRUE, loops = FALSE, l = NULL, p = NULL, trials = 1, multilevel = FALSE )
n |
The number of nodes of the first set |
m |
The number of nodes of a second set |
type |
The model assumes a fixed number of |
digraph |
Whether the matrix is symmetric or not |
loops |
Whether to expect nonzero elements in the diagonal of the matrix |
l |
The number of ties expected for the |
p |
The probability of the ties expected for the |
trials |
Whether to add counting numbers to the |
multilevel |
Whether to return a meta-matrix to represent a multilevel network |
The fixed model is often called the G(n,m) graph with 'n' nodes and 'm' edges, and the 'm' edges are chosen uniformly randomly from the set of all possible ties.
The probability model is known as the G(n,p) graph, in which the matrix has 'n' nodes, and for each tie, the probability that it is present in the matrix is 'p'.
These are the simplest models that follow a conditional uniform distribution that place nonnull probability on a subset of networks with distinctive characteristics corresponding to the observed networks - for example, simulating a matrix based on the number of ties observed in the network.
This function return the counts of the dyad census.
Alejandro Espinosa-Rada
Erdos, P. and Renyi, A. (1959). On random graphs. Publicationes Mathematicae 6, 290–297.
Gilbert, N. (1959). Random Graphs. The Annals of Mathematical Statistics, 30(4): 1141-1144.
Moreno, J. and Jennings, H. (1938). Statistics of social configurations. Sociometry, 1(3/4):342–374.
Rapoport, A. (1948). Cycle distributions in random nets. Bulletin of Mathematical Biology, 10(3):145–157.
Solomonoff, R. and Rapoport, A. (1951). Connectivity of random nets. Bulletin of Mathematical Biology, 13:107–117.
set.seed(18051889) ind_rand_matrix(5, type = "edges", l = 3, digraph = TRUE, loops = TRUE) ind_rand_matrix(5, type = "probability") ind_rand_matrix(n = 5, m = 2, p = 0.20, type = "probability", multilevel = TRUE)
set.seed(18051889) ind_rand_matrix(5, type = "edges", l = 3, digraph = TRUE, loops = TRUE) ind_rand_matrix(5, type = "probability") ind_rand_matrix(n = 5, m = 2, p = 0.20, type = "probability", multilevel = TRUE)
Jaccard similarity identifies the changes of ties between two matrices.
jaccard( A, B, directed = TRUE, diag = FALSE, coparticipation = FALSE, bipartite = FALSE )
jaccard( A, B, directed = TRUE, diag = FALSE, coparticipation = FALSE, bipartite = FALSE )
A |
Binary matrix A |
B |
Binary matrix B |
directed |
Whether the matrix is symmetric |
diag |
Whether the diagonal should be considered |
coparticipation |
Select nodes that co-participate in both matrices |
bipartite |
Whether the matrix is incidence |
The output are: jaccard
= Jaccard similarity, proportion
=
proportion among the ties present at a given observation of ties that
are also present in the other matrix, and table
= a table with the
tie changes between matrices.
If coparticipation = TRUE
, then
also: match
= The number of nodes present in both matrices;
size_matrix1
= The size of the first matrix;
size_matrix2
= The size of the second matrix;
coparticipation1
= The percentage of nodes in the first matrix also present in the second matrix;
coparticipation2
= The percentage of nodes in the second matrix also present in the first matrix:
overlap_actors
= Overlap of nodes between two matrices
#' If coparticipation = TRUE
and bipartite = TRUE
, then
also: matchM1
= The number of nodes in the first 'mode' present in both matrices;
matchM2
= The number of nodes in the second 'mode' present in both matrices;
size_matrix1_M1
= The number of nodes in the first 'mode' of the first matrix;
size_matrix1_M2
= The number of nodes in the second 'mode' of the first matrix;
size_matrix2_M1
= The number of nodes in the first 'mode' of the second matrix;
size_matrix2_M2
= The number of nodes in the second 'mode' of the second matrix;
coparticipation1_M2
= The percentage of nodes of the first 'mode' in the first matrix present in the second matrix.
coparticipation1_M2
= The percentage of nodes of the second 'mode' in the first matrix present in the second matrix.
coparticipation2_M1
= The percentage of nodes of the first 'mode' in the second matrix present in the first matrix.
coparticipation2_M2
= The percentage of nodes of the second 'mode' in the second matrix present in the first matrix.
overlap_actors_M1
= Overlap between two matrices (nodes of the first 'mode')
overlap_actors_M2
= Overlap between two matrices (nodes of the second 'mode')
Alejandro Espinosa-Rada
Batagelj, V., and Bren, M. (1995). Comparing resemblance measures. Journal of Classification 12, 73–90.
A <- matrix(c( 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0 ), byrow = TRUE, ncol = 4) B <- matrix(c( 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 ), byrow = TRUE, ncol = 4) jaccard(A, B, directed = TRUE)
A <- matrix(c( 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0 ), byrow = TRUE, ncol = 4) B <- matrix(c( 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 ), byrow = TRUE, ncol = 4) jaccard(A, B, directed = TRUE)
Generalized k-core for undirected, directed, weighted and multilevel networks
k_core( A, B1 = NULL, multilevel = FALSE, type = "in", digraph = FALSE, loops = FALSE, weighted = FALSE, alpha = 1 )
k_core( A, B1 = NULL, multilevel = FALSE, type = "in", digraph = FALSE, loops = FALSE, weighted = FALSE, alpha = 1 )
A |
A matrix object. |
B1 |
An incidence matrix for multilevel networks. |
multilevel |
Whether the measure of k-core is for multilevel networks. |
type |
Character string, “out” (outdegree), “in” (indegree) and “all” (degree) |
digraph |
Whether the matrix is directed or undirected |
loops |
Whether the diagonal of the matrix is considered or not |
weighted |
Whether the measure of k-core is for valued matrices |
alpha |
Sets the alpha parameter in the generalised measures from Opsahl et al. (2010) |
This function return the k-core.
Alejandro Espinosa-Rada
Batagelj, V., & Zaveršnik, M. (2011). Fast algorithms for determining (generalized) core groups in social networks. Advances in Data Analysis and Classification, 5(2), 129–145. https://doi.org/10.1007/s11634-010-0079-y
Eidsaa, M., & Almaas, E. (2013). s-core network decomposition: A generalization of $k$-core analysis to weighted networks. Physical Review E, 88(6), 062819. https://doi.org/10.1103/PhysRevE.88.062819
Seidman S (1983). 'Network structure and minimum degree'. Social Networks, 5, 269-287.
A1 <- matrix(c( 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0 ), byrow = TRUE, ncol = 5) B1 <- matrix(c( 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1 ), byrow = TRUE, ncol = 3) k_core(A1, B1, multilevel = TRUE)
A1 <- matrix(c( 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0 ), byrow = TRUE, ncol = 5) B1 <- matrix(c( 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1 ), byrow = TRUE, ncol = 3) k_core(A1, B1, multilevel = TRUE)
Reciprocity of Katz and Powell
kp_reciprocity(G, fixed = FALSE, d = NULL, dichotomic = TRUE)
kp_reciprocity(G, fixed = FALSE, d = NULL, dichotomic = TRUE)
G |
A symmetric matrix object. |
fixed |
Whether the choices are fixed or not |
d |
Numeric value of the number of fixed choices. |
dichotomic |
Whether the matrix is weighted or binary |
This function gives a measurment of the tendency toward reciprocation of choices.
Alejandro Espinosa-Rada
Katz, L. and Powell, J.H. (1955). "Measurement of the tendency toward reciprocation of choice." Sociometry, 18:659-665.
data(krackhardt_friends) kp_reciprocity(krackhardt_friends, fixed = TRUE, d = 5)
data(krackhardt_friends) kp_reciprocity(krackhardt_friends, fixed = TRUE, d = 5)
Friendship network of the relations measured for Krackhardt's high-tech managers.
data(krackhardt_friends)
data(krackhardt_friends)
A 21 x 21 directed matrix of the managers
Wasserman, S. and Faust, K. (1994). Social network analysis: Methods and applications. Cambridge University Press.
The data is part of a study carried out in a Northeastern US corporate law firm, referred to as SG&R, 1988-1991 in New England. The data were collected by Emmanuel Lazega (2001). This is a multiplex network of attorneys (partners and associates) of this firm. It includes (among others) measurements of networks among the 71 attorneys (partners and associates) of this firm, i.e. their strong-coworker network, advice network, friendship network, and indirect control networks.
data(lazega_lawfirm)
data(lazega_lawfirm)
Three 71 X 71 matrices:
A matrix indicating "cowork" relationships among the attorneys, based on their work together on cases and other professional activities.
A matrix indicating "advice" relationships, where the matrix shows to whom attorneys went for professional advice.
A matrix indicating "friends" relationships, showing social connections outside of work.
A data frame with attributes of the actors, including:
Seniority.
1=partner; 2=associate
1=man; 2=woman
1=Boston; 2=Hartford; 3=Providence
Years with the firm
Age
1=litigation; 2=corporate
1 = Harvard, Yale; 2 = UConn; 3 = Other
Lazega, Emmanuel (2001) The Collegial Phenomenon: The Social Mechanisms of Cooperation Among Peers in a Corporate Law Partnership. Oxford University Press.
Transform a matrix to an adjacency list
matrix_adjlist(A)
matrix_adjlist(A)
A |
A matrix |
This function transform a matrix to an adjacency list
Alejandro Espinosa-Rada
A <- matrix(c( 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ), byrow = TRUE, ncol = 9) rownames(A) <- letters[1:nrow(A)] colnames(A) <- rownames(A) matrix_adjlist(A)
A <- matrix(c( 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ), byrow = TRUE, ncol = 9) rownames(A) <- letters[1:nrow(A)] colnames(A) <- rownames(A) matrix_adjlist(A)
Two-mode networks can be represented (or 'projected') as one-mode networks.
matrix_projection(A, B = NULL, digraph = FALSE)
matrix_projection(A, B = NULL, digraph = FALSE)
A |
A first matrix object |
B |
A second matrix object |
digraph |
Whether the matrix is directed or not |
This function return a list of matrices of the two projections of the original matrix.
Alejandro Espinosa-Rada
Davis, Allison; Gardner, Burleigh B. and Mary. R. Gardner (1941). Deep South: A Social Anthropological Study of Caste and Class. The University of Chicago Press, Chicago.
Breiger, Ronald L. (1976). The Duality of Persons and Groups, 53(2), 181-190 doi: https://doi.org/10.2307/2576011
Wasserman, S. and Faust, K. (1994). Social network analysis: Methods and applications. Cambridge University Press.
A <- matrix(c( 2, 0, 2, 1, 1, 0, 0, 3, 3, 0, 2, 2, 0, 0, 1 ), byrow = TRUE, ncol = 3) matrix_projection(A) A <- matrix(c( 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0 ), byrow = TRUE, ncol = 5) B <- matrix(c( 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0 ), byrow = TRUE, ncol = 5) matrix_projection(A, B, digraph = TRUE)
A <- matrix(c( 2, 0, 2, 1, 1, 0, 0, 3, 3, 0, 2, 2, 0, 0, 1 ), byrow = TRUE, ncol = 3) matrix_projection(A) A <- matrix(c( 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0 ), byrow = TRUE, ncol = 5) B <- matrix(c( 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0 ), byrow = TRUE, ncol = 5) matrix_projection(A, B, digraph = TRUE)
The primary matrix used in social network analysis are the adjacency matrix or sociomatrix, and the incidence matrix.
matrix_report(A)
matrix_report(A)
A |
A matrix |
This function return a report of some of the characteristics of the matrix.
Alejandro Espinosa-Rada
Wasserman, S. and Faust, K. (1994). Social network analysis: Methods and applications. Cambridge University Press.
A <- matrix(c( 1, 1, 0, 0, -1, 1, 0, 0, 1, 1, 0, 0, NA, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0 ), byrow = TRUE, ncol = 5) B <- matrix(c( 1, 0, 0, 1, 1, 0, 0, NA, 0, 0, 1, 0, 0, 1, 1 ), byrow = TRUE, ncol = 3) matrix_report(A) matrix_report(B)
A <- matrix(c( 1, 1, 0, 0, -1, 1, 0, 0, 1, 1, 0, 0, NA, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0 ), byrow = TRUE, ncol = 5) B <- matrix(c( 1, 0, 0, 1, 1, 0, 0, NA, 0, 0, 1, 0, 0, 1, 1 ), byrow = TRUE, ncol = 3) matrix_report(A) matrix_report(B)
Transform a square matrix to an edge-list
matrix_to_edgelist(A, digraph = FALSE, valued = FALSE, loops = FALSE)
matrix_to_edgelist(A, digraph = FALSE, valued = FALSE, loops = FALSE)
A |
A square matrix |
digraph |
Whether the matrix is directed or not |
valued |
Add a third columns with the valued of the relationship |
loops |
Whether the loops are retained or not |
This function transform the matrix into an edgelist
Alejandro Espinosa-Rada
A <- matrix(c( 0, 2, 1, 1, 0, 0, 1, 0, 1 ), byrow = TRUE, ncol = 3) matrix_to_edgelist(A, digraph = TRUE, valued = TRUE, loops = TRUE)
A <- matrix(c( 0, 2, 1, 1, 0, 0, 1, 0, 1 ), byrow = TRUE, ncol = 3) matrix_to_edgelist(A, digraph = TRUE, valued = TRUE, loops = TRUE)
Meta matrix for multilevel networks
meta_matrix(A1, B1, A2 = NULL, B2 = NULL, A3 = NULL, B3 = NULL)
meta_matrix(A1, B1, A2 = NULL, B2 = NULL, A3 = NULL, B3 = NULL)
A1 |
The square matrix of the lowest level |
B1 |
The incidence matrix of the ties between the nodes of first level and the nodes of the second level |
A2 |
The square matrix of the second level |
B2 |
The incidence matrix of the ties between the nodes of the second level and the nodes of the third level |
A3 |
The square matrix of the third level |
B3 |
The incidence matrix of the ties between the nodes of the third level and the nodes of the first level |
Return a meta matrix for multilevel networks
Alejandro Espinosa-Rada
Carley, K. M. (2002). Smart agents and organizations of the future. In: Leah Lievrouw & Sonia Livingstone (Eds.), The Handbook of New Media (pp. 206-220). Thousand Oaks, CA, Sage.
Krackhardt, D., & Carley, K. M. (1998). PCANS model of structure in organizations (pp. 113- 119). Pittsburgh, Pa, USA: Carnegie Mellon University, Institute for Complex Engineered Systems.
A1 <- matrix(c( 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0 ), byrow = TRUE, ncol = 5) B1 <- matrix(c( 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1 ), byrow = TRUE, ncol = 3) A2 <- matrix(c( 0, 1, 1, 1, 0, 0, 1, 0, 0 ), byrow = TRUE, nrow = 3) B2 <- matrix(c( 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1 ), byrow = TRUE, ncol = 4) A3 <- matrix(c( 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0 ), byrow = TRUE, ncol = 4) B3 <- matrix(c( 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ), byrow = TRUE, ncol = 5) rownames(A1) <- letters[1:nrow(A1)] colnames(A1) <- rownames(A1) rownames(A2) <- letters[nrow(A1) + 1:nrow(A2)] colnames(A2) <- rownames(A2) rownames(B1) <- rownames(A1) colnames(B1) <- colnames(A2) rownames(A3) <- letters[nrow(A1) + nrow(A2) + 1:nrow(A3)] colnames(A3) <- rownames(A3) rownames(B2) <- rownames(A2) colnames(B2) <- colnames(A3) rownames(B3) <- rownames(A3) colnames(B3) <- rownames(A1) meta_matrix(A1, B1, A2, B2, A3, B3)
A1 <- matrix(c( 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0 ), byrow = TRUE, ncol = 5) B1 <- matrix(c( 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1 ), byrow = TRUE, ncol = 3) A2 <- matrix(c( 0, 1, 1, 1, 0, 0, 1, 0, 0 ), byrow = TRUE, nrow = 3) B2 <- matrix(c( 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1 ), byrow = TRUE, ncol = 4) A3 <- matrix(c( 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0 ), byrow = TRUE, ncol = 4) B3 <- matrix(c( 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ), byrow = TRUE, ncol = 5) rownames(A1) <- letters[1:nrow(A1)] colnames(A1) <- rownames(A1) rownames(A2) <- letters[nrow(A1) + 1:nrow(A2)] colnames(A2) <- rownames(A2) rownames(B1) <- rownames(A1) colnames(B1) <- colnames(A2) rownames(A3) <- letters[nrow(A1) + nrow(A2) + 1:nrow(A3)] colnames(A3) <- rownames(A3) rownames(B2) <- rownames(A2) colnames(B2) <- colnames(A3) rownames(B3) <- rownames(A3) colnames(B3) <- rownames(A1) meta_matrix(A1, B1, A2, B2, A3, B3)
Two-mode networks can be represented (or 'projected') as one-mode networks.
minmax_overlap(A, row = TRUE, min = TRUE)
minmax_overlap(A, row = TRUE, min = TRUE)
A |
A matrix object |
row |
Whether to consider the actors in the rows of the matrix (default) or the column. |
min |
Whether to extract the minimum (default) or the maximum overlap. |
This function return the overlap between the modes (a.k.a. actors, nodes, vertices).
Alejandro Espinosa-Rada
Morris, S.A. (2005). Unified Mathematical Treatment of Complex Cascaded Bipartite Networks: The Case of Collections of Journal Papers. Unpub- lished PhD Thesis, Oklahoma State University. Retrieved from http://digital.library.okstate.edu/etd/umi-okstate-1334.pdf
A <- matrix(c( 2, 0, 2, 1, 1, 0, 0, 3, 3, 0, 2, 2, 0, 0, 1 ), byrow = TRUE, ncol = 3) minmax_overlap(A)
A <- matrix(c( 2, 0, 2, 1, 1, 0, 0, 3, 3, 0, 2, 2, 0, 0, 1 ), byrow = TRUE, ncol = 3) minmax_overlap(A)
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.
mix_matrix(A, att = NULL)
mix_matrix(A, att = NULL)
A |
A symmetric matrix object |
att |
Categorical attribute of the nodes |
Values in the diagonal are the number of ties within groups, and off-diagonal are the number of relations between groups.
This function returns a mixing matrix.
Alejandro Espinosa-Rada
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)
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)
Multilevel triad and quadrilateral census
mixed_census(A1, B1, B2 = NULL, quad = FALSE)
mixed_census(A1, B1, B2 = NULL, quad = FALSE)
A1 |
An adjacent matrix object. |
B1 |
An incidence matrix object. |
B2 |
An incidence matrix object. |
quad |
Whether the matrix is a quadrilateral census or not. |
This function return the counts of a multilevel census.
If quad = TRUE
, then the function return the multilevel quadrilateral census.
Alejandro Espinosa-Rada
Espinosa-Rada, A. (2021). A Network Approach for the Sociological Study of Science: Modelling Dynamic Multilevel Networks. [PhD](https://research.manchester.ac.uk/en/studentTheses/a-network-approach-for-the-sociological-study-of-science-and-know). The University of Manchester.
Espinosa-Rada, A., Bellotti, E., Everett, M., & Stadtfeld, C. (2024). Co-evolution of a socio-cognitive scientific network: A case study of citation dynamics among astronomers. Social Networks, 78, 92–108. https://doi.org/10.1016/j.socnet.2023.11.008
Hollway, J., Lomi, A., Pallotti, F., & Stadtfeld, C. (2017). Multilevel social spaces: The network dynamics of organizational fields. Network Science, 5(2), 187–212. https://doi.org/10.1017/nws.2017.8
B1 <- matrix(c( 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0 ), byrow = TRUE, ncol = 3) A1 <- matrix(c( 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0 ), byrow = TRUE, ncol = 4) B2 <- matrix(c( 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ), byrow = TRUE, ncol = 5) mixed_census(A1, B1, B2, quad = TRUE)
B1 <- matrix(c( 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0 ), byrow = TRUE, ncol = 3) A1 <- matrix(c( 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0 ), byrow = TRUE, ncol = 4) B2 <- matrix(c( 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ), byrow = TRUE, ncol = 5) mixed_census(A1, B1, B2, quad = TRUE)
Degree centrality for multilevel networks
multilevel_degree( A1, B1, A2 = NULL, B2 = NULL, A3 = NULL, B3 = NULL, complete = FALSE, digraphA1 = FALSE, digraphA2 = FALSE, digraphA3 = FALSE, typeA1 = "out", typeA2 = "out", typeA3 = "out", loopsA1 = FALSE, loopsA2 = FALSE, loopsA3 = FALSE, normalized = FALSE, weightedA1 = FALSE, weightedA2 = FALSE, weightedA3 = FALSE, alphaA1 = 0.5, alphaA2 = 0.5, alphaA3 = 0.5 )
multilevel_degree( A1, B1, A2 = NULL, B2 = NULL, A3 = NULL, B3 = NULL, complete = FALSE, digraphA1 = FALSE, digraphA2 = FALSE, digraphA3 = FALSE, typeA1 = "out", typeA2 = "out", typeA3 = "out", loopsA1 = FALSE, loopsA2 = FALSE, loopsA3 = FALSE, normalized = FALSE, weightedA1 = FALSE, weightedA2 = FALSE, weightedA3 = FALSE, alphaA1 = 0.5, alphaA2 = 0.5, alphaA3 = 0.5 )
A1 |
The square matrix of the lowest level |
B1 |
The incidence matrix of the ties between the nodes of first level and the nodes of the second level |
A2 |
The square matrix of the second level |
B2 |
The incidence matrix of the ties between the nodes of the second level and the nodes of the third level |
A3 |
The square matrix of the third level |
B3 |
The incidence matrix of the ties between the nodes of the third level and the nodes of the first level |
complete |
Add the degree of bipartite and tripartite networks for B1, B2 and/or B3, and the low_multilevel (i.e. A1+B1+B2+B3), meso_multilevel (i.e. B1+A2+B2+B3) and high_multilevel (i.e. B1+B2+A3+B3) degree |
digraphA1 |
Whether A1 is a directed network |
digraphA2 |
Whether A2 is a directed network |
digraphA3 |
Whether A3 is a directed network |
typeA1 |
Type of degree of the network for A1, "out" for out-degree, "in" for in-degree or "all" for the sum of the two |
typeA2 |
Type of degree of the network for A2, "out" for out-degree, "in" for in-degree or "all" for the sum of the two |
typeA3 |
Type of degree of the network for A3, "out" for out-degree, "in" for in-degree or "all" for the sum of the two |
loopsA1 |
Whether the loops of the edges are considered in matrix A1 |
loopsA2 |
Whether the loops of the edges are considered in matrix A2 |
loopsA3 |
Whether the loops of the edges are considered in matrix A3 |
normalized |
If TRUE then the result is divided by (n-1)+k+m for the first level, (m-1)+n+k for the second level, and (k-1)+m+n according to Espinosa-Rada et al. (2021) |
weightedA1 |
Whether A1 is weighted |
weightedA2 |
Whether A2 is weighted |
weightedA3 |
Whether A3 is weighted |
alphaA1 |
The alpha parameter of A1 according to Opsahl et al (2010) for weighted networks. The value 0.5 is given by default. |
alphaA2 |
The alpha parameter of A2 according to Opsahl et al (2010) for weighted networks. The value 0.5 is given by default. |
alphaA3 |
The alpha parameter of A3 according to Opsahl et al (2010) for weighted networks. The value 0.5 is given by default. |
Return a data.frame of multilevel degree
Alejandro Espinosa-Rada
Borgatti, S. P., and Everett, M. G. (1997). Network analysis of 2-mode data. Social Networks, 19(3), 243–269.
Freeman, L. C. (1978). Centrality in social networks conceptual clarification. Social Networks, 1(3), 215–239.
Opsahl, T., Agneessens, F., and Skvoretz, J. (2010). Node centrality in weighted networks: Generalizing degree and shortest paths. Social Networks, 32(3), 245–251.
A1 <- matrix(c( 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0 ), byrow = TRUE, ncol = 5) B1 <- matrix(c( 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1 ), byrow = TRUE, ncol = 3) A2 <- matrix(c( 0, 1, 1, 1, 0, 0, 1, 0, 0 ), byrow = TRUE, nrow = 3) B2 <- matrix(c( 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1 ), byrow = TRUE, ncol = 4) A3 <- matrix(c( 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0 ), byrow = TRUE, ncol = 4) B3 <- matrix(c( 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ), byrow = TRUE, ncol = 5) multilevel_degree(A1, B1, A2, B2, A3, B3) ## Not run: multilevel_degree(A1, B1, A2, B2, A3, B3, normalized = TRUE, complete = TRUE) ## End(Not run)
A1 <- matrix(c( 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0 ), byrow = TRUE, ncol = 5) B1 <- matrix(c( 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1 ), byrow = TRUE, ncol = 3) A2 <- matrix(c( 0, 1, 1, 1, 0, 0, 1, 0, 0 ), byrow = TRUE, nrow = 3) B2 <- matrix(c( 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1 ), byrow = TRUE, ncol = 4) A3 <- matrix(c( 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0 ), byrow = TRUE, ncol = 4) B3 <- matrix(c( 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ), byrow = TRUE, ncol = 5) multilevel_degree(A1, B1, A2, B2, A3, B3) ## Not run: multilevel_degree(A1, B1, A2, B2, A3, B3, normalized = TRUE, complete = TRUE) ## End(Not run)
This function counts the different subgraphs of three nodes in a multiplex directed and undirected network.
multiplex_census(A, B)
multiplex_census(A, B)
A |
A directed matrix object. |
B |
An undirected matrix object. |
This function gives the counts of the mixed multiplex triad census for a directed and an undirected network.
Alejandro Espinosa-Rada
Espinosa-Rada, A. (2021). A Network Approach for the Sociological Study of Science: Modelling Dynamic Multilevel Networks. [PhD](https://research.manchester.ac.uk/en/studentTheses/a-network-approach-for-the-sociological-study-of-science-and-know). The University of Manchester.
Espinosa-Rada, A., Bellotti, E., Everett, M., & Stadtfeld, C. (2024). Co-evolution of a socio-cognitive scientific network: A case study of citation dynamics among astronomers. Social Networks, 78, 92–108. https://doi.org/10.1016/j.socnet.2023.11.008
# SOAR A <- matrix( c( 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ), byrow = TRUE, ncol = 12 ) B <- matrix( c( 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ), byrow = TRUE, ncol = 12 ) multiplex_census(A, B)
# SOAR A <- matrix( c( 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ), byrow = TRUE, ncol = 12 ) B <- matrix( c( 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ), byrow = TRUE, ncol = 12 ) multiplex_census(A, B)
Clique Percolation Method (CPM) is an algorithm for finding overlapping communities within networks, introduced by Palla et al. (2005). This function firstly identify cliques of size k, then creates a incidence matrix as an affiliation network.
percolation_clique(A)
percolation_clique(A)
A |
A matrix |
A matrix that assign each node to a clique
Alejandro Espinosa-Rada
Palla, G., Derényi, I., Farkas, I., & Vicsek, T. (2005). Uncovering the overlapping community structure of complex networks in nature and society. Nature, 435(7043), 814-818.
A <- matrix( c( 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 ), byrow = TRUE, ncol = 9 ) rownames(A) <- letters[1:nrow(A)] colnames(A) <- letters[1:ncol(A)] percolation_clique(A)
A <- matrix( c( 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 ), byrow = TRUE, ncol = 9 ) rownames(A) <- letters[1:nrow(A)] colnames(A) <- letters[1:ncol(A)] percolation_clique(A)
This function permutes the labels of a matrix.
perm_label(A, m = 1, unique = FALSE)
perm_label(A, m = 1, unique = FALSE)
A |
A matrix |
m |
Number of permutations |
unique |
Whether to return unique cases |
This function returns the permutation of labels.
Alejandro Espinosa-Rada
W <- matrix(c( 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0 ), byrow = TRUE, ncol = 5) rownames(W) <- c("P", "Q", "R", "S", "T") colnames(W) <- rownames(W) perm_label(W, m = 1000, unique = TRUE)
W <- matrix(c( 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0 ), byrow = TRUE, ncol = 5) rownames(W) <- c("P", "Q", "R", "S", "T") colnames(W) <- rownames(W) perm_label(W, m = 1000, unique = TRUE)
This function create permutation matrices.
perm_matrix(n, m = 1, unique = FALSE)
perm_matrix(n, m = 1, unique = FALSE)
n |
The size of the square matri |
m |
Number of permutations |
unique |
Whether to return unique cases |
This function returns a list of permutation matrices
Alejandro Espinosa-Rada
W <- matrix(c( 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0 ), byrow = TRUE, ncol = 5) rownames(W) <- c("P", "Q", "R", "S", "T") colnames(W) <- rownames(W) perm_matrix(5, m = 1000, unique = TRUE)
W <- matrix(c( 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0 ), byrow = TRUE, ncol = 5) rownames(W) <- c("P", "Q", "R", "S", "T") colnames(W) <- rownames(W) perm_matrix(5, m = 1000, unique = TRUE)
Positive-negative centrality
posneg_index(A, select = c("all", "in", "out"))
posneg_index(A, select = c("all", "in", "out"))
A |
A signed symmetric matrix (i.e., with ties that are either -1, 0 or 1) |
select |
Whether to consider the direction of the outgoing ties. Considering |
This function return the positive-negative centrality index for signed networks (Everett and Borgatti).
Adapted from David Schoch 'signnet'
Everett, Martin and Borgatti, Stephen (2014). Networks containing negative ties. Social Networks, 38, 111-120. http://dx.doi.org/10.1016/j.socnet.2014.03.005
A <- matrix( c( 0, 1, -1, -1, -1, -1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 1, 1, 0, -1, 0, -1, -1, 0, 0, -1, -1, 0, 0, 0, 0, 1, 1, -1, -1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, -1, -1, -1, -1, 1, 0, 0, 0, 1, 1, -1, 0, 1, 1, -1, 0, 0, -1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, -1, 0, 0, 0, -1, 0, 0, 1, -1, 0, 0, 0, 1, -1, 0, 1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 1, 0, -1, 0, 1, 0, -1, 0, 0, 0, 0, 0, 0, 1, 1, 1, -1, -1, 0, 1, -1, 0, -1, -1, -1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, -1, -1, -1, 0, 0, 0, 0, 0, -1, 1, 0, 1, 1, -1, 0, 0, 1, -1, -1, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, -1, 1, 0, 0, -1, 1, 1, 0, 0, -1, 0, 0, 0, -1, -1, -1, -1, -1, 0, 0, 1, 1, 1, 0, 0, -1, -1, 0, 0, 0, 0, -1, -1, -1, -1, 1, 0 ), ncol = 16, nrow = 16, byrow = TRUE ) label <- c( "Gavev", "Kotun", "Ove", "Alika", "Nagam", "Gahuk", "Masil", "Ukudz", "Notoh", "Kohik", "Geham", "Asaro", "Uheto", "Seuve", "Nagad", "Gama" ) rownames(A) <- label colnames(A) <- rownames(A) posneg_index(A, select = c("all"))
A <- matrix( c( 0, 1, -1, -1, -1, -1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 1, 1, 0, -1, 0, -1, -1, 0, 0, -1, -1, 0, 0, 0, 0, 1, 1, -1, -1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, -1, -1, -1, -1, 1, 0, 0, 0, 1, 1, -1, 0, 1, 1, -1, 0, 0, -1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, -1, 0, 0, 0, -1, 0, 0, 1, -1, 0, 0, 0, 1, -1, 0, 1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 1, 0, -1, 0, 1, 0, -1, 0, 0, 0, 0, 0, 0, 1, 1, 1, -1, -1, 0, 1, -1, 0, -1, -1, -1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, -1, -1, -1, 0, 0, 0, 0, 0, -1, 1, 0, 1, 1, -1, 0, 0, 1, -1, -1, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, -1, 1, 0, 0, -1, 1, 1, 0, 0, -1, 0, 0, 0, -1, -1, -1, -1, -1, 0, 0, 1, 1, 1, 0, 0, -1, -1, 0, 0, 0, 0, -1, -1, -1, -1, 1, 0 ), ncol = 16, nrow = 16, byrow = TRUE ) label <- c( "Gavev", "Kotun", "Ove", "Alika", "Nagam", "Gahuk", "Masil", "Ukudz", "Notoh", "Kohik", "Geham", "Asaro", "Uheto", "Seuve", "Nagad", "Gama" ) rownames(A) <- label colnames(A) <- rownames(A) posneg_index(A, select = c("all"))
Power of a matrix computed by successive matrix multiplication.
power_function(A, n)
power_function(A, n)
A |
A matrix |
n |
Positive integer |
This function return the power of a matrix by repeating matrix multiplication.
Alejandro Espinosa-Rada
Wasserman, S. and Faust, K. (1994). Social network analysis: Methods and applications. Cambridge University Press.
A <- matrix(c( 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1 ), byrow = TRUE, ncol = 4, nrow = 4) power_function(A, 1000)
A <- matrix(c( 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1 ), byrow = TRUE, ncol = 4, nrow = 4) power_function(A, 1000)
Q-structure of a simplicial complex.
q_analysis(A, simplicial_complex = FALSE, dimensions = FALSE)
q_analysis(A, simplicial_complex = FALSE, dimensions = FALSE)
A |
An incidence matrix |
simplicial_complex |
Whether the incidence matrix is a simplices or simplicial complexes representation |
dimensions |
Return the successively chains from high to low dimensions ($q$) and the number of components ($Q_p$) |
This function return a q-analysis of a simplicial complex matrix
Alejandro Espinosa-Rada
Atkin, R. H. (1974). Mathematical structure in human affairs. New York: Crane, Rusak.
Freeman, L. C. (1980). Q-analysis and the structure of friendship networks. International Journal of Man-Machine Studies, 12(4), 367–378. https://doi.org/10.1016/S0020-7373(80)80021-6
A <- matrix(c( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ), byrow = TRUE, ncol = 19) colnames(A) <- letters[1:ncol(A)] rownames(A) <- 1:nrow(A) q_analysis(A, simplicial_complex = TRUE)
A <- matrix(c( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ), byrow = TRUE, ncol = 19) colnames(A) <- letters[1:ncol(A)] rownames(A) <- 1:nrow(A) q_analysis(A, simplicial_complex = TRUE)
This measure calculated the reciprocity of an asymmetric matrix (directed graph).
recip_coef( A, diag = NULL, method = c("total_ratio", "ratio_nonnull", "global") )
recip_coef( A, diag = NULL, method = c("total_ratio", "ratio_nonnull", "global") )
A |
A matrix |
diag |
Whether to consider the diagonal of the matrix |
method |
Whether to use |
Return a reciprocity coefficient
Alejandro Espinosa-Rada A <- matrix(c(0,1,1,0, 1,0,1,0, 0,0,0,0, 1,0,0,0), byrow = TRUE, ncol = 4) recip_coef(A)
Wasserman, S. and Faust, K. (1994). Social network analysis: Methods and applications. Cambridge University Press.
Redundancy measures of the structural holes theory for binary matrixes
redundancy(A, ego = NULL, digraph = FALSE, weighted = FALSE)
redundancy(A, ego = NULL, digraph = FALSE, weighted = FALSE)
A |
A symmetric matrix object |
ego |
Name of ego in the matrix |
digraph |
Whether the matrix is directed or undirected |
weighted |
Whether the matrix is weighted or not |
This function returns redundancy, effective size and efficincy measures (Burt, 1992).
Alejandro Espinosa-Rada
Burt, R.S., 1992. Structural Holes: the Social Structure of Competition. Harvard University Press, Cambridge.
Borgatti, S., 1997. Unpacking Burt's redundancy measure. Connections, 20(1): 35-38. doi: http://www.analytictech.com/connections/v20(1)/holes.htm
A <- matrix(c( 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0 ), ncol = 7, byrow = TRUE) rownames(A) <- letters[1:nrow(A)] colnames(A) <- letters[1:ncol(A)] redundancy(A, ego = "g")
A <- matrix(c( 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0 ), ncol = 7, byrow = TRUE) rownames(A) <- letters[1:nrow(A)] colnames(A) <- letters[1:ncol(A)] redundancy(A, ego = "g")
incidence matrix of simplexes or cliques
simplicial_complexes(A, zero_simplex = FALSE, projection = FALSE)
simplicial_complexes(A, zero_simplex = FALSE, projection = FALSE)
A |
A symmetric matrix object. |
zero_simplex |
Whether to include the zero simple. |
projection |
Whether to return the links between actors (i.e., rows) through their shared linking events (i.e., columns). |
This function return an incidence matrix of actors participating in simplices or simplicial complexes
Alejandro Espinosa-Rada
Atkin, R. H. (1974). Mathematical structure in human affairs. New York: Crane, Rusak.
Freeman, L. C. (1980). Q-analysis and the structure of friendship networks. International Journal of Man-Machine Studies, 12(4), 367–378. https://doi.org/10.1016/S0020-7373(80)80021-6
Wasserman, S. and Faust, K. (1994). Social network analysis: Methods and applications. Cambridge University Press.
A <- matrix(c( 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ), byrow = TRUE, ncol = 9) rownames(A) <- letters[1:nrow(A)] colnames(A) <- rownames(A) simplicial_complexes(A, zero_simplex = FALSE)
A <- matrix(c( 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ), byrow = TRUE, ncol = 9) rownames(A) <- letters[1:nrow(A)] colnames(A) <- rownames(A) simplicial_complexes(A, zero_simplex = FALSE)
This function calculate some spatial autocorrelations for a sample of networks at different orders (distances).
spatial_cor( A, V, measures = c("covariance", "correlation", "moran", "geary"), mean = TRUE, diag = FALSE, distance1 = TRUE, rowstand = FALSE, scale = FALSE )
spatial_cor( A, V, measures = c("covariance", "correlation", "moran", "geary"), mean = TRUE, diag = FALSE, distance1 = TRUE, rowstand = FALSE, scale = FALSE )
A |
A symmetric matrix |
V |
A vector |
measures |
Whether to use the Covariance |
mean |
Whether to use the mean of the vector for the measures |
diag |
Whether to consider the diagonal of the matrix for the measures |
distance1 |
Whether to return only the spatial autocorrelation considering the actor at distance 1 |
rowstand |
Whether to use the row-standardization to estimate Moran I (Anselin, 1995) |
scale |
Whether to scale Moran I (Anselin, 1995) |
This function return the global spatial autocorrelation. Multiple orders can also be computed.
Anselin, L. (1995). Local indicators of spatial association—LISA. Geographical analysis, 27(2), 93-115.
Geary, R.C. (1954). “The Contiguity Ratio and Statistical Mapping.” The Incorporated Statistician, 5: 115-145.
Moran, P.A.P. (1950). “Notes on Continuous Stochastic Phenomena.” Biometrika, 37: 17-23.
A <- matrix(c( 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0 ), byrow = TRUE, ncol = 4) V <- c(2, 2, 1, 1) spatial_cor(A, V, measures = c("moran"))
A <- matrix(c( 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0 ), byrow = TRUE, ncol = 4) V <- c(2, 2, 1, 1) spatial_cor(A, V, measures = c("moran"))
Structural balance
struc_balance(A, B = NULL, score = c("triangle", "walk"))
struc_balance(A, B = NULL, score = c("triangle", "walk"))
A |
A signed symmetric matrix (i.e., with ties that are either -1, 0 or 1) |
B |
A signed symmetric matrix considered as the negative ties (i.e., with ties that are either -1, 0 or 1) |
score |
Whether to return the |
This function return the structural balance (Heider, 1940; Cartwright and Harary, 1956).
When B
is used, matrix A is considered the negative matrix and A
the positive matrix.
Alejandro Espinosa-Rada
Aref, Samin and Wilson, Mark C. (2017). Measuring partial balance in signed networks. Journal of Complex Networks, 6(4): 566-595.
Cartwright, Dorwin, and Harary, Frank (1956). Structural balance: a generalization of Heider's theory. Psychological review, 63(5), 277.
Heider, Fritz (1946). Attitudes and Cognitive Organization. The Journal of Psychology, 21: 107–112
A <- matrix(c( 0, -1, -1, 0, -1, 0, 1, 0, -1, 1, 0, 0, 0, 0, 0, 0 ), byrow = TRUE, ncol = 4) rownames(A) <- letters[1:nrow(A)] colnames(A) <- rownames(A) struc_balance(A)
A <- matrix(c( 0, -1, -1, 0, -1, 0, 1, 0, -1, 1, 0, 0, 0, 0, 0, 0 ), byrow = TRUE, ncol = 4) rownames(A) <- letters[1:nrow(A)] colnames(A) <- rownames(A) struc_balance(A)
Assign NA to missing data in matrices.
structural_na( A, label = NULL, row_labels = NULL, col_labels = NULL, two_mode = FALSE )
structural_na( A, label = NULL, row_labels = NULL, col_labels = NULL, two_mode = FALSE )
A |
An incident or symmetric matrix object. |
label |
A string vector with the names of the theoretical complete matrix (used for one-mode networks only). |
row_labels |
A string vector with the names of the rows (used for two-mode networks). |
col_labels |
A string vector with the names of the columns (used for two-mode networks). |
two_mode |
Boolean indicating whether the matrix is two-mode. Default is FALSE. |
This function returns a matrix with NA assigned to missing data.
# Example for one-mode network A <- matrix(c( 0, 1, 1, 1, 0, 1, 0, 0, 0 ), byrow = TRUE, ncol = 3) colnames(A) <- c("A", "C", "D") rownames(A) <- c("A", "C", "D") label <- c("A", "B", "C", "D", "E") structural_na(A, label = label) # Example for two-mode network B <- matrix(c( 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 ), byrow = TRUE, ncol = 3) rownames(B) <- c("X1", "X2", "X3", "X4") colnames(B) <- c("Y1", "Y2", "Y3") rlabels <- c("X1", "X2", "X3", "X4", "X5") clabels <- c("Y1", "Y2", "Y3", "Y4") structural_na(B, row_labels = rlabels, col_labels = clabels, two_mode = TRUE)
# Example for one-mode network A <- matrix(c( 0, 1, 1, 1, 0, 1, 0, 0, 0 ), byrow = TRUE, ncol = 3) colnames(A) <- c("A", "C", "D") rownames(A) <- c("A", "C", "D") label <- c("A", "B", "C", "D", "E") structural_na(A, label = label) # Example for two-mode network B <- matrix(c( 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 ), byrow = TRUE, ncol = 3) rownames(B) <- c("X1", "X2", "X3", "X4") colnames(B) <- c("Y1", "Y2", "Y3") rlabels <- c("X1", "X2", "X3", "X4", "X5") clabels <- c("Y1", "Y2", "Y3", "Y4") structural_na(B, row_labels = rlabels, col_labels = clabels, two_mode = TRUE)
This measure is sometimes called clustering coefficient.
trans_coef( A, method = c("weakcensus", "global", "mean", "local"), select = c("all", "in", "out") )
trans_coef( A, method = c("weakcensus", "global", "mean", "local"), select = c("all", "in", "out") )
A |
A matrix |
method |
Whether to calculate the |
select |
Whether to consider |
Return a transitivity measure
Alejandro Espinosa-Rada
Wasserman, S. and Faust, K. (1994). Social network analysis: Methods and applications. Cambridge University Press.
A <- matrix(c( 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0 ), byrow = TRUE, ncol = 5) rownames(A) <- letters[1:ncol(A)] colnames(A) <- rownames(A) trans_coef(A, method = "local")
A <- matrix(c( 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0 ), byrow = TRUE, ncol = 5) rownames(A) <- letters[1:ncol(A)] colnames(A) <- rownames(A) trans_coef(A, method = "local")
This function assigns a one in the elements of the matrix if a group of actors are part of a transitivity structure (030T label considering the MAN triad census)
trans_matrix(A, loops = FALSE)
trans_matrix(A, loops = FALSE)
A |
A matrix |
loops |
Whether to expect nonzero elements in the diagonal of the matrix |
A vector assigning an id the components that each of the nodes of the matrix belongs
Alejandro Espinosa-Rada
Davis, J.A. and Leinhardt, S. (1972). “The Structure of Positive Interpersonal Relations in Small Groups.” In J. Berger (Ed.), Sociological Theories in Progress, Vol. 2, 218-251. Boston: Houghton Mifflin.
Wasserman, S. and Faust, K. (1994). Social network analysis: Methods and applications. Cambridge University Press.
A <- matrix( c( 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 ), byrow = TRUE, ncol = 6 ) rownames(A) <- letters[1:NROW(A)] colnames(A) <- rownames(A) trans_matrix(A, loops = TRUE)
A <- matrix( c( 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 ), byrow = TRUE, ncol = 6 ) rownames(A) <- letters[1:NROW(A)] colnames(A) <- rownames(A) trans_matrix(A, loops = TRUE)
Considering the triad census of Davis and Leinhardt (1972) for vector A, B, and C:
triad_uman(A, ztest = FALSE, covar = FALSE)
triad_uman(A, ztest = FALSE, covar = FALSE)
A |
A symmetric matrix object |
ztest |
Return Z and p-value |
covar |
Return the covarianc matrix for triadic analysis |
003 = A,B,C, empty triad
012 = A -> B, C, triad with a single directed edge
102 = A <-> B, C, triad with a reciprocated connection between two vertices
021D = A <-B-> C, triadic out-star
021U = A -> B <- C triadic in-star
021C = A-> B-> C, directed line
111D = A <-> B <-C
111U = A <-> B-> C
030T = A-> B <-C, A-> C
030C = A <-B <-C, A-> C
201 = A <-> B <-> C
120D = A <-B-> C, A <-> C
120U = A-> B <-C, A <->C
120C = A-> B-> C, A <-> C
210 = A-> B <-> C, A <-> C
300 = A <-> B <-> C, A <->C, complete triad.
This function gives the counts of the triad census, the expected counts, assuming that U|MAN distribution (Holland and Leinhardt, 1975, 1976) is operating, and the standard deviations of these counts.
Alejandro Espinosa-Rada
Davis, J.A. and Leinhardt, S. (1972). The Structure of Positive Interpersonal Relations in Small Groups. In J. Berger (Ed.), Sociological Theories in Progress, Volume 2, 218-251. Boston: Houghton Mifflin.
Holland, P. W. and Leinhardt, S. (1975). The statistical analysis of local structure in social networks. In D. R. Heise (Ed.), Sociological Methodology, 1976 (Jossey-Bass, pp. 1–45).
Holland, P. W. and Leinhardt, S. (1976). Local Structure in Social Networks. Sociological Methodology, 7, 1–45. doi: https://doi.org/10.2307/270703
Wasserman, S. and Faust, K. (1994). Social network analysis: Methods and applications. Cambridge University Press.
data(krackhardt_friends) triad_uman(krackhardt_friends) ## Not run: triad_uman(krackhardt_friends, ztest = TRUE, covar = TRUE) ## End(Not run)
data(krackhardt_friends) triad_uman(krackhardt_friends) ## Not run: triad_uman(krackhardt_friends, ztest = TRUE, covar = TRUE) ## End(Not run)
Z test of the number of arcs
z_arctest(G, p = 0.5, interval = FALSE)
z_arctest(G, p = 0.5, interval = FALSE)
G |
A symmetric matrix object. |
p |
Constant probability p. |
interval |
Return a 95 percent confidence interval. |
This function gives a Z test and p-value for the number of lines or arcs present in a directed graph
Alejandro Espinosa-Rada
Wasserman, S. and Faust, K. (1994). Social network analysis: Methods and applications. Cambridge University Press.
data(krackhardt_friends) z_arctest(krackhardt_friends)
data(krackhardt_friends) z_arctest(krackhardt_friends)
Second-zone multilevel sampling considering a second-mode focal actor
zone_sample(A, X, ego = TRUE, core = FALSE)
zone_sample(A, X, ego = TRUE, core = FALSE)
A |
A symmetric matrix object. |
X |
X an incidence matrix object. |
ego |
Whether to add or not ego into the subgraph. |
core |
Whether to add actors at distance one from ego |
This function return a list of second-zone subgraphs using as a focal actor the second-mode of the multilevel network.
Alejandro Espinosa-Rada
Espinosa-Rada, A. (2021). A Network Approach for the Sociological Study of Science: Modelling Dynamic Multilevel Networks. [PhD](https://research.manchester.ac.uk/en/studentTheses/a-network-approach-for-the-sociological-study-of-science-and-know). The University of Manchester.
A <- matrix(c( 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ), byrow = TRUE, ncol = 8) colnames(A) <- c("1", "2", "3", "4", "5", "6", "7", "8") rownames(A) <- c("1", "2", "3", "4", "5", "6", "7", "8") X <- matrix(c( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ), byrow = TRUE, ncol = 4) colnames(X) <- c("a", "b", "c", "d") rownames(X) <- c("1", "2", "3", "4", "5", "6", "7", "8") set.seed(18051889) zone_sample(A, X, core = TRUE)
A <- matrix(c( 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ), byrow = TRUE, ncol = 8) colnames(A) <- c("1", "2", "3", "4", "5", "6", "7", "8") rownames(A) <- c("1", "2", "3", "4", "5", "6", "7", "8") X <- matrix(c( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ), byrow = TRUE, ncol = 4) colnames(X) <- c("a", "b", "c", "d") rownames(X) <- c("1", "2", "3", "4", "5", "6", "7", "8") set.seed(18051889) zone_sample(A, X, core = TRUE)