The Emergence and Stability of Groups in Social Networks

An important puzzle in social network research is to explain how macro-level structures emerge from micro-level network processes. Explaining the emergence and stability of structural groups in social networks is particularly difficult for two reasons. First, because groups are characterized both by high connectedness within (group cohesion) and lack of connectedness between them (group boundaries). Second, because a large number of theoretical micro-level network processes contribute to their emergence. We argue that traditional social net- work theories that are concerned with the evolution of positive relations (forces of attraction) are not sufficient to explain the emergence of groups because they lack mechanisms explaining the emergence of group bound- aries. Models that additionally account for the evolution of negative ties (forces of repulsion) may be better suited to explain the emergence and stability of groups. We build a theoretical model and illustrate its usefulness by fitting stochastic actor-oriented models (SAOMs) to empirical data of co-evolving networks of friendship and dislike among 479 secondary-school students. The SAOMs include a number of newly developed effects ex- pressing the co-evolution between positive and negative ties. We then simulate networks from the estimated models to explore the micro-macro link. We find that a model that considers forces of attraction and repulsion simultaneously is better at explaining groups in social networks. In the long run, however, the empirically informed simulations generate networks that are too stylized to be realistic, raising further questions about model degeneracy and time heterogeneity of group processes.


Introduction
Important parts of human life are organized in social groups. In large social contexts, like schools, universities, workplaces, neighborhoods, and digital online communities, people form smaller groups in which they experience a higher level of communication, safety, belonging, interdependence, social norms, and psychological well-being as compared to the rest of the social context (Homans, 1950;Kadushin, 2002;Baumeister and Leary, 1995;Cartwright and Ed Zander, 1960;Turner et al., 1987;Berkman et al., 2000). How groups emerge and remain stable in various contexts is an important question in the social sciences, as group cohesion and group boundaries are linked to crucial societal outcomes such as segregation, group inequalities, differences in information access, and political polarization. The formation and stability of groups is further related to a central puzzle in sociology and social network research of how micro-level network processes aggregate into macro-level network structures (e.g., Stadtfeld, 2018).
Within social groups, individuals typically form strong positive ties, such as friendship (cf. Moody and White, 2003). The interpersonal relations that connect individuals who are members of different groups, however, tend to be weaker, neutral, or even negative (e.g., Granovetter, 1973;Tajfel and Turner, 1979;Stark et al., 2013). From a social network perspective, small groups thereby appear as network clusters-subsets of nodes in a positive social network that have a high density within (group cohesion) and are sparsely connected between (group boundaries) 1 . To distinguish groups based on this structural definition from broader concepts, we refer to them as structural groups in the following. Similar definitions have been linked to social groups in prior work (e.g., Reitz, 1988;Freeman et al., 1989;Freeman, 1992;Zeggelink et al., 1996). boundaries are shaped by exogenous attributes and distances. It is possible, however, that group boundaries are independent of such exogenous factors and evolve through multiple endogenous social network mechanisms. Human groups do in fact not only occur along pre-existing attributes, distances, or kinship ties. Even randomly assembled groups have been linked to in-group attraction and betweengroup repulsion (e.g., Sherif et al., 1961;Puurtinen et al., 2015). One approach of modeling the emergence of structural groups is to assume that the cost of individual ties are non-linear (e.g., individuals maintaining a fixed number of N ties) and that thereby groups with a group size of N are an optimal outcome for individuals that simultaneously strive for being embedded in embedded structures. If we refrain from making such assumptions, however, it is less clear how to model an endogenous process of group formation.
The model that we propose builds upon social network theory and incorporates a battery of well-known positive social mechanisms, for example, reciprocity, transitivity and degree popularity (Rivera et al., 2010;Kadushin, 2012). These mechanisms can be linked to the creation of positive ties within an existing group (group cohesion) and can operate as forces of attraction. However, in the absence of exogenous variables these forces of attraction cannot explain why individuals refrain from creating ties to out-group members. Therefore, we further consider social mechanisms on the evolution of negative ties (Labianca and Brass, 2006;Labianca, 2014;Pál et al., 2016). For example, building on arguments from balance theory and identity theory, we can express how individuals within the same group agree on their negative perceptions of out-group individuals, rather than forming positive ties with them. 2 We argue that the incorporation of such forces of repulsion into a network model helps to explain the emergence and stability of group boundaries.
We discuss the effects of various social network mechanisms (microlevel) on the emergence and stability of groups (macro-level) in section 2. We develop a theoretical model which incorporates both forces of attraction and repulsion. We compare this to a model in which only forces of attraction are considered. We anticipate that the model which includes forces of repulsion will be better able to explain the emergence and stability of structural groups. We test this proposition empirically in a two-step procedure, using a combination of two established analytical strategies.
In the first step, we fit stochastic actor-oriented models (SAOMs, Snijders, 2017) to empirical network data of 479 secondary school students from 13 school classes (between whom 7,879 friendship ties and 3,056 negative ties are observed). We estimate two micro-level models that take into account a number of mechanisms of attraction (attraction model) and mechanisms of attraction and repulsion (attraction and repulsion model). The empirical setting is described in section 3. In order to derive a parsimonious SAOM, we develop a set of novel specifications that express the co-evolution of positive and negative networks. The results of the SAOMs are discussed in section 4.
In the second step, we treat the estimated model as an empirically calibrated agent-based simulation model (Macy and Willer, 2002;Bianchi and Squazzoni, 2015;Snijders and Steglich, 2015;Stadtfeld, 2018). We investigate whether the two empirical models are able to generate networks in which structural groups emerge (section 5). In accordance with our theoretical expectations, we find that the model with only forces of attraction is not able to generate groups with clear boundaries that are stable through time. This macro-outcome is better represented when forces of attraction and repulsion are considered simultaneously. In section 6, we reflect on our combination of research strategies from agent-based modeling and statistical network analysis and discuss in how far the SAOM is different from traditional agentbased simulation models. In section 7, we discuss the implications of our model, results, and analytical strategy for future research on explaining groups and other macro-level phenomena in social networks.

