Integrating sentiment and social structure to determine preference alignments: The Irish Marriage Referendum

01/01/2017 ∙ by David J. P. O'Sullivan, et al. ∙ 0

We examine the relationship between social structure and sentiment through the analysis of a large collection of tweets about the Irish Marriage Referendum of 2015. We obtain the sentiment of every tweet with the hashtags #marref and #marriageref that was posted in the days leading to the referendum, and construct networks to aggregate sentiment and use it to study the interactions among users. Our results show that the sentiment of mention tweets posted by users is correlated with the sentiment of received mentions, and there are significantly more connections between users with similar sentiment scores than among users with opposite scores in the mention and follower networks. We combine the community structure of the two networks with the activity level of the users and sentiment scores to find groups of users who support voting `yes' or `no' in the referendum. There were numerous conversations between users on opposing sides of the debate in the absence of follower connections, which suggests that there were efforts by some users to establish dialogue and debate across ideological divisions. Our analysis shows that social structure can be integrated successfully with sentiment to analyse and understand the disposition of social media users. These results have potential applications in the integration of data and meta-data to study opinion dynamics, public opinion modelling, and polling.



There are no comments yet.


page 3

page 10

This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

1 Introduction

The Republic of Ireland held a referendum to legalise same-sex marriage on the of May . This referendum saw a high turnout (60.52% of voters), and the final result was a 62% majority in favour of the legalisation of same-sex marriage. Such high turnout represented a dramatic increase compared to previous referenda [30]. The enthusiasm of the electorate was reflected in the activity of on-line social media platforms, particularly on Twitter which saw a wealth of activity in the days preceding the referendum [33]. Twitter is an online micro-blogging platform where users can post short messages or tweets

that can be up to 140 characters long; in Ireland, an estimated

% of adults have a Twitter account, of which use the service every day [15]. Users can subscribe to other users’ tweets (or follow); such following relationships are often asymmetric, if one user follows another, a reciprocated following relationship does not always exist [21]. In addition to following each other, there are other ways in which users can publicly interact such as re-tweeting (passing forward another user’s tweet), and mentioning each other in tweets. Twitter has been a popular venue for the dissemination of information, memes, opinions, and has facilitated public debate about a variety of subjects [18, 4, 5, 2, 35, 25, 21]. As a result, Twitter has received considerable attention from researchers who wish to gain insights into the relationships and mechanisms that govern these social interactions [11].

The use of sentiment analysis to infer the disposition of individuals or groups towards specific topics is a growing area of interest in computational social science 

[26, 23, 32, 11, 14, 7]. For example, sentiment analysis on Twitter data has been used to study stock market fluctuations [8, 38], film box-office performance [3] and reviews [36], tracking the spread of influenza [22], and (albeit controversially) predicting elections [35, 29, 24, 6, 37]. Although some of these studies have well-noted shortcomings [16, 17], the idea of using the content of tweets to gain insight into social phenomena remains a promising and compelling one. Recent studies, using carefully constructed methodologies, have successfully leveraged sentiment to uncover insights into its effect on the spreading of cascades on Twitter [2], and how top broadcasters send messages with positive sentiment more often than negative [10].

In this work we combine analyses of sentiment and social structure to explore Twitter conversations about the Irish marriage referendum. In particular, we address the following questions:

  • How did users interact with each other on Twitter in the context of the Irish Marriage Referendum?

  • Can user interactions and the sentiment of their tweets help us find supporters of voting yes (in favour of the legalisation of same-sex marriage) and no (against it)?

To answer these questions, we analyse an extensive dataset of tweets about the referendum, and the interactions among the users who posted the tweets (Sec. 2). We extract a sentiment score for each tweet (Sec. 3), and incorporate it into the structure of the mention and follower networks of users (Sec. 4). These networks enable the analysis of how the sentiment of users is correlated, and the proclivity of users with positive/negative sentiment to cluster together (Sec. 5). We use community detection to partition the users in the mention and follower networks into groups who communicate more or are generally more interested in each other’s content. We examine these communities from the vantage point of sentiment analysis to find a parsimonious three-group partition of the users (Sec. 6). These three groups are broadly composed of yes and no supporters with varying levels of activity, and starkly different patterns of interaction with each other (Sec. 7). Finally, in Sec. 8 we discuss our results and explore potential future research directions.

2 Data

Figure 1: (a) Number of tweets containing the tracked hashtags (solid red line) and number of unique users (dashed blue line) in

minute bins. The volume of tweets increases over time with the notable spikes for the two televised debates and the referendum day. (b) Complementary Cumulative Distribution Function (CCDF) for number of tweets per user on a log-log scale (Inset: the Probability Distribution Function (PDF) of the same data).

