Title: | Multilevel Networks Analysis |
---|---|
Description: | Analyze multilevel networks as described in Lazega et al (2008) <doi:10.1016/j.socnet.2008.02.001> and in Lazega and Snijders (2016, ISBN:978-3-319-24520-1). The package was developed essentially as an extension to 'igraph'. |
Authors: | Neylson Crepalde [aut, cre] |
Maintainer: | Neylson Crepalde <[email protected]> |
License: | GPL-3 |
Version: | 0.2.2.9000 |
Built: | 2025-03-08 04:46:53 UTC |
Source: | https://github.com/neylsoncrepalde/multinets |
Extract one of the three levels of a multilevel network.
extract_highlevel
will extract the higher level vertices and the
edges between them, extract_lowlevel
will extract the lower level
vertices and the edges between them. On the other hand,
extract_mesolevel
will extract all the vertices but only the edges
between vertices from different levels.
extract_highlevel(x)
extract_highlevel(x)
x |
a graph object. Must be a multilevel network. |
extract_highlevel
and extract_lowlevel
return a 1-mode network. All
the vertices in the selected level and the edges between them.
extract_mesolevel
returns a bipartite (2-mode) network.
All the vertices
are kept. Only edges between vertices of different levels are kept. This
is what the literature also calls an affiliation network.
Neylson Crepalde, [email protected]
organizations <- extract_highlevel(linked_sim) individuals <- extract_lowlevel(linked_sim) affiliations <- extract_mesolevel(linked_sim)
organizations <- extract_highlevel(linked_sim) individuals <- extract_lowlevel(linked_sim) affiliations <- extract_mesolevel(linked_sim)
Extract one of the three levels of a multilevel network.
extract_highlevel
will extract the higher level vertices and the
edges between them, extract_lowlevel
will extract the lower level
vertices and the edges between them. On the other hand,
extract_mesolevel
will extract all the vertices but only the edges
between vertices from different levels.
extract_lowlevel(x)
extract_lowlevel(x)
x |
a graph object. Must be a multilevel network. |
extract_highlevel
and extract_lowlevel
return a 1-mode network. All
the vertices in the selected level and the edges between them.
extract_mesolevel
returns a bipartite (2-mode) network.
All the vertices
are kept. Only edges between vertices of different levels are kept. This
is what the literature also calls an affiliation network.
Neylson Crepalde, [email protected]
organizations <- extract_highlevel(linked_sim) individuals <- extract_lowlevel(linked_sim) affiliations <- extract_mesolevel(linked_sim)
organizations <- extract_highlevel(linked_sim) individuals <- extract_lowlevel(linked_sim) affiliations <- extract_mesolevel(linked_sim)
Extract one of the three levels of a multilevel network.
extract_highlevel
will extract the higher level vertices and the
edges between them, extract_lowlevel
will extract the lower level
vertices and the edges between them. On the other hand,
extract_mesolevel
will extract all the vertices but only the edges
between vertices from different levels.
extract_mesolevel(x)
extract_mesolevel(x)
x |
a graph object. Must be a multilevel network. |
extract_highlevel
and extract_lowlevel
return a 1-mode network. All
the vertices in the selected level and the edges between them.
extract_mesolevel
returns a bipartite (2-mode) network.
All the vertices
are kept. Only edges between vertices of different levels are kept. This
is what the literature also calls an affiliation network.
Neylson Crepalde, [email protected]
organizations <- extract_highlevel(linked_sim) individuals <- extract_lowlevel(linked_sim) affiliations <- extract_mesolevel(linked_sim)
organizations <- extract_highlevel(linked_sim) individuals <- extract_lowlevel(linked_sim) affiliations <- extract_mesolevel(linked_sim)
Checks whether a network (a graph) is multilevel according to the linked design proposed by Lazega et al (2008).
is_multilevel(x)
is_multilevel(x)
x |
A graph object. |
A multilevel network can be defined as a network with two kinds of vertex and two kinds of edges: Vertices on the lower level are, usually, individuals. Vertices on the higher level are, usually, organizations, collectivities or other kinds of social joint structures. The first kind of edges are those between the vertices of the higher level and between the vertices of the lower level. The second kind of edges are those between the vertices of different levels (affiliation ties).
Put another way, a multilevel network is a bipartite network (2-mode) that has ties between nodes on both levels.
Neylson Crepalde, [email protected]
Lazega, E., Jourda, M. T., Mounier, L., & Stofer, R. (2008). Catching up with big fish in the big pond? Multi-level network analysis through linked design. Social Networks, 30(2), 159-176.
Lazega, E. and Snijders, Tom A.B. (eds) (2016), Multilevel Network Analysis for the Social Sciences: Theory, Methods and Applications, Springer, Methodos Series.
is_multilevel(linked_sim)
is_multilevel(linked_sim)
Set layout coordinates for multilevel networks from a chosen algorithm
layout_multilevel(x, layout = igraph::layout_with_fr)
layout_multilevel(x, layout = igraph::layout_with_fr)
x |
a graph object. Must be a multilevel network. |
layout |
The chosen layout algorithm. A function layout of the 'igraph' package without parentheses. Default set to 'Fruchterman-Reingold'. |
In order to facilitate the visualization of multilevel networks, higher level nodes are set in the upper part of the plane and the lower level nodes are set in the lower part of the plane.
A two- or three-column matrix, each row giving the coordinates of a vertex, according to the ids of the vertex ids.
Neylson Crepalde, [email protected]
# Check if the network is multilevel is_multilevel(linked_sim) # Generate the layout (x,y) coordinates l <- layout_multilevel(linked_sim) # Plot the graph using the layout plot(linked_sim, layout = l) # Using Kamada Kawai algorithm l.kk <- layout_multilevel(linked_sim, layout = igraph::layout_with_kk) # Plot the graph with the new layout plot(linked_sim, layout = l.kk)
# Check if the network is multilevel is_multilevel(linked_sim) # Generate the layout (x,y) coordinates l <- layout_multilevel(linked_sim) # Plot the graph using the layout plot(linked_sim, layout = l) # Using Kamada Kawai algorithm l.kk <- layout_multilevel(linked_sim, layout = igraph::layout_with_kk) # Plot the graph with the new layout plot(linked_sim, layout = l.kk)
A simulated multilevel network following the "linked design" as proposed by Lazega et al (2008).
linked_sim linked_sim_matrix linked_sim_type
linked_sim linked_sim_matrix linked_sim_type
linked_sim
is a graph object with 150 vertices and 600 edges.
There is one vertex attribute "type" defining to which level each vertex
belongs. FALSE
means lower level and TRUE
means higher level.
linked_sim_matrix is a matrix object that contains the adjacency matrix for the simulated network.
linked_sim_type is a logical vector containing each vertex type.
Neylson Crepalde, [email protected]
Elaborated by the author.
Lazega, E., Jourda, M. T., Mounier, L., & Stofer, R. (2008). Catching up with big fish in the big pond? Multi-level network analysis through linked design. Social Networks, 30(2), 159-176.
Lazega, E. and Snijders, Tom A.B. (eds) (2016), Multilevel Network Analysis for the Social Sciences: Theory, Methods and Applications, Springer, Methodos Series.
This function is a wrapper to the bipartite_projection
function from the 'igraph' package. It transforms a bipartite (2-mode)
network to two 1-mode networks. It is recommended to use it as an analysis
tool for a bipartite network that was obtained from
extract_mesolevel
.
mode_transformation(x, which = c("both", "high", "low"))
mode_transformation(x, which = c("both", "high", "low"))
x |
a bipartite graph object. Data must be bipartite and must not be multilevel |
which |
one of "both", "high" or "low". High indicates to do the transformation to the higher level. Low indicates to do the transformation to the lower level. Both returns a list with both networks. |
The function counts 1 edge when two vertices of the higher level share a vertex of the lower level and 1 edge when two vertices of the lower level are affiliated to the same vertex in the higher level.
If which is set to "both" (default), returns a list with two generated networks. If which is set to "high" or "low", returns a graph object.
Neylson Crepalde, [email protected]
# First, extract the mesolevel of the multilevel network affiliation <- extract_mesolevel(linked_sim) # To obtain both transformed networks transformed <- mode_transformation(affiliation) # To obtain just one transformed network high_transformed <- mode_transformation(affiliation, which = "high")
# First, extract the mesolevel of the multilevel network affiliation <- extract_mesolevel(linked_sim) # To obtain both transformed networks transformed <- mode_transformation(affiliation) # To obtain just one transformed network high_transformed <- mode_transformation(affiliation, which = "high")
Set vertices and edges colors for a multilevel network. Default set to blue (higher level) and red (lower level).
set_color_multilevel(x, color.true = "blue", color.false = "red", V.alpha = 0.7, E.alpha = 0.7)
set_color_multilevel(x, color.true = "blue", color.false = "red", V.alpha = 0.7, E.alpha = 0.7)
x |
a graph object. Must be a multilevel network. |
color.true |
a character. The color to be chosen for the higher
level (attribute |
color.false |
a character. The color to be chosen for the lower
level (attribute |
V.alpha |
numeric. The factor modifying the opacity alpha for the vertices; typically in [0,1]. |
E.alpha |
numeric. The factor modifying the opacity alpha for the edges; typically in [0,1]. |
A graph object. A multilevel network with an added color
vertex attribute vector and a color
edge attribute vector.
Neylson Crepalde, [email protected]
# Check whether a graph is multilevel is_multilevel(linked_sim) # Set the colors for each level linked_sim <- set_color_multilevel(linked_sim)
# Check whether a graph is multilevel is_multilevel(linked_sim) # Set the colors for each level linked_sim <- set_color_multilevel(linked_sim)
Set vertices shapes for a multilevel network. Default set to "square" (higher level) and "circle" (lower level).
set_shape_multilevel(x, shape.true = "square", shape.false = "circle")
set_shape_multilevel(x, shape.true = "square", shape.false = "circle")
x |
a graph object. Must be a multilevel network. |
shape.true |
a character. The shape to be chosen for the higher
level (attribute |
shape.false |
a character. The shape to be chosen for the lower
level (attribute |
A graph object. A multilevel network with an added shape
vertex attribute vector.
Neylson Crepalde, [email protected]
# Check whether a graph is multilevel is_multilevel(linked_sim) # Set the shapes for each level linked_sim <- set_shape_multilevel(linked_sim)
# Check whether a graph is multilevel is_multilevel(linked_sim) # Set the shapes for each level linked_sim <- set_shape_multilevel(linked_sim)