A theoretical model of group formation and stability
We develop a theoretical micro-macro model of group formation. The model builds upon existing social network theory and links a variety of micro-level network processes to group cohesion and group boundaries. It illustrates how the emergence and stability of groups in social networks (the macro level) can be explained by a combination of forces of attraction and repulsion.

Micro level: Forces of attraction and repulsion
Individuals form positive social ties for various reasons (see for example, Rivera et al., 2010;Schaefer et al., 2010;Kadushin, 2012;Block, 2018). The four most widely discussed positive mechanisms in directed social networks are sketched in the first row of Table 1. These "big four" social network mechanisms are reciprocity, transitivity, Fig. 1. Structural groups are characterized by group cohesion and group boundaries. These structural outcomes stem from dynamic social mechanisms. Forces of attraction enforce group cohesion by explaining the emergence of ties within groups, forces of repulsion explain the lack of tie creation between groups and thus the emergence of group boundaries. popularity (or: Matthew effect, preferential attachment, cumulative advantage), and homophily 3 . These positive network mechanisms are related to a number of negative network mechanisms that are shown below in rows 2-5 of Table 1 . We review and further develop a number of arguments that address why these mechanisms tend to be dominant dynamic patterns in social networks (see Yap and Harrigan, 2015), and how they are related to group cohesion and group boundaries.
Reciprocity (Table 1, first column), or the mutual alignment of sentiments and perceptions in dyads, is a process operating between pairs of actors. Granovetter (1973) argues that strong social ties are characterized by "mutual confiding" and "reciprocal services" (p. 1361). Other mechanisms behind reciprocity explain how one-sided relationships tend to either dissolve or develop into mutual ties (Hallinan, 1978). Reciprocity may explain how cohesion between two individuals increases through time and, if one-sided relationships are more likely to emerge within existing groups, how the tendency towards reciprocity will further promote group cohesion.
Below positive reciprocity in Table 1, we show three related dyadic mechanisms. Reciprocity in negative ties represents a tendency for mutually shared negative perceptions between two actors. This mechanism is relevant in outlining boundaries between groups. The two types of mixed (positive-negative) reciprocity are assumed to be outcomes rarely observed due to tendencies for reciprocity in positive and negative networks and for the dissolution of asymmetric positive ties. Processes that prevent the reciprocation of positive ties with negative ones help explaining how within-group negativity may give way to increased cohesion and how negative group boundaries become clear and stabilize over time.
Transitivity (Table 1, second column) is the tendency for positive ties to be aligned between three actors. There are a number of reasons why positive ties between A and B, and B and C lead to positive ties between A and C. Transitivity may stem from an overlap in interaction opportunities (Festinger et al., 1974), dependence between distances in physical space or Blau space (Blau, 1994), or overlap in social foci (Feld, 1981). It can further be a side-product of shared (and potentially unobserved) homophilous preferences (Granovetter, 1973;Goodreau et al., 2009;Stadtfeld and Pentland, 2015), be a consequence of tie formation in line with balance theory (Heider, 1958;Cartwright and Harary, 1956), or be related to reputation diffusion and hierarchy formation (Chase, 1980). The consequence of transitivity (and similarly, potential tendencies of individuals to close cyclic triadic structures) is increasing cohesion within subsets of the network where positive relationships already exist. Transitivity may serve as a nucleus of group formation and thus operates as a central force of attraction. Mechanisms of transitivity and clustering that interplay with reciprocity can magnify these effects (Davis, 1970).
The emergence of transitivity through mechanisms of cognitive balance has been generalized to triadic structures in which positive and negative ties co-exist (Cartwright and Harary, 1956;Hummon and Doreian, 2003). In this approach, any triadic configuration with three positive relationships or one positive and two negative relationships can be seen as balanced. However, the definition of a positive or a negative relationship is not self-evident in empirical studies, since individuals in a triad may have incongruent perceptions about their ties to one another. 4 One could argue that many specific network mechanisms have to be distinguished, for example, those in which a negative tie is asymmetric in either direction or reciprocated.
Here, we propose a simplified representation that significantly reduces the set of possible triadic mechanisms. We assume that a dyad in which at least one negative tie exists is likely to be perceived as a "conflicted dyad" by both individuals involved. This definition is in line with "negative relationships" elaborated in much detail in the social ledger theory of Labianca and Brass (2006). We expect that conflicted dyads are potentially visible to third individuals, affecting the way they form triadic relationships with them. We further assume that an individual A who is not positively tied to either B or C is most likely to perceive that B and C are in a positive relationship if their relation is mutual. We thereby define three mixed (positive-negative) balanced network mechanisms in directed networks (Table 1, second column): i) individuals tend to form positive ties to others if there is a third person with whom they both have a conflicted dyad; ii) individuals tend to form negative ties to others who are in a conflicted dyad with someone who they are positively tied to; iii) individuals tend to form negative ties to others who are reciprocally positively connected with someone with whom they are in a conflicted dyad. The advantage of using conflicted dyads is that we do not need to consider different cases that have the same consequences according to structural balance theory (e.g., disliking someone a friend dislikes and disliking someone who dislikes a friend).
Each of the mixed (positive-negative) balanced triads includes one positive relationship and two negative ones. When groups exist, we may assume that the positive tie is most likely to be within a group, whereas the two negative relationships will define the boundaries to a third person who is not a member of the group (Hummon and Doreian, 2003). The mixed balanced triadic mechanisms thus contribute to group cohesion and group boundaries and operate as forces of attraction and repulsion. This interpretation of balanced triads is in line with social identity theory (Tajfel and Turner, 1979) that argues that people within a group tend to agree on their perceptions towards outgroup members. These shared perceptions will be observed at the groups' boundaries. Shared perceptions and group boundaries will further contribute to the development of a group identity that enforces group cohesion through positive ties.
Popularity (Table 1, third column) is an endogenous social mechanism and relates to the tendency that those who are perceived as popular by others tend to attract additional positive ties. Merton (1968) initially referred to this phenomenon as the "Matthew effect", whereas other scholars called this mechanism "preferential attachment" (Newman, 2001), or "cumulative advantage" (Price, 1976). The same Table 1 Core social mechanisms that relate to attraction (increasing cohesion within groups) and repulsion (emergence of group boundaries). The tie that is subject to change is indicated by a dotted arrow. For example, the top left diagram indicates the reciprocity mechanism whereby an existing positive tie in one direction increases the likelihood of a later positive tie in the opposite direction. Positive ties are blue, negative ties are red. Where the nodal attribute matters, this is indicated by a background pattern. In case it only matters that at least one negative tie exists within a dyad regardless of its direction (a conflicted dyad), the tie is indicated as undirected. mechanism for negative networks is equally likely: negatively perceived individuals tend to attract additional negative ties (Pál et al., 2016). Positive and negative popularity effects should partly be irrespective of group boundaries and it is thus unclear how much popularity mechanisms in negative or positive networks may contribute to cohesion within groups or to the emergence of group boundaries. However, mechanisms of popularity (as well as mixed popularity effects that are referring, for example, to the tendency not to dislike popular individuals) may explain the formation of initial positive and negative ties that serve as nuclei in the formation of groups and the definition of boundaries.
Homophily (Table 1, last column) relates to the increased likelihood of forming ties to others who are similar (McPherson et al., 2001). Empirical evidence for the effect of homophily on group formation has been found within various contexts (Mäs et al., 2010) and regarding different attributes (see e.g., Moody (2001), Stark and Flache (2012), Boda and Néray (2015) on ethnic segregation). Homophily will increase the cohesion within groups whose members are characterized by an attribute and thus operate as a straightforward force of attraction.
In turn, heterophobia as a parallel mechanism would explain how negative ties generate boundaries between groups of individuals who are dissimilar. In case of the presence of strong homophily and heterophobia, one could thus perfectly explain the emergence and stability of social groups (Skvoretz, 2013). However, homophily has been argued to be multidimensional (Block and Grund, 2014). This would suggest that homophily as a main driver of group formation could be limited to contexts in which multiple individual attributes are highly correlated. Rarely are social groups perfectly bounded by individual attributes which suggests that similarity mechanisms need to be studied in a multi-mechanistic network framework. Some studies (e.g., Marques et al., 1988;Pál et al., 2016) found empirical evidence for mechanisms of dislike between similar individuals (homophobia 5 ). In such situations a homophily/heterophobia model will in particular not be able to explain the formation of social groups. Overall, we assume that similaritybased mechanisms play an important role in promoting group cohesion and drawing group boundaries.