The dataset we use in this work consists of every tweet containing the hashtags #marref and #marriageref from May 8 to May 23 (one day after the referendum). In total we collected 499,642 tweets posted by 144,007 unique users (see Fig. 1(a)). A total of 204,626 tweets were posted before the referendum day; 88,320 on the day; and 206,696 after. The peaks observed in Fig. 1(a) coincide with the first and second televised debates (held on May and May ) and the referendum day (May ), the tallying and announcement of the results, and subsequent global reaction. Figure 1(b) shows that the number of tweets per user has a heavy tailed distribution. The vast majority of users only posted a small number of tweets with the tracked hashtags, while a small number of users are responsible for a large volume of tweets. Of the total number of tweets, 135,370 () were original, 24,397 () were replies and 339,875 () were retweets. Broadly speaking, original tweets are messages that are not in response to another previously posted tweet (i.e., the content is ‘new’), replies are tweets that are posted in response to an existing original tweet, and retweets are tweets written by others that a user passes along to his/her followers. In addition users can mention each other in their tweets by inserting a user’s screen name (technically, replies and retweets can be seen as specific types of mention tweets). In our data there are 388,161 mention tweets ( of all tweets), of which 25,732 are original, 23,131 are replies, and 339,298 are retweets. In addition to tweets, we also obtained the follower relationships of all users who tweeted one of the hashtags in our data (i.e., a list of everyone who is followed by the authors of the tweets in our data, regardless of whether they used the tracked hashtags). These correspond to 117,669,550 follower links. We also collected user information such as self-defined location, self-description and how long the user has been a member of Twitter.

All data was collected by Sinnia using Twitter Gnip Power-Track API111 which returns a complete dataset, not just a sample [19]. Using the Twitter stream API has the limitation that as the popularity of a search term (e.g., a hashtag) increases, the representativeness of the sample decreases [27]. By extracting all tweets with the two hashtags, and all user following relationships we are able to circumvent such sampling issues. There could be, however, other issues with the data. For example, it is possible that our data gathering could miss important tweets or individuals if they never tweeted using one of the tracked hashtags. However, due to the ubiquity of the hashtags #marref and #marriageref in the weeks leading up to the referendum we are confident that our data is an adequate representation of the Twitter discourse about the topic.

3 Sentiment of tweets

To quantify how positive or negative a tweet is, we need to compute the tweet’s sentiment score. We do not consider sentiment with the categorical positive or negative labels; instead we consider sentiment to be a number whose magnitude denotes how positive or negative the language expressed is [31]. For this task we use the open source sentiment algorithm SentiStrength

, a lexicon-based sentiment algorithm that searches for words that have an associated positive or negative score 

[34]. SentiStrength provides a score of both the positive and the negative emotional charge of a string of text (in this case, of each tweet in our data). Positive scores range from to , and negative scores from to . A score of (or ) indicates that the tweet has no positive (or negative sentiment), while a score of (or ) means that the tweet has the most positive (negative) score possible. See Appendix A for more details on how sentiment scores are obtained with SentiStrength.

Figure 2: (a) Density plot of the two-dimensional sentiment scores of all tweets. (b) Histogram of the difference between the positive and negative score of each tweet.

Figure 2(a) shows the two dimensional distribution of sentiment scores of all the tweets in our dataset. To simplify calculations we compute the difference between the positive and negative scores of each tweet to obtain a one dimensional score between and . A negative score indicates that the tweet contains stronger negative language than positive, and vice versa for positive scores. Figure 2(b) shows the distribution of the unidimensional sentiment scores of all tweets in the dataset. About half of all tweets () have a score of zero; of these the vast majority () have a score of and

for positive and negative language, respectively (i.e., no detected sentiment), and the rest have balanced positive and negative sentiment scores. The distribution is roughly symmetric about zero with a slight positive skew; this observation is consistent with previous reports of sentiment bias in language 

[14] and tweets [10]. As noted in the Appendix A, the SentiStrength scores of a single tweet can be unreliable, so a single tweet does not provide definitive information about the user’s sentiment. To obtain a more robust indication of users’ sentiment, we can aggregate the scores of all the tweets produced by one user to obtain a single score. Although aggregate scores can help overcome some issues, computing a single score per author neglects the fact that Twitter users often interact with multiple people, and that the sentiment of these interactions may vary substantially depending on the counterpart and the nature of the exchange. Therefore using exclusively a single score per user can lead to information loss, and provide a misleading indication about the user’s sentiment. To avoid these problems it is necessary to incorporate the users’ interactions into our analysis.

4 Sentiment aggregation and social structure

Although SentiStrength has been reported to preform well on Twitter datasets [34], the nuances and complexities of human language (for example sarcasm, idioms, negation, double negatives, and a cavalier attitude towards grammar) make the process of automatically extracting sentiment a challenging task. In addition, Twitter users do not exist in isolation, they interact with each other through mentions, replies and friend/follower relationships. For this reason it is necessary to incorporate social structure to obtain a more robust description of the user’s disposition with regards to the marriage referendum. We focus our analysis on two types of Twitter networks:

  1. Reciprocal mention network: In this network connections exist between users who have mentioned each other in tweets containing the tracked hashtags.

  2. Reciprocal follower network: Connections exist between users who follow each other on Twitter.

The information contained in these networks reflects complementary aspects of the interactions between users: the reciprocated mention network includes interactions that arise specifically from conversations about the Irish marriage referendum, and are constrained to the observation period ( to of May). We are interested in studying reciprocal mentions because they are a sign of genuine interactions between users [10, 20]. In contrast, the follower network is not constrained to discussions about the marriage referendum, nor to the observation period; this network provides a broader view of how users are interested in each other. Table 1 provides a summary of statistics for both networks.

4.1 Construction of the networks

