Q-analysis
Description
Q-analysis of a simplicial complex (Atkin, 1974): the q-connected components at every dimension,
the structure vectors, the obstruction vector and the eccentricity of each simplex.
Usage
q_analysis(
A,
simplicial_complex = FALSE,
complex = c("clique", "neighbourhood"),
closed = FALSE,
eccentricity = c("atkin", "johnson"),
dimensions = FALSE
)
q_analysis(
A,
simplicial_complex = FALSE,
complex = c("clique", "neighbourhood"),
closed = FALSE,
eccentricity = c("atkin", "johnson"),
dimensions = FALSE
)
Arguments
A |
An incidence matrix of simplices (rows) and vertices (columns), or a square matrix of a network
|
simplicial_complex |
Whether A is an incidence matrix of simplices (TRUE) or a network (FALSE)
|
complex |
The complex built from a network: the maximal cliques (clique, default) or the neighbourhoods (neighbourhood)
|
closed |
Whether the neighbourhoods include the node itself, for complex = "neighbourhood"
|
eccentricity |
The definition of the eccentricity: atkin (default) or johnson
|
dimensions |
Kept for compatibility with version 1.0-3. The table of the dimensions is always returned
|
Details
A simplex is a set of vertices, and its dimension q is the number of its vertices minus one.
Two simplices are q-near when they share at least q+1 vertices, that is, a face of dimension
q, and q-connected when a chain of q-near simplices joins them. For every q from the largest
dimension down to 0, the simplices of dimension q or more are grouped in q-connected components
(Atkin, 1974; Freeman, 1980). The table of the results has, for each q:
Q, the first structure vector: the number of q-connected components.
n, the second structure vector: the number of simplices of dimension q or more.
Qbar, the third structure vector: 1−Q/n, which is zero when no simplex is q-connected to
another and approaches one when they all form a single component (Raj et al., 2024).
obstruction, the obstruction vector: Q−1, the number of gaps that separate the components
(Atkin, 1974).
The eccentricity measures how much a simplex stands apart from the others, and there are two definitions.
With eccentricity = "atkin" (default) it is (q^−qˇ)/(qˇ+1), where
q^ is the dimension of the simplex and qˇ the dimension of the largest face it shares
with another simplex (Atkin, 1974). It is zero for a simplex that is a face of another, and infinite for a
simplex that shares no vertex with the others. With eccentricity = "johnson" it is the family
eccentricity of Johnson, the smallest proportion of the vertices of the simplex that are not in another
simplex, minσ′∣σ∖σ′∣/∣σ∣, as implemented by Smirnov et al. (2025).
It runs from zero to one, which makes simplices of different dimension comparable, and it is NA
when the complex has a single simplex.
With simplicial_complex = TRUE, the rows of A are the simplices and the columns their
vertices, as in the example of Freeman (1980), where the researchers are simplices of the events that
linked them. The conjugate complex, in which the columns are the simplices, is the analysis of t(A).
With simplicial_complex = FALSE, A is a network and the complex is built from it (Raj et al., 2024):
with complex = "clique", the simplices are the maximal cliques of the underlying undirected
network, including the isolated nodes as simplices of dimension 0; with complex = "neighbourhood",
each node is the simplex of its neighbours, the rows of A (the out-neighbours of a directed
network). With closed = TRUE the node is also a vertex of its own simplex (closed neighbourhood),
so that two adjacent nodes share at least the two of them. The rows without vertices are not simplices.
The complex is the one returned by simplicial_complexes().
Value
This function returns a list with the incidence matrix of the simplices analysed, the
q_table with the structure and obstruction vectors, the components at each q (named
q3, q2, ...), and the eccentricity of each simplex.
Author(s)
Alejandro Espinosa-Rada
References
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. doi:10.1016/S0020-7373(80)80021-6
Raj, U., Banerjee, A., Ray, S. and Bhattacharya, S. (2024). Structure of higher-order interactions in social-ecological networks through Q-analysis of their neighbourhood and clique complex. PLOS ONE, 19(8), e0306409. doi:10.1371/journal.pone.0306409
Smirnov, N., Kurkin, S. and Hramov, A. E. (2025). A Q-analysis package for higher-order interactions analysis in Python and its application in network physiology. Frontiers in Network Physiology, 5. doi:10.3389/fnetp.2025.1691159
Examples
# Freeman (1980): 29 researchers (simplices) and the 19 events that linked them (vertices)
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,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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 <- q_analysis(A, simplicial_complex = TRUE)
Q$q_table
Q$components$q3
# A network: a clique of four nodes and a pendant node
B <- matrix(c(
0, 1, 1, 1, 0,
1, 0, 1, 1, 0,
1, 1, 0, 1, 0,
1, 1, 1, 0, 1,
0, 0, 0, 1, 0
), byrow = TRUE, ncol = 5)
rownames(B) <- letters[1:nrow(B)]
colnames(B) <- rownames(B)
q_analysis(B, complex = "clique")$q_table
q_analysis(B, complex = "neighbourhood")$q_table
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,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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 <- q_analysis(A, simplicial_complex = TRUE)
Q$q_table
Q$components$q3
B <- matrix(c(
0, 1, 1, 1, 0,
1, 0, 1, 1, 0,
1, 1, 0, 1, 0,
1, 1, 1, 0, 1,
0, 0, 0, 1, 0
), byrow = TRUE, ncol = 5)
rownames(B) <- letters[1:nrow(B)]
colnames(B) <- rownames(B)
q_analysis(B, complex = "clique")$q_table
q_analysis(B, complex = "neighbourhood")$q_table
Social influence
Description
Simulates how the opinions of the actors change when they are influenced by their neighbours, under the rules compared by Flache et al. (2017).
Usage
Arguments
AA square matrix of influence, which can be weighted. The rows are usually normalised so that the weights of each actor add up to one
opinionA vector with the initial opinion of every actor, usually between zero and one
ruleThe rule of influence:
assimilation(default),bounded,repulsionorfriedkinmuHow much an actor moves at each step
epsilonMaximum difference of opinion that still influences an actor, for the
boundedrulesusceptibilityWeight given to the neighbours in the
friedkinrule, as a number or a vector with one value per actorstepsNumber of steps
Details
Every actor starts with an opinion and updates it at each step:
assimilation: the actor moves towards the opinions of its neighbours, which leads the network to consensus (French, 1956; DeGroot, 1974).bounded: the actor is only influenced by the neighbours whose opinion differs less thanepsilon, which leads to fragmentation into groups that no longer influence each other (Hegselmann and Krause, 2002).repulsion: the actor moves towards similar neighbours and away from those who are too different, which leads to bi-polarization. The opinions are kept between zero and one.friedkin: the actor combines the opinions of its neighbours with the opinion it started with, andsusceptibilityis the weight given to the neighbours (Friedkin and Johnsen, 1990).Value
This function returns the opinions of every actor at every step, the final opinions, and the number of groups of opinions at the end.
Author(s)
Alejandro Espinosa-Rada
References
DeGroot, M. H. (1974). Reaching a consensus. Journal of the American Statistical Association, 69(345), 118–121. doi:10.1080/01621459.1974.10480137
Flache, A., Mas, M., Feliciani, T., Chattoe-Brown, E., Deffuant, G., Huet, S. and Lorenz, J. (2017). Models of social influence: Towards the next frontiers. Journal of Artificial Societies and Social Simulation, 20(4), 2. doi:10.18564/jasss.3521
French, J. R. P. (1956). A formal theory of social power. Psychological Review, 63(3), 181–194. doi:10.1037/h0046123
Friedkin, N. E. and Johnsen, E. C. (1990). Social influence and opinions. Journal of Mathematical Sociology, 15(3-4), 193–206. doi:10.1080/0022250X.1990.9990069
Hegselmann, R. and Krause, U. (2002). Opinion dynamics and bounded confidence models, analysis and simulation. Journal of Artificial Societies and Social Simulation, 5(3), 2.
Examples