Macro level: The emergence and stability of groups
Social forces of attraction can naturally be linked to the development of cohesion within groups. Reciprocity explains how one-sided relationships develop into mutual relations. Transitivity explains how "missing links" in a group may come about. Popular individuals within a group will attract additional ties from group members. Homophily explains how those who are similar are more likely to form cohesive groups.
Conceptually, however, there is a flaw in the attraction model on the macro level. If reciprocity, transitivity, popularity, and homophily explain tie formation between individuals, then this happens partly irrespective of endogenous group boundaries. A popular actor within a group will also attract ties from the outside, giving rise to opportunities for subsequent transitive closure and reciprocity. Any incidental connection from a group member to the outgroup serves as a seed facilitating the further growth of the group and the integration of outsiders and their social ties. A pure attraction model will thus, intuitively, only explain how groups expand, until they reach the limit set by the social context. The level of cohesion in this scenario is potentially constrained by the finite time and resources individuals can invest in forming and maintaining relationships, but not by group boundaries. As a consequence, boundaries between groups will seemingly exist at times, but they will be unstable, unless exogenous attributes in combination with homophily can fully explain them. If this is not the case, each pair of individuals will be likely to appear in the same group at some point. This macro-level outcome is contrary to our intuition and empirical observation of stable group structures in various social contexts that do not solely follow exogenously defined faultlines.
Including social forces of repulsion is a possible way of solving the problem of unclear group boundaries and group instability. Then, through mechanisms of structural balance, individuals will not only align their perceptions about positive ties, but also about negative ties (or neutral or weak ties). For example, if two friends A and B dislike individual C, then also C's friends D and F will tend to dislike A and B. Individuals D and F then not only have a common friend C, but also two common foes A and B which will make them more likely to be friends with one another. Forces of attraction are thus not only dependent on forces of repulsion, but their dynamic interplay will lead to the emergence of coalitions with clear boundaries (A, B on one side; C, D, E on the other). Mixed-network reciprocity and popularity mechanisms will further contribute to a compartmentalization of negative and positive ties within different parts of the network. Fig. 2 illustrates two prototypical outcomes that we expect from the two models. The network on the left is an expected outcome of the attraction model. It consists of a big main component in which most individuals are indirectly connected. Colors indicate a potential structural identification of groups (e.g., using the approach by Newman, 2006). However, the boundaries between them are unclear and are likely to change through time. The network on the right is an expected outcome of the attraction and repulsion model. Group structures are clearly identifiable in the positive network (solid lines are positive ties) and are expected to be more stable through time, since the repulsive forces stabilize boundaries which in turn further increase group cohesion (dashed lines are negative ties).

Two propositions
We derive two network models from the discussion above. One model (the attraction model) is concerned with the dynamics of positive social network mechanisms and thus only considers forces of attraction 6 . The other model (the attraction and repulsion model) is concerned with the joint dynamics of positive and negative social network mechanisms and thus considers forces of attraction and repulsion. We derive two propositions from the discussion.

Proposition 1. Group emergence proposition: In comparison to the attraction model, the attraction and repulsion model generates structural groups with higher levels of group cohesion and clearer group boundaries.
Proposition 2. Group stability proposition: In comparison to the attraction model, the attraction and repulsion model generates structural groups that are more stable over time.