We construct the directed mention network by searching each users’ tweets for mentions of other users (indicated by a prefixed ‘@’). A mention often indicates that the author wishes to draw the attention of another user to the content of the tweet; this could be original content directed at a user, a retweet, or a reply. The announcement of the referendum results received widespread international attention, which translated into a large number of tweets from users outside of Ireland (see Fig.1(a)). We are specifically interested in detecting yes and no supporters, which is why we further refine our networks to only include tweets generated before the day of the referendum. Each mention creates a directed connection from the author of the tweet to the user who has been mentioned. We can incorporate sentiment into this network by setting the weight of the connection to be the sentiment score of the tweet. When there are multiple directed mentions, we average their sentiment scores. The resulting network is directed, weighted and signed (negative weights indicate when the mentions have a predominantly negative sentiment); it contains unique users, and directed connections. Note that the users who appear in this network may not have used one of the tracked hashtags, they only need to have been mentioned in a tweet containing one of the hashtags. The average combined in and out degree is , with a transitivity coefficient of . The reciprocal mentions network is the subnetwork in which connected individuals have mentioned each other in their tweets. This network has edges ( of the mentions in the full network), and users with non-zero in- and out-degree.

To construct the follower network we obtain the following relationships between users who authored the tweets in our dataset. This network has users with connections, of which () are reciprocal. The average combined in- and out-degree is and the transitivity coefficient is . The full follower network has a different size to the full mention network because the latter networks starting point was the users who have authored at least one of the tweets in our database. Of the users in the reciprocal mention network are in the largest connected component, of these users users are in the largest connected component of the follower network. The final mention and follower networks contain the users in this node set with and connections, respectively. Table 1 contains the summary statistics for the networks.

Mention Follower
Full Reciprocal Full Reciprocal
Nodes 40,812 2,047 36,674 2,047
Links 227,203 69,022 3,309,687 173,137
Reciprocal links 23,713 22,218 1,398,236 85,986
Avg. out degree 9 34 90 85
Transitivity 0.02 0.13 0.09 0.28
Table 1: Summary statistics for the mention and follower networks.

To incorporate the sentiment of tweets with the social structure of the networks described above, we compute four user attributes: the average in- and out-sentiment ( and ) of each user in the mentions network, as well as the average in- and out-sentiment of each user’s neighbours ( and ). These quantities allow us to aggregate sentiment scores whilst preserving the heterogeneity of the user’s interactions (e.g., supportive or adversarial discussions).

Figure 3 shows that users tend to have approximately the same average in- and out-sentiment. The average out-neighbour sentiment is marginally higher than the average in-neighbour sentiment ( and , respectively). The average sentiment scores are centred about zero with a distribution that is approximately symmetric.

Figure 3: Distribution of the average of users’ (a) in-sentiment, (b) out-sentiment, (c) neighbour’s in-sentiment, and (d) neighbour’s out-sentiment.

5 User sentiment alignment

As discussed in Sec. 3 (and Appendix A

) the sentiment score of a single tweet is not itself is not entirely reliable; however, the scores of a large number of tweets can provide a more robust indication of the sentiment of the corpus. We test this intuition against the null hypothesis that the sentiment is generated by an inherently random process. For example, if the content of the tweets is completely unrelated to sentiment, or if the sentiment extraction process gives noisy scores that do not contain any information about the actual sentiment of the tweets.

More precisely, we would like to determine 1) whether user in- and out-sentiment scores are correlated; and 2) if users whose tweets have similar sentiment tend to be clustered in the network. If the sentiment of the mention tweets that a user sends and receives is correlated, and users tend to cluster together with others with similar sentiment, we could then consider sentiment alignment as a proxy for homophily among users. We can reasonably expect this because users with a similar disposition towards the referendum may communicate using similar language. For instance, yes campaigners may use phrases that are more positively charged (e.g., “vote yes”) more often in their tweets, which results in a higher positive user sentiment (and vice versa for no campaigners).

To answer 1), we examine whether there is a correlation between a user’s in- and out-sentiment. The Pearson correlation between and is , which indicates a moderate linear relationship between these two nodal attributes [28]. To confirm that this correlation is not due to chance alone, we use a procedure based on redistributing the sentiment of a user’s tweets. The randomisation procedure is:

  • Sample a sentiment score for each connection from the observed distribution of link scores with replacement. This keeps the network topology intact.

  • Calculate the average randomised in- and out-sentiment of each user ( and ).

  • Calculate the correlation coefficient between and in the resampled network.

Figure 4 shows the comparison of the resulting distribution of the correlation between ( and ) after 1,000 iterations of the procedure with the observed correlation of and in our data. This result indicates that there is a nontrivial correlation between the sentiment of what a user tweets and receives.

Figure 4: Distribution of the correlation between and after 1,000 randomisations (blue bars), and the observed correlation between and in the data (red dashed line).

To answer 2) we investigate whether users with similar sentiment are clustered together in the mention and follower networks. The observed correlation between and suggests that users may be more likely to be connected to other users with similar sentiment scores. We create three coarse class labels for users according to their sentiment — aggregate scores above zero are “positive”, scores less than zero are “negative” and scores equal to zero are “unknown” — and we find the fraction of links connecting users of these broad sentiment labels. We denote the fraction of links between positive and positive users as , the fraction of links between positive and negative users as , between positive and unknown users as , and so on. In total there are six types of links: , , , , and . We randomise the class labels of each user by sampling from the observed distributions with replacement, and recalculate the fraction of connections; we repeat this process times. As before, we compare the randomised distributions of the fractions with the observed fraction in our data; Figure 5(a) shows the results for this procedure.