Data
We test the propositions about the two models in an empirical setting of 13 secondary-school classes in Hungary. Attraction mechanisms are modeled through friendship nominations; forces of repulsion are modeled through expressed dislike. Friendship and dislike nominations are measured on the same 5-point that ranged from dislike over neutral to friendship, hence there are no ambivalent nominations in the data. School classes are an ideal setting for dynamic social network studies as students spend most of their time within this context, they have well defined boundaries, and they are stable during secondary-school years. We utilize a unique network panel from the study titled "Wired into Each Other: Network Dynamics of Adolescents in the Light of Status Competition, School Performance, Exclusion and Integration" (Boda and Néray, 2015;Vörös and Snijders, 2017;Pál et al., 2016). The data contain four survey waves in the period of 2010-2013. We analyze only the first 3 waves as wave 4 had significantly higher non-response. The first wave took place approximately two months after students first met in school, the second wave followed half a year later, and a third approximately one year after the second. Hence, students were 9th-graders in the first and in the second wave, and 10th-graders in the third wave. Of the 44 classrooms in the sample, only 13 were used for the analysis; see Appendix A for details. Surveys were completed during regular classes in the presence of trained interviewers and took no more than 45 minutes. Students without parental consent were not included in the analysis, and those who were absent during the data collection were coded as missing. Students were assured that their answers would be kept confidential and used for research purposes only.

Descriptives
Our sample consists of 479 individuals of which 292 are females (61%). Across the three data collection waves we observe 7,879 friendship nominations and 3,056 dislike nominations. Table 2 shows the 13 empirically observed networks in the second wave. In each panel of the table we show the friendship network on the left in which automatically detected structural groups are highlighted 7 . On the right side of each panel we plot the positive and negative relationships together. It appears that the networks mostly have a clear group structure: the percentage of friendship ties within structural groups (identified through modularity maximization; Newman, 2006) ranges from 58% to 92%. It further seems that negative relationships tend to connect individuals who are in different groups of the friendship network (with the rather unstructured network 6 as a potential exception). The percentage of dislike relationships that connect individuals who were identified as being in different groups ranges from 63% to 97%. To compare those numbers to a meaningful reference category, we permute (rewire) the dislike nominations of all individuals to random others and count the number of cases where the percentage of between-group ties is higher than observed in 1000 simulations. By rewiring ties, we maintain the network density as well as the out-degree of each individual. The calculated percentage constitutes a non-parametric p-value. In ten of the 13 networks, the proportion of betweengroup dislike is higher than expected (86-94%) with p-values between 0 and 0.034. Exceptions are network 3 (89%; p = 0.17), network 6 (65%; p = 0.80) and network 12 (74%; p = 0.54) where we find no evidence for a higher proportion of between-group dislike than expected. These findings are static and descriptive but relate to Proposition 1 on the emergence of groups. Table 3 shows the 13 networks in wave 1 and 2. The right network in each panel (wave 2) corresponds to the respective classroom network in Table 2. On each network the same modularity-optimizing algorithm used earlier was run; structural groups are marked by highlighted areas. Node colors in both waves represent the structural groups of the nodes in the first-wave network. One can see that a high proportion of groups seem to be relatively stable through time as only few nodes "change" (for example, an orange node appears in the green group in wave 2 of network 1). Some group partitions seem very stable (e.g., networks 1 and 10), others somewhat less (networks 7 and 8). The proportion of pairs of individuals that are in the same structural group across the two waves ranges from 64% to 92%. These values are high given that the stability of the friendship network is relatively low: the proportion of Two hypothetical networks; one is a positive network (solid ties) generated from the attraction model, one is a multiplex positive and negative network (dashed ties) generated from the attraction and repulsion model. One can expect emerging groups with clear boundaries between them (indicated by the background colors) only in the latter case. Negative ties are expected to exist mostly between groups, positive ties are expected within groups.

Table 2
Empirical friendship (blue) and dislike (red) networks from the second of three data collection waves of the 13 classrooms. Structural groups in the friendship networks are highlighted. The left network in each panel shows the friendship relations, the network on the right also shows dislike. Isolated nodes in the friendship networks are not shown. 7 Groups were identified using an edge betweenness clustering algorithm that maximizes the modularity criterion on a symmetrized transformation of the friendship network (Newman, 2006). Within each dyad, the maximum of both ties was used for the symmetrization. Networks are visualized with the igraph software in R (Kolaczyk and Csárdi, 2014). C. Stadtfeld, et al. Social Networks 60 (2020) 129-145 ties that are present in both waves among ties that are present in either wave (the Jaccard coefficient) only ranges from 26% (network 12) to 55% (network 1) 8 . We assess the significance of the group stability ratios by applying a similar test as before in which we rewire the networks of wave 2 (keeping the outdegree of each node unchanged), then apply the modularity clustering algorithm and recalculate the proportion of node pairs that remain in the same group. We find that the percentages in the empirical networks are higher than expected under 1,000 random permutations in all classrooms, with the non-parametric p-values ranging from 0 to 0.053 (network 7). These findings are descriptive but they relate to Proposition 2 on the stability of groups. Gender matters in the formation of friendship ties within the sample (for a statistical test, see Pál et al., 2016). Between 65% (class 3) and 96% (class 1) of all friendship ties are between individuals of the same gender.