The randomisation test in the mention network (blue box plots in Fig. 5) shows that it is highly unlikely that the , , , and observed in the mention network arise from chance. There are fewer connections involving unknown users ( and and ) than we would expect by chance. In contrast, the connections between positive users () and negative users () are higher than expected. The faction of connections between positive and negative users () is less than what we would expect (below the quantile), although this result is less robust than the rest. This analysis shows that users tend to mention in their tweets other users with similar sentiment more frequently than we would expect by chance. The same analysis in the follower network (yellow box plots in Fig. 5) paints a broadly consistent picture. We find more links between positive users, fewer links between positive and negative, and fewer links involving unknown users than we would expect by random chance.

Figure 5: Result of the randomisation tests in the the mention (blue box plots) network and the follower network (yellow box plots). The green squares and red triangles mark the observed fraction of links in the data. Green squares indicate that the observed fraction of connections falls outside the lower and upper quantiles of the randomised distribution (i.e., it is unlikely to arise by chance alone); red squares indicate that the observed fraction falls inside the lower and upper quantiles of the randomised distribution.

This analysis provides evidence of a relationship between users’ and , and their preference to engage with users of a similar sentiment, and supports the notion that in this case sentiment can be a proxy for homophily. Labelling users as positive, negative or unknown, according to the sign of their may seem too coarse; to test this we performed a similar analysis in which we split the users according to their quantile, or by above/below the mean or median (see Appendix C). These tests produced the same results we present in this section.

6 Communities and sentiment

We are interested in finding groups of users that are not only tightly connected in both networks, but also whose tweets have similar sentiment. For this task, we extract the communities in each network, and enrich it with the analysis of connection patterns from the previous section. We use Markov Stability [13, 12] to obtain a robust partition of the mentions network into communities, and a partition of the follower network into communities (Fig. 6(a) and (b)).

The communities in the mention network arise specifically around conversations between users; the links consist of mention tweets containing the tracked hashtags posted during the observation period. In contrast, the communities in the follower network arise from the declared interest of a user in receiving another users’ posts, which is not necessarily restricted to the context of the marriage referendum. In essence, we now seek to find a new grouping of users based on both partitions, and use the sentiment scores to construct a measure of similarity.

To accomplish this task, we intersect the partitions of the two networks to obtain sub-communities (Fig. 6(c)). Each of these new groups contains users that are in the same community in both networks; these users are not only more broadly interested in each other (because they follow each other), but also had conversations about the referendum. Then, we calculate the average in- and out-sentiment and neighbour sentiment , , and in each sub-community . As we noted in the previous section, we consider sentiment as a proxy for homophily between users; therefore we use aggregate sentiment scores as an indication of similarity between the sub-communities. However, of these sub-communities have users or fewer ( users in total). Because sentiment scores of individual tweets are a noisy signal and these communities are small, we are unable to provide a robust statistical description in these communities. To limit the effect of this noise we remove these sub-communities and proceed to analyse the remaining sub-communities. This procedure is illustrated in Fig. 6.

Figure 6: Schematic of our analysis of communities and sentiment. Communities in the mention network (a) and follower (b) networks. The intersection of the communities in both networks is shown in (c). Mention network with nodes coloured according to sentiment (d). The -means clustering of the sub-communities according to their sentiment reveals three broad clusters (e). The relationship between in- and out-sentiment of each sub-community and cluster membership is shown in (f). The size of each marker is proportional to the size of each sub community; crosses indicate the centroid of each cluster. Final partition of users into three “community clusters” in the mention network.

We use -means clustering to group the sub-communities according to the euclidean distance between the average in- and out-sentiment and neighbour sentiment scores of each sub-community. To choose the number of clusters we locate the bend in the plot of the total within sum of squares of the sentiment difference of the members of the groups (Fig. 6(e)). A marked flattening of the graph suggests that a finer clustering is not considerably better at segregating sub-communities into distinct groups than a more parsimonious clustering with fewer groups. The appropriate number of clusters is found at the “elbow” of the graph [1], which in this case is three. Figure 6

(f) shows the three regions in which we have classified the sub-communities. We call these clusters of sub-communities

community clusters: with users, with , and with . The community cluster has the highest in- and out-sentiment, followed by and lastly .

Mention Follower Mention Follower Mention Follower
Users 1,064 604 155
Links 32,076 85,302 22,333 45,799 8,119 6,409
Reciprocal links 12,855 44,890 5,527 22,171 2,582 3,163
Avg. out degree 30 80 37 76 52 41
Transitivity 0.15 0.35 0.15 0.27 0.45 0.57
Table 2: Summary statistics for each community cluster. Note that the number of reciprocal links and transitivity are calculated for each community clusters network in isolation.

Table 2 contains the summary statistics for each of these community clusters: has the lowest average out degree in the mention network, followed by , and has the highest. The clusters and are the most active; Fig. 7(a) shows that they consistently have the highest number of tweets per users. Cluster is the most tightly connected of the three, with a high transitivity coefficient in both the mention and follower network. These community clusters are also consistently stratified by the sentiment of their tweets over time (Fig. 7(b)).

Figure 7: (a) Average number of tweets per user per day in each community cluster. (b) Out sentiment of each community cluster over time (left y-axis), and number of tweets (right y-axis, orange dotted line)

7 Support for the yes and no sides in the community clusters

Are the community clusters that we found in the previous section representative of yes or no supporters? To find out we sample 358 () users at random and classify manually them as either yes, no and unaligned voters. To classify each user we examine their Twitter biography (self-description) and all their tweets in our dataset. If an account has no obvious leaning, such an automated account (e.g., a bot); an institutional account, or an impartial journalist, we classify it as unaligned. After classifying all the users in our sample, we examine the composition of each community cluster. Table 3 shows how the yes, no and unaligned users are distributed across the sample from each community cluster. See Appendix B for a detailed outline of the classification procedure.

Community cluster
Yes 183 114 6 303
Alignment No 1 2 23 26
Unaligned 21 5 3 29
Total 205 121 32 358
Table 3: Number of sampled yes, no and unaligned supporters in each community cluster.

Users that support the yes side are predominantly found in community clusters and ( of the users in and of users in in the sample). Users that lean towards the no side are concentrated in ( of the users in from the sample). The unaligned users are mostly in () and (), whereas has the fewest (). We categorise each community cluster according to the prevalence of yes and no leaning accounts; this achieves an accuracy of , and a balanced accuracy [9] of (see Appendix B).

As we observed in Sec. 6, the community clusters have varying levels of activity: members of and post twice as many mention tweets as over the observation period. With these activity levels, in combination with the distribution of support in Table 3, we label community cluster as Passive Yes, as Active Yes, and as Active No. Figure 8 shows these classifications displayed on the layout of the mention network, alongside their sentiment.

Figure 8: Reciprocal mention network in which the nodes are coloured by sentiment (a) and the final community-cluster partitions labelled by the side they support in the referendum (b). Edges removed for clarity.

7.1 Activity of community clusters

Figure 9: Fraction of connections between users in the three community clusters for the follower (a) and mention (b) networks.

We examine which community clusters interact more frequently through mentions and friend/follower links, the difference in the type of mention used (original, reply or retweet), and the sentiment of the interactions between community clusters. Figure 9(a) shows that users in the Passive Yes and Active No community clusters tend to follow mostly users within their own group ( and of user links, respectively), whereas users in the Active Yes cluster follow a disproportionately large number of users from Passive Yes (). Users in both Yes communities, on average, follow only a small number of users in Active No ( and respectively). This pattern also appears in the mention network, where most connections are between members of the same community cluster (Fig. 9(b)). The strongest interaction between community clusters consists of connections between users in the Yes groups in both networks.

Mention tweets Porportion of cluster’s tweets
From To Original Reply Retweet Original Reply Retweet
Passive Yes Passive Yes 5302 1755 21740 0.16 0.06 0.68
Passive Yes Active Yes 206 306 2152 0.01 0.01 0.07
Passive Yes Active No 139 168 308 0.00 0.00 0.01
Active Yes Passive Yes 1200 1205 10130 0.05 0.05 0.45
Active Yes Active Yes 380 1935 4648 0.02 0.09 0.21
Active Yes Active No 286 1948 601 0.01 0.09 0.03
Active No Passive Yes 361 458 753 0.04 0.06 0.09
Active No Active Yes 47 939 257 0.01 0.12 0.03
Active No Active No 310 649 4345 0.04 0.08 0.54
Table 4: Type of communication channel used between community clusters. Proportions are given for the total tweets originating from each group.

We also examine which type of mentions (original, replies or retweets) are used by the members of each group in their interactions. All community clusters retweet more often than they produce original messages or replies (Table 4). Unsurprisingly, retweet connections occur most often between groups where there is already a high number of follower connections. We observe a similar situation with original mention tweets. Interestingly, reply tweets do not follow this trend; these messages tend to be sent to community clusters where there are few follower links to the source cluster. The users in the Active Yes and Active No community clusters produce the most reply tweets: and of their tweets are replies, respectively.

Of the total number of tweets sent between the Active Yes and Active No community clusters, and respectively correspond to replies. This finding is surprising for two reasons: Firstly, there are very few follower connections between the two groups, which means that these messages bridged a gap between groups that do not typically interact. Secondly, these groups are ideologically opposed to each other. The Passive Yes community cluster, on the other hand, only sent of its tweets in the form of replies to other community clusters. The two active Yes and No community clusters produced of all replies, although they represent only of all users.

From To Original Reply Retweet
Passive Yes Passive Yes 0.99 0.96 0.97
Passive Yes Active Yes 0.99 0.96 0.97
Passive Yes Active No 0.68 0.49 0.53
Active Yes Passive Yes 1.00 1.00 1.00
Active Yes Active Yes 1.00 0.98 1.00
Active Yes Active No 0.70 0.59 0.76
Active No Passive Yes 0.96 0.81 0.75
Active No Active Yes 0.83 0.47 0.60
Active No Active No 0.94 0.76 0.97
Table 5: Fraction of mention tweets that occurred between nodes that are connected in the follower network.

We also calculate the fraction of original, replies and retweets that occurred in the presence of a follower link. Table 5 shows that, of all the reply tweets between the active Yes and No communities, only and occurred when there was a follower link between the users. This is yet another indication that users in these two groups were more likely to engage with each other, even in the absence of strong structural ties. These results are consistent with the notion that although the marriage referendum was a heated topic on Twitter, the engagement between users with different views was limited to a small subset of highly active users. Note that we only study tweets made using two hashtags; it is possible that the actual number of replies was higher.

Given the differences in the type of mentions between the community clusters, we are also interested in knowing whether the sentiment of the connections varies depending on the source and the target group. We unfold the average out sentiment of each user () to see the scores of tweets directed at each community cluster.