Evidence for micro-level network processes of attraction and repulsion -a SIENA model
We fit two multigroup stochastic actor-oriented models (SAOMS, Snijders, 2017) to the longitudinal network data described in section 3. Models are estimated with the RSiena software (Ripley et al., 2019) 9 . One model expresses positive social mechanisms of attraction (attraction model) and one model expresses the simultaneous operation of positive and negative social mechanisms (attraction and repulsion model). The two submodels of the second model (positive and negative network dynamics) are treated as interdependent processes. Model parameters are estimated with the method of moments (Snijders, 2017). It ensures that for each effect included the model (e.g., reciprocity), a simulation from the model will return a network in which the corresponding network-level statistic (e.g., the number of reciprocal ties) across all groups is expected to be equal to the empirically observed statistic in the subsequent wave. The models are specified by a number of effects that are representative of micro-level social mechanisms that involve two or a few individuals. They express, for example, whether individuals are more likely to dislike those who their friends dislike. Given the theoretical complexity of triadic social mechanisms that include both negative and positive ties, a set of new RSiena effects was developed for this article. These new effects relate to the specification of balanced triadic mechanisms in directed networks. Details are presented in Appendix C.
Results of the first model (attraction model) are shown in Table 4. Results of the second model (attraction and repulsion model) are presented in two tables: Table 5 includes the results of the submodel about positive network dynamics, Table 6 includes the results of the submodel about negative network dynamics. Both submodels include parameters that express how the two networks co-evolve.
The first 13 effects of the attraction and repulsion model in Table 5 are equivalent to the effects in the attraction model in Table 4. The estimated parameters of these effects are similar in both models (the reciprocity parameter, for example, is 1.97 and 1.86, respectively). We thus focus on the interpretation of the results of the attraction and repulsion model in Tables 5 and 6 in the following. In the interpretation of effects we follow the structure outlined in Table 1 and discuss in the following subsections reciprocal, triadic, degree-related, and genderrelated mechanisms separately. One additional parameter of the model are the "rates" that explain how often actors in the network consider changing their outgoing ties between two subsequently observed networks. The mean rates range from 8.9 friendship network changes per actor (attraction model) to 12.3 negative tie changes per actor (attraction and repulsion model) within an observed period. Another central parameter is the "density" that express that the number of ties that actors typically maintain is limited (e.g., due to cognitive or time constraints).
Dislike and friendship co-evolve. They are modeled as disjoint categories, in line with the questionnaire design in which those were assessed with a single scale. The SAOM is therefore specified similarly to an "ordered SAOM" (e.g., Elmer et al., 2017). An individual A can only establish a friendship nomination to B if A does not dislike B. The model assumes that individuals who want to switch a tie from friendship to dislike first have to dissolve the friendship tie.
All micro-level mechanisms that are included in the models are visually represented in Table 1 (core mechanisms) as well as in Table 9 in Appendix C (additional control mechanisms).

Dyadic network mechanisms
Effects 3 and 19 in Tables 5 and 6 provide evidence that individuals tend to reciprocate both positive and negative ties. Effects 14 and 29 further weakly indicate the tendency not to reciprocate positive or negative ties with a tie of the opposite valence (an opposite tie creation and maintenance is less likely). Those two effects are negative, but are Table 3 Empirical friendship networks in the first and the second wave in the 13 classrooms. In each panel, the network in wave 1 is plotted on the left and the network in wave 2 on the right. Structural groups in the friendship network are highlighted. The node color corresponds to the groups in wave 1. Isolated nodes in the friendship networks are not shown. not significant on an α = 0.05 level 10 . The negative sign of the effects, however, is not surprising and can be derived, for example, from a cognitive dissonance argument.

Triadic network mechanisms
We find evidence for transitive clustering in the friendship network (effects 4 and 5 in Table 5). We further find evidence for two out of three triadic mechanisms that include both positive and negative ties (effects 16, 31 and 32). These effects can be connected to a structural interpretation of Heider's balance theory (Heider, 1958;Cartwright and Harary, 1956;Hummon and Doreian, 2003;Rambaran et al., 2015). First, individuals tend to be friends with those that are in a conflicted relationship with someone whom they are also in a conflicted relationship with (effect 16 in Table 5). Second, individuals tend to dislike individuals who are in a conflicted relationship with one of their friends. This follows from the positive parameter 31 in Table 6. Third, effect 32 in Table 6 expresses whether individuals dislike (reciprocal) friends of others who they are in a conflicted relationship with. The effect is not significant on a α = 0.05 level, but has the expected sign (see endnote 10 on the treatment of non-significant effects).  The columns indicate the dependent variable (here: change in the positive network), the technical RSiena short name, a reference of the mechanism in the figures illustrating the model specifications, a visual representation of the mechanism, estimates, standard errors (standard deviations in case of the mean rates), and levels of confidence. + p < 0.1.

Table 5
Attraction and repulsion model ( The columns indicate the dependent variable (change in the positive or negative network), the technical RSiena short name, a reference of the mechanism in the figures illustrating the model specifications, a visual representation of the mechanism, estimates, standard errors (standard deviations in case of the mean rates), and levels of confidence. + p < 0.1.
*p < 0.05. ** p < 0.01. ***p < 0.001. The columns indicate the dependent variable (change in the positive or negative network), the technical RSiena short name, a reference of the mechanism in the figures illustrating the model specifications, a visual representation of the mechanism, estimates, standard errors (standard deviations in case of the mean rates), and levels of confidence + p < 0.1.
10 Non-significant effects capture potentially relevant information that can be exploited in a simulation study; we argue that their inclusion is preferred over dropping non-significant effects and thereby assuming a zero effect. We will later use non-significant estimates, like the negative mixed reciprocity effect, in the agent-based simulations.

Degree-related network mechanisms
Ten social mechanisms relate to the degree distributions in the positive and negative networks. Effects 6-10 in Table 5 and effects 20-24 in Table 6 capture degrees dynamics. Mechanisms 6 and 20 are of specific interest as they relate to preferential attachment in the positive and negative network as shown in Table 1. We find no evidence for indegree popularity or preferential attachment (Merton, 1968;Price, 1976) in the friendship network (the effect is positive but not significant). However, we find evidence for in-degree popularity in the dislike network - Pál et al. (2016) refer to this mechanism as to the "black sheep" effect. In the negative network we find a tendency towards outdegree dispersion with few individuals disliking many others (effect 22), whereas in the friendship network outdegrees seem to be more homogenous (effect 8).
Both networks show a strong tendency for a few individuals not to have any ties and thus not to participate in the friendship or disliking structure of the class (effect 9 and 23). In both networks we observe a tendency not to nominate those who call many others their friends (effect 7) or who dislike many (effect 21) which could indicate a hierarchical structuring of the two networks. In both networks it is unlikely that individuals who have an in-degree of zero (are not called a friend or disliked by anyone) subsequently attract friendship nominations (effect 10) or dislike (effect 24).
The mixed-degree effects 15 and 30 in Tables 5 and 6 relate to how degree effects operate across networks. We find evidence that individuals tend not to become friends with others who are disliked by many (effect 15), but not for the opposite mechanism that individuals tend not to dislike others with many friends (effect 30).

Similarity mechanisms
Three gender-related social mechanisms were included in each of the submodels; one relates to similarity and the other two to the differential activity (ego effect) and attractiveness (alter effect) of females as compared to males. We find gender homophily in the friendship network (effect 13 in Table 5) but also a tendency that individuals of the same gender are more likely to dislike one another (homophobia; effect 28 in Table 6). Alter effects indicate that female students (coded as 1, males as 0) are slightly less likely to be nominated as friends but more likely to be disliked (effects 11 and 12 in Tables 5 and 6). The strong homophily effect 13 in the attraction model indicates that group cohesion could partly be explained by similarity. Within the attraction and repulsion model, however, it seems unclear however how the gender attribute could contribute to the emergence of groups, given that we also find evidence for disliking others who have the same gender.

Exploring the micro-macro link
Through simulations, we now investigate whether the estimated SAOMs can explain the emergence and stability of structural groups (the propositions in section 2.3). To that end, we compare the empirical attraction model to the empirical attraction and repulsion model. We do not aim at explaining which model is better in terms of fit to the data, but to understand in how far the theoretical prediction holds that the attraction and repulsion model will generate outcomes with clearer group boundaries and a higher level of stability. The answer to this question is not self-evident, as the models are constructed from microlevel mechanisms that are mostly concerned with two (dyadic and similarity mechanisms) or three (triadic mechanisms) actors. Structural groups, however, typically consist of more than three nodes and are simultaneously characterized by group cohesion and group boundaries. We utilize the fact that SAOMs express actor-oriented micro-level processes 11 and that these processes can be straightforwardly simulated (as illustrated by Snijders and Steglich, 2015;Prell and Lo, 2016;Block et al., 2018;Stadtfeld, 2018;Stadtfeld et al., 2018). Simulations are carried out with the RSiena software (Ripley et al., 2019). Applying SAOMs as agent-based simulation models is related to a prominent literature strand about agent-based models (ABMs) in sociology (e.g. Macy and Willer, 2002;Gilbert, 2008;Macy and Flache, 2009;Bianchi and Squazzoni, 2015).
From each of the two models (attraction model, attraction and repulsion model), we simulate 100 long chains of evolving networks with a maximum rate of 1000 (about 100 times the empirically estimated rate 12 ). The simulations start from an empty network with 36 nodes (the average size of the empirically observed networks). The same analyses were conducted on networks with 200 nodes which essentially returned the same results. Networks can be drawn from the simulation chain at any point in time.
We show nine exemplary simulation chains of the attraction model (Table 7) and nine exemplary simulation chains of the attraction and repulsion model (Table 8). Each simulation is illustrated in one row of the tables. Networks are drawn from the simulation chain after a rate of 10, 50, 100, 500, and 1000 (the columns of the tables). A rate of 10, for Table 7 The first 9 network simulations of friendship networks from the attraction model in Table 4. Snapshots are plotted after simulations with rates 10 (close to the empirical rate), 50, 100, 250, 500, and 1000. Clusters with at least two nodes are highlighted by background and node colors.
11 SAOMs model network change as a result of individuals making choices about their set of outgoing ties. 12 The mean estimates of the rates are 8.9, 10.9 (friendship) and 12.3 (dislike) and are shown as effect 1 in Table 4 (attraction model) and effects 1 and 17 in Table 5 and 6 (attraction and repulsion model). For more details about the rate parameters in estimation and simulation with SAOMs, see Ripley et al. (2019).
example, indicates that in the simulation each actor reconsiders her set of outgoing ties on average 10 times, starting from an empty network. The larger the rates, the less meaningful is an interpretation of rates in terms of actors' opportunities to reconsider their set of ties-large rates of, for example, 500 are best interpreted as approaching a stochastic equilibrium of the actor-oriented network change process. In a stochastic equilibrium, the macro-level features of the process are relatively stable while change still occurs on the micro-level 13 . The rates were chosen so that different phases of the simulation process (as discussed below) are represented in the visualizations. To visually capture the formation of group structure, only the friendship networks are plotted in the two tables even though in the attraction and repulsion model in Table 8, a co-evolving dislike network was part of the simulation. The visual representations are in line with the micro-macro link that we established in the theoretical model. In the attraction model in Table 7, we cannot see that groups emerge within the simulated time span. Groups tend to be overlapping without clear boundaries between them. It is noteworthy that this is the fact even though the gender homophily mechanism could generate group structures in principle. In the attraction and repulsion model in Table 8, in contrast, we can see that with rates of 250 or more group-like structures emerge that have a high cohesion within and no or few connections between them. Isolated nodes are, however, more frequent in the attraction and repulsion model. The reason for this phenomenon is that social mechanisms that explain the formation of group boundaries (e.g., agreement on disliked individuals) can also explain emergence of isolated nodes in a network. Over time, attraction forces within groups tend to become so strong that the within-group friendship networks get close to complete subnetworks in some cases. This observation is related to model degeneracy discussed in the networks statistics literature (e.g., Snijders, 2002).
Systematic comparisons of features of 100 simulated network chains per model are presented in Figs. 3-5. Here, we aggregate descriptive results from the network chains throughout the simulation process. In contrast to the visual inspection above, we now simulate from four empirical observed networks of the first data collection wave and compare the resulting statistics to those of the networks in the second wave (indicated by horizontal lines). As empirical starting points, we chose the wave 1 networks from the first four panels of Table 3 Tables 7 and 8 . Fig. 3 relates to proposition 1 (group emergence proposition) and shows the percentage of ties within structural groups (clusters). The three columns present the statistic up to a simulated rate of 10 (roughly the empirical rate, see Tables 4-6), 100, and 1000. Within a rate of 10, the simulations develop similarly in terms of within-group ties. Within a period of 100, however, they start developing different patterns. In three out of four cases, the clustering generated by the attraction and repulsion model increases and eventually transitions to a stochastic equilibrium in which almost all ties are within clusters. From the visual inspection, we could conclude that in the long run the attraction and repulsion model tends to generate networks with completely separated components. In one out of four cases (where the empirical rate of within-group ties is low), the two models keep behaving similarly with respect to the first statistic. Fig. 4 relates to proposition 2 (group stability proposition) and shows the percentage of within-group ties that are stable in a forward simulation after a rate of 10. The left column includes forward simulations up to a rate of 50. The group stability is evaluated for the networks simulated after a rate of 10. Both models behave similarly at the beginning. After a forward simulation of about 50 (column 2) the stability of the attraction and repulsion model increases in comparison to the attraction model in three out of four cases. In the long run, the structural groups generated by the attraction and repulsion model are extremely stable. Fig. 5 presents three additional statistics: the percentage of homophilous ties, the number of detected groups (ignoring isolates), and the density of the friendship network. Again, the simulations from the first three empirical networks behave similarly. First, it can be seen that the clustering of the attraction and repulsion model is explained less by the gender attribute and that the percentage of homophilous ties is thus generally lower. Second, the number of clusters in the attraction model Table 8 The first 9 network simulations of friendship networks from the attraction and repulsion model in Tables 5 and 6 . Snapshots of the friendship ties are plotted after simulations with rates 10 (close to the empirical rate), 50, 100, 250, 500, and 1000. Dislike ties are omitted from the plot, but not from the simulation model. Clusters with at least two nodes are highlighted by background and node colors.
is typically higher at a value of 5-7 in comparison to 2-4 clusters in the attraction and repulsion model. Third, the density of attraction and repulsion model is higher in the long run (25-30%) as the density within clusters increases to values close to 1. The fourth empirical case is again different. It can be seen that in case of the attraction model typically only one structural group emerges in the long run and that the network density increases. It seems that in this case both models suffer from (local) model degeneracy where extreme stochastic states are reached with very high or low densities. The probability of transitions between these regimes is supposedly very low.

Reflection on applying stochastic actor-oriented models as ABMs
This section reflects on a perceived gap between the literature on ABMs and empirical network modeling that researchers may come across when aiming at speaking to the two communities simultaneously. Overall, we believe that the integration of the two approaches is quite natural and promising. Bianchi and Squazzoni (2015, p.284), for example, define ABMs as "computer simulations of social interaction between heterogeneous agents [...], embedded in social structures [...] [that] are built to observe and analyze the emergence of aggregate outcomes." Macy and Willer (2002, p. 146) define ABMs as simulation models of agents that are autonomous and interdependent, that follow simple rules, are adaptive and backwardlooking. Gilbert (2008, p.2) defines agent-based modeling as a "computational method that enables a researcher to create, analyze, and experiment with models composed of agents that interact within an environment." The purpose of our simulations is indeed the observation and analysis of an emergent aggregate outcome (structural groups). Individuals within the SAOM take autonomous but interdependent decisions on the creation of ties  Table 3) that the simulations started from. The gray horizontal bar indicates the statistic in the empirical case.
(positive and negative) which changes their position and decision opportunities in the network. This interdependence is observed when, for example, a reciprocal tie is generated as a sequence of two tie creations. The newly created reciprocal tie may then create opportunities for further subsequent network changes (e.g., reciprocity → popularity → transitivity) that alter the positions of the individuals in the network, for example, their level of embeddedness. These interdependent tie creations can be understood as a form of interaction. The changing positions of actors as well as their differences in terms of exogenous attributes (gender in our empirical example) induce heterogeneity in this process.
The ABM that we propose in this paper is certainly not prototypical for the ABM literature within sociology. Other than in many ABM studies, for example, we do not explore / experiment with a space of parameters, but limit the parameters to the SAOM parameters estimated from empirical data. Thereby, we are closer to an empirically calibrated ABM as discussed by Boero and Squazzoni (2005), Manzo (2007) and Hedström and Åberg (2005). A parameter exploration only happens in terms of the comparison of two models and by varying a time parameter that governs the length of the simulation process. Our model is more complex than many prototypical ABMs (some famous examples are discussed in Bianchi and Squazzoni, 2015). The attraction and repulsion model, for example, has 32 parameters that aim at taking into account the multi-mechanistic nature of social network dynamics (as discussed in Stadtfeld, 2018). Other differences to classical ABM studies are rooted in assumptions of the SAOM framework. SAOMs do not easily allow the expression of strategic or forward-looking behavior which could be an interesting issue to explore in the context of group emergence. Adaptation of behavior is not taken into account in our simulations, but only occurs due to changes in network position (e.g., after the emergence of groups, in-group preferences are more pronounced).  Table 3) that the simulations started from. The gray horizontal bar indicates the statistic in the empirical case.
Many ABM studies are further inspired by game-theoretic interactions, which are also different from the SAOM approach.
An important concern in ABMs is empirical calibration. The SAOM is empirically calibrated by means of the parameter estimation: the method of moments estimation ensures that the fit of each included statistic (e.g., reciprocity) is correct in the empirical context and given the estimated parameters. However, once parameters change (the rate is varied in our case) or the empirical context is altered (simulations start from empty networks in our case) this calibration does not hold anymore and it is possible that networks are generated that are different from the empirically observed networks. Indeed, we see that the longrun outcomes of the simulated models are too stylized to be meaningfully compared to empirical data. Yet, we know that the complex set of model parameters are valid in at least one specific empirical context.
We believe that exploring macro-level outcomes based on empirically-calibrated ABMs is a promising research direction (Hedström, 2005). In particular, this is the case because many agentbased models are implicitly or explicitly concerned with group formation and the consequences of in-group and out-group ties on interaction between agents (e.g., cooperation, trust, punishment, see the review of Bianchi and Squazzoni, 2015). Theoretical arguments in this context are concerned with in-group favoritism and negative out-group ties (e.g., Sakoda, 1971;Hammond and Axelrod, 2006). The underlying behavioral model of SAOMs and its ability to be simulated indeed has strong similarities to ABM models 14 . Snijders and Steglich (2015) proposed first that SAOMs can be applied for this purpose. Stadtfeld  Table 3) that the simulations started from. The gray horizontal bar indicates the statistic in the empirical case.
14 Empirical SAOM studies have in fact referred to "stochastic agent-based models" to highlight this similarity (e.g. Lomi et al., 2011) C. Stadtfeld, et al. Social Networks 60 (2020) 129-145 (2018) discusses how some of the assumptions of SAOMs can be remedied in future research to bring statistical network modeling and ABM closer together. A similar call for the integration of ABMs and statistical (network) models is made by Flache et al. (2017).