Figure 10: Box plots with the sentiment of the interactions between community clusters (a). On the network in (b) we see an illustration of these boxplots in the mention network. The size and colour of the arrow are proportional to the mean sentiment of the connections from each community cluster.

Figure 10 shows that interactions with the Active No community cluster have, on average, more negative sentiment than other interactions. The interaction between the Active Yes and Active No clusters is overwhelmingly negative. Over of users from both active community clusters use language with negative sentiment in their mention tweets sent between each other. The interactions of the Passive Yes cluster with itself, on the other hand, are overwhelmingly positive; over have a positive sentiment score. The opposite is true for any interaction of the Active Yes with the Active No community cluster. This is the main feature that allows us to distinguish the Active Yes community cluster from the Passive Yes. The interactions between Active and Passive Yes are almost all positive, and consist mostly of retweets. In contrast, the interactions between Active Yes and Active No are typically negative, and consist of replies.

8 Conclusion

We have investigated the relationship between sentiment and social structure in the context of the Twitter discussion about the 2015 Irish Marriage referendum. We computed the sentiment scores of tweets posted by users, and constructed follower and mention networks among users in which the weight of the connections corresponds to the sentiment of the interactions. Our results show that although the sentiment score of individual tweets can be noisy, it can be aggregated successfully using networks to study the interactions between users in a mention and follower network. We performed extensive statistical tests to study the relationship between the sentiment of users’ tweets and their interactions, both in general (i.e., friend/follower) and topic-specific (i.e., from tweets about the referendum). The correlation between the sentiment of mentions that a user sends and receives (the in- and out-sentiment) is positive and robust to randomisation tests. Furthermore, our tests show that users in the mentions network with positive and negative aggregate sentiment scores are more likely to be connected to users with similar sentiment than would occur by chance; positive users are also more likely to follow each other. The community structure of the networks shows that users with similar sentiment tend to be clustered together. We combined sentiment scores with the networks’ communities to find three distinct groups of users that we classified as either yes or no supporters based on the content of their tweets and sentiment, and as active or passive based on their activity. Interestingly, many of the mentions between the users in the yes and no groups occurred in the absence of friend/follower links, which indicates the existence of topical dialogue across ideological lines. These results show that sentiment and social structure are related yet distinct, and must be studied together to understand the disposition of users around topics of interest. This work can be extended in a number of directions, for example by combining sentiment analysis with topic modelling and additional user features (such as demographics, age, gender, or income) to obtain a more accurate picture of user disposition. We anticipate that this work will also provide a basis for incorporating sentiment in opinion dynamics models and the analysis of retweet cascades, and to investigate the calibration of polling data using social structure.


This work was partially funded by Science Foundation Ireland (awards 11/PI/1026 and 12/IA/I683). MBD acknowledges support Oxford-Emirates Data Science Lab and a James S. McDonnell Foundation Postdoctoral Program in Complexity Science/Complex Systems Fellowship Award (#220020349-CS/PD Fellow). The authors thank Kevin Burke and Pete Grindrod for advice and fruitful discussions.

Appendix A Sentiment extraction with SentiStrength

SentiStrength [34] contains a lexicon of sentiment-annotated words and word stems (i.e., roots of words). The system finds the sentiment of a string (more precisely a sentence, or in this case a tweet) of text by matching each word against the internal lexicon. The positive and negative score of the string is the total positive and negative scores from its words normalised to be between and for positive sentiment, and and for negative. SentiStrength also accounts for some nuances of the language by including an extensive rule set that includes negations, repeated letters (for emphasis), and booster words [34]. The rules for punctuation do not apply to our dataset as we removed punctuation as part of the pre-processing of the text. Figure S1 contains examples of how SentiStrength assigns positive and negative scores to short strings of text, and how in some cases can miscalculate the sentiment of a tweet.

Figure S1: Examples of how SentiStrength assigns sentiment scores to various tweets. Highlighted words are detected as positive (green), negative (red), negations and boosters (grey). (a): Example of multiple letters. (b): Negation and booster words. (d): Failure to detect double negatives.

Appendix B Accuracy of the classification of users

The classification of community clusters as either yes, no or unaligned in Sec. 7 was performed manually by annotating a sample of of users in each group. The classification of users was based on their profile description and their tweets with the tracked hashtags, and was blinded to the community cluster of the user. The profile descriptions are an indicator of which side users are likely to support, as they often contain hashtags, words or phrases in support of yes or no (e.g., #equalitymatters or #marriagematters can indicate support for yes or no). Tweets from the referendum day often contain references to having voted or supported yes or no (e.g., “I voted for equality #voteyes #marref”). In the absence of an overt reference to supporting either side we classified the user after examining all their tweets in our data. We assigned an unaligned label if the user did not show a discernible leaning towards the yes or no side. Typically, users who were classified as unaligned either had posted few tweets or their tweets did not have a discernible leaning (e.g., “Interesting debate taking place now about #marref”).

After classifying the tweets from our random sample, we computed the proportion of yes, no, or unaligned supporters in each community cluster. The proportion of yes supporters in community clusters and is and ; as a result, we labelled these groups as yes community clusters. We labelled as a no community cluster because its proportion of no supporters is

. To find the accuracy of these labels we construct a confusion matrix 

[9] (Table S1), which provides a breakdown of true and false positives.

Yes No Total
Classification Yes 297 (True yes) 23 (True no) 320
No 29 (False yes) 9 (False no) 38
Total 326 32 358
Table S1: Confusion matrix with the number of correct and incorrect classification for yes and no voters.

We can calculate the overall and balanced accuracy for yes and no supporters using Table S1. The overall accuracy is the ratio of “true yes” and “true no” supporters ( and , respectively) to the total number of users in the sample (). The overall accuracy for the sample is . However, overall accuracy is known to be biased towards more frequent classes. To correct for this bias we calculate the balanced accuracy [9] by calculating the fraction of correctly classified yes or no supporters out of the total number of actual supporters and averaging the two ( and , respectively). The balanced accuracy is then ().

In Sec. 7 we labelled the community clusters in terms of both the dominant user leaning and activity levels. We defined as the Passive yes community cluster, the Active yes, and the Active no community cluster. In an ideal setting, we would report the balanced accuracy for the three types of users. In practice, however, it is a difficult and subjective exercise to discern Passive Yes from Active Yes users at an individual level. The distinction between passive and active is based on the average user’s activity (number of tweets) in each community cluster shown in Fig. 7(a). Therefore, a balanced accuracy for both voter classification and activity is not viable. If we were to make a distinction between and the balanced accuracy would be , treating and separately.

Appendix C Robustness of randomisation

Figure S2: Results after 1,000 randomisation tests in the mention network and the follower network. (a): Division of users above and below the mean. (b): Division of users above and below the median. (c): Division of users into quantiles. Green squares and red triangles marks the observed fraction of links in the data. A green square indicates that the observed fraction falls outside the lower and upper quantiles of the randomised distribution. A red square indicates the observed fraction falls inside the lower and upper quantiles of the randomised distribution.

In Sec. 5 we showed that the sentiment of users’ in-neighbourhoods is positively correlated (in agreement with previous reports [7]) in both the mention and follower network; this allows us to use it as a proxy for homophily. We arrived at this result by showing that users with similar sentiment, in particular positive users, were connected more often then we would have expected by random chance. These results are robust to how we group these users by sentiment. In Sec. 5 we applied a coarse labelling of users according to their sentiment score (“positive”, “negative” or “unknown”). Here we show that a finer labelling of users also produces similar results. We test three alternative ways of labelling users:

  1. Divide users into groups in which the out-sentiment is below () and above () the mean.

  2. Divide users into groups in which the out-sentiment is below () and above () the median.

  3. Divide users into groups by the out-sentiment quartiles (

    , , , ).

We then randomise the network with these labels in the same way as described in Sec. 5. Figure S2 shows the results from the new randomisation tests, which are consistent with our results in Sec. 5 of the Main Text. The similarity observed between Fig. S2(a) and (b) is due to the fact that the mean and median of the out sentiment distribution are close. In both cases users above the mean and median tend to be connected more than we would have expected by chance. Figure S2(c) tells a similar story, where users in the top two quartiles are more likely to be connected with each other than what we would expect by chance.


  • [1] C. C. Aggarwal and C. K. Reddy, Data clustering: algorithms and applications, CRC Press, 2013.
  • [2] R. Álvarez, D. García, Y. Moreno, and F. Schweitzer, Sentiment cascades in the 15M movement, EPJ Data Science, 4 (2015), pp. 1–13.
  • [3] S. Asur and B. A. Huberman, Predicting the future with social media, in Web Intelligence and Intelligent Agent Technology (WI-IAT), 2010 IEEE/WIC/ACM International Conference on, vol. 1, Aug 2010, pp. 492–499.
  • [4] M. Beguerisse-Díaz, G. Garduño Hernández, B. Vangelov, S. N. Yaliraki, and M. Barahona, Interest communities and flow roles in directed networks: the Twitter network of the UK riots., J R Soc Interface, 11 (2014).
  • [5] M. Beguerisse-Díaz, A. K. McLennan, G. Garduño Hernández, M. Barahona, and S. Ulijaszek, The ‘who’ and ‘what’ of #diabetes on Twitter, Digital Health (in Press), (2017). Also arXiv:1508.05764.
  • [6] A. Bermingham and A. F. Smeaton, On using Twitter to monitor political sentiment and predict election results, (2011).
  • [7] C. A. Bliss, I. M. Kloumann, K. D. Harris, C. M. Danforth, and P. S. Dodds, Twitter reciprocal reply networks exhibit assortativity with respect to happiness, Journal of Computational Science, 3 (2012), pp. 388 – 397. Advanced Computing Solutions for Health Care and Medicine.
  • [8] J. Bollen, H. Mao, and X. Zeng, Twitter mood predicts the stock market, Journal of Computational Science, 2 (2011), pp. 1–8.
  • [9] K. H. Brodersen, C. S. Ong, K. E. Stephan, and J. M. Buhmann, The balanced accuracy and its posterior distribution

    , in Pattern recognition (ICPR), 2010 20th international conference on, IEEE, 2010, pp. 3121–3124.

  • [10] N. Charlton, C. Singleton, and D. V. Greetham, In the mood: the dynamics of collective sentiments on Twitter, Open Science, 3 (2016).
  • [11] P. Cihon and T. Yasseri, A biased review of biases in Twitter studies on political collective action, Frontiers in Physics, 4 (2016), p. 34.
  • [12] J.-C. Delvenne, M. T. Schaub, S. N. Yaliraki, and M. Barahona, The stability of a graph partition: A dynamics-based framework for community detection, in Dynamics On and Of Complex Networks, Volume 2, Springer, 2013, pp. 221–242.
  • [13] J.-C. Delvenne, S. Yaliraki, and M. Barahona, Stability of graph communities across time scales, Proc Nat Acad Sci USA, 107 (2010), pp. 12755–12760.
  • [14] P. S. Dodds, E. M. Clark, S. Desu, M. R. Frank, A. J. Reagan, J. R. Williams, L. Mitchell, K. D. Harris, I. M. Kloumann, J. P. Bagrow, K. Megerdoomian, M. T. McMahon, B. F. Tivnan, and C. M. Danforth, Human language reveals a universal positivity bias, Proceedings of the National Academy of Sciences, 112 (2015), pp. 2389–2394.
  • [15] C. Fitzpatrick, Twitter’s woes continue as Irish userbase falls, 2016. (Accessed 2016-08-20).
  • [16] D. Gayo-Avello, “I wanted to predict elections with Twitter and all I got was this lousy paper”–a balanced survey on election prediction using twitter data, arXiv preprint arXiv:1204.6441, (2012).
  • [17] D. Gayo-Avello, No, you cannot predict elections with twitter, IEEE Internet Computing, 16 (2012), pp. 91–94.
  • [18] J. P. Gleeson, D. Cellai, J.-P. Onnela, M. A. Porter, and F. Reed-Tsochas, A simple generative model of collective online behavior, Proceedings of the National Academy of Sciences, 111 (2014), pp. 10411–10415.
  • [19] S. Goel, A. Anderson, J. Hofman, and D. J. Watts, The structural virality of online diffusion, Management Science, 62 (2015), pp. 180–196.
  • [20] P. Grindrod and T. E. Lee, Comparison of social structures within cities of very different sizes, Royal Society Open Science, 3 (2016).
  • [21] H. Kwak, C. Lee, H. Park, and S. Moon, What is Twitter, a social network or a news media?, in Proceedings of the 19th international conference on World wide web, ACM, 2010, pp. 591–600.
  • [22] V. Lampos and N. Cristianini, Tracking the flu pandemic by monitoring the social web, in 2010 2nd International Workshop on Cognitive Information Processing, June 2010, pp. 411–416.
  • [23] B. Liu and L. Zhang, A survey of opinion mining and sentiment analysis, in Mining text data, Springer, 2012, pp. 415–463.
  • [24] A. Livne, M. P. Simmons, E. Adar, and L. A. Adamic, The party is over here: structure and content in the 2010 election., ICWSM, 11 (2011), pp. 17–21.
  • [25] P. T. Metaxas, E. Mustafaraj, and D. Gayo-Avello, How (not) to predict elections, in Privacy, Security, Risk and Trust (PASSAT) and 2011 IEEE Third Inernational Conference on Social Computing (SocialCom), 2011 IEEE Third International Conference on, IEEE, 2011, pp. 165–171.
  • [26] A. Mislove, S. Lehmann, Y.-Y. Ahn, J.-P. Onnela, and J. N. Rosenquist, Pulse of the nation: US mood throughout the day inferred from Twitter, 2010.
  • [27] F. Morstatter, J. Pfeffer, H. Liu, and K. M. Carley, Is the sample good enough? comparing data from Twitter’s streaming API with Twitter’s firehose, arXiv preprint arXiv:1306.5204, (2013).
  • [28] M. Mukaka, A guide to appropriate use of correlation coefficient in medical research, Malawi Medical Journal, 24 (2012), pp. 69–71.
  • [29] B. O’Connor, R. Balasubramanyan, B. R. Routledge, and N. A. Smith, From tweets to polls: Linking text sentiment to public opinion time series., ICWSM, 11 (2010), pp. 1–2.
  • [30] M. O’Halloran, Marriage vote turnout in top five of all referendums, 2015 accessed 2016-08-20.
  • [31] B. Pang and L. Lee, Seeing stars: Exploiting class relationships for sentiment categorization with respect to rating scales, in Proceedings of the 43rd annual meeting on association for computational linguistics, Association for Computational Linguistics, 2005, pp. 115–124.
  • [32] B. Pang and L. Lee, Opinion mining and sentiment analysis, Found. Trends Inf. Retr., 2 (2008), pp. 1–135.
  • [33] RTE news, Marriage referendum leading Irish Twitter topic for 2015, 2015 (accessed 2016-08-20).
  • [34] M. Thelwall, Heart and soul: sentiment strength detection in the social web with sentistrength, Proceedings of the CyberEmotions, (2013), pp. 1–14.
  • [35] A. Tumasjan, T. O. Sprenger, P. G. Sandner, and I. M. Welpe, Predicting elections with twitter: What 140 characters reveal about political sentiment., ICWSM, 10 (2010), pp. 178–185.
  • [36] P. D. Turney, Thumbs up or thumbs down? semantic orientation applied to unsupervised classification of reviews, in Proceedings of the 40th annual meeting on association for computational linguistics, Association for Computational Linguistics, 2002, pp. 417–424.
  • [37] S. Unankard, X. Li, M. Sharaf, J. Zhong, and X. Li, Predicting elections from social networks based on sub-event detection and sentiment analysis, in International Conference on Web Information Systems Engineering, Springer, 2014, pp. 1–16.
  • [38] I. N. Zheludev, When can social media lead financial markets?, PhD thesis, UCL (University College London), 2015.