Discussion and conclusions
The social lives of humans are organized in small informal groups. These groups are observable in various contexts from schools to digital communities. They are typically characterized by high internal cohesion, observable in tightly knit networks of positive relations, like friendships, connecting group members. The boundaries between groups are in contrast characterized by weaker ties, neutral ties, and sometimes negative ties.
In this paper, we argued that forces of attraction that explain the formation of positive ties within groups of individuals are necessary to express group cohesion, but that they cannot fully explain how stable groups emerge within a larger social context. The reason is that they lack a way of expressing the formation of group boundaries. Those could be expressed by also considering forces of repulsion, that explain the lack of positive ties formation between groups. Based on this intuition, we developed a theoretical framework of group formation in social networks. It builds upon a combination of micro-level social network theories about the evolution of positive and negative relations, and thereby illustrates how forces of attraction and repulsion could jointly explain the emergence and stability of social groups.
We tested the propositions of the theoretical model with a novel combination of dynamic empirical social network analysis and agentbased modeling. As a starting point, we chose an empirical setting of coevolving networks of friendship and dislike among 479 secondary school students. Descriptively, the networks that they form exhibit group structures, where dislike relations indeed mostly connect individuals in different groups. In a statistical analysis with a newly extended version of stochastic actor-oriented models (SAOMs), we then found evidence for a number of micro-level mechanisms that shape the dynamics of the analyzed networks. Friendship networks, for example, tended to exhibit reciprocity, transitive clustering, gender homophily, and popularity. In the evolution of the dislike networks, we found evidence for reciprocity, disliking of isolated individuals, same gender dislike, and the black sheep effect. The co-evolution of the two networks was characterized by the alignment of friends' dislike towards other students, and an increased likelihood of individuals to be friends when they dislike the same others.
We then explored how the micro-level mechanisms of two SAOMs (one only modeling forces of attraction, the other forces of attraction and repulsion) were able to generate the emergence and stability of group structures on the macro level. We did so by conducting computer simulations, treating the empirically estimated SAOMs as empirically calibrated agent-based models (ABMs). We could show that in line with our theoretical model, only the model that combined forces of repulsion and forces of attraction generated stable structural groups. In the long run, however, the group features of the simulated networks were too stylized with extremely high densities within groups and a large proportion of isolated nodes. These observations call for further theoretical and statistical work, investigating homogeneity of the micro-level processes contributing to group formation and possible problems of model degeneracy. Comparing the two models, it is noteworthy that even though the attraction model included a relatively strong homophily effect, the generated groups were generally less pronounced and less stable through time.
The current study has general implications for future research on emergent social structures. We presented an extension of the still dominant social network approach, which relies on the analysis of a single relational dimension, by considering the co-evolution of multiplex networks, one positive and one negative. The most straightforward extension by one additional network dimension (negative relations) helped to better explain the emergence and stability of groups on the macro level. The existence of explicit dislike or conflict ties between groups, however, is not a strict necessity for the proposed explanation of group formation. Indeed, one can observe stable groups which are not in direct conflict with one another. In these cases, forces of repulsion can still be present and promote the formation of non-negative, neutral, or weak relationships between groups (rather than stronger ties that tend to be observed within). For example, group norms and identities may exist that simply prohibit group members from interacting and developing positive ties with the outgroup. We encourage future research to test the analytical strategy in different empirical contexts and thereby aim at generalizing the social network theory of group formation that we proposed. Future research could aim at defining more parsimonious variations of the proposed attraction and repulsion model, and evaluate the relative importance of the micro-level mechanisms. Another important extension of this model would be to multidimensional group processes where we do not assume that each individual is the member of one or zero groups. Individuals are in fact often members of multiple groups and these can partly be overlapping. This has not been considered in our "single-dimensional" definition of structural groups.
The presented multiplex network approach may further be used to explain other complex macro-level phenomena. For example, the emergence of social roles within groups or a larger community may be described as the co-evolution of positive ties and perceptions about role-taking behavior (consider the black sheep and popularity effects in our study). Similarly, internal structures of groups such as hierarchies, and their occasional instability and dissolution, may be understood through micro-processes of status competition as expressed by coevolving positive, negative, and status perception networks. Such efforts may help establish the relation between micro-level processes and the emergence and stability of complex macro-level phenomena in social networks.
Recently, the discussion of group cohesion, group boundaries, and dislike between groups has gained momentum in the context of a perceived increase in polarization in political and societal debates. Particularly, in the context of digital societies there is anecdotal evidence for forces of between-group repulsion that go hand in hand with an increase in within-group cohesion. In the context of digital communities, a lack of interconnectedness between groups may result in "filter bubbles" in terms of information exchange, and in the long run in societally relevant and undesirable outcomes such as segregation, polarization and expressions of hate (e.g., Clemm von Hohenberg et al., 2017). In such circumstances, systematic efforts into explaining the emergence of macro-level structures in human communities are timely. Our theoretical model proposes to consider both forces of attraction and forces of repulsion when trying to understand the dynamics of group emergence and group stability. B, or they mutually dislike each other. Consider, for example, the mechanism in Fig. 8d. It expresses the tendency of individual A to dislike individual B when A's friend C is in conflict with B. The new effect considers the three cases of i) B disliking C, ii) C disliking B, and iii) mutual dislike between B and C. These cases might be substantially distinct but they all can be argued to relate to individuals' need to be embedded in cognitively balanced, triadic structures. The new effects are straightforward to interpret and and increase the statistical power of the model as less parameters need to be included .
Technically, the extension was achieved by modifying the RSiena software with a new C++ iterator for cases of dyads in which either of two ties exists. A similar iterator was added for reciprocal connections. The effect in Fig. 8d, for example, includes such a reciprocal connection. The new iterators are readily available for the development of new effects.   C. Stadtfeld, et al. Social Networks 60 (2020) 129-145