Skip to the content.

Danish politicians - Does Twitter reflect real politics?

Authors: Frederik Kromann Hansen, Lau Johansson & Christian Petersen
4th March 2020
Read time: 17 minutes

Introduction

In Denmark, the legislative power is in the hands of the elected politicians. These Danish politicians are therefore of great importance for how Denmark develops as a country. The politicians meet at the Danish Parliament to debate bills, and these meetings are publicly available. Outside the Parliament, the Danish politicians also figure on social media – there among Twitter. This platform allows the politicians to directly communicate with both the public and other politicians. It is interesting to examine how politicians are connected on Twitter, and how these connections correspond to the structure of the political system in Denmark. At the same time, it is interesting to analyze the topics of the politicians’ tweets, to shed light on whether the politicians’ opinions on social media correspond to what the parties debate in the Parliament.

Data Collection

To attempt to satisfy the curiosity expressed in the introduction, we will need data from three different kinds of sources. Firstly, some information on who the politicians are and what parties and regions they belong to. Secondly, some data on social interactions between the politicians as we want to investigate the network spanned by these and the contents of the network. Thirdly, some data on their official business, to investigate if it aligns with what they express to the public through their most easily accessible public statements on Twitter.

Twitter Data

On twitterpolitikere.dk, Twitter profiles of 650 danish politicians have been collected (25 November 2020). The publishers of the data are journalists Ernst Poulsen and Filip Walberg in collaboration with the Center for Journalism. The website is continuously updated by the publishers, with data from Twitter’s open APIs. Danish politicians can choose to write to the publishers to be removed from the list. Each person’s profile is assessed manually by the authors before people are included on the lists. There is no information on the process of assessing the profiles. If interested, this link has more lists with overviews of people in different industries: Politicians, journalists and people in managerial positions, etc.

From the list of Danish politicians’ Twitter usernames, each of the profiles is going to represent a node in a graph that is going to be called: “Danish Politicians’ Twitter Network”. In order to make a network that connects the Danish politicians, this project uses tweets from Twitter. Initially, a developer account for twitter has been created. Tweets can then be assessed through Twitter’s API on https://developer.twitter.com/en. Tweets are messages posted to Twitter containing text, photos, a GIF, and/or video. Both sender and receivers of tweets can see all tweets on a Home Timeline – a timeline that is different for each person – depending on who you are following.

This project is especially interested in mentions because mentions are tweets that contain other profiles’ Twitter usernames. A mention in a tweet is preceded by the “@” symbol – which makes it possible to examine the mentions between Danish politicians. These mentions are the edges between politicians in the network.

Political parties

In most cases, politicians are members of some party, sharing a general ideology that they agree with. Therefore, and because politicians might communicate equally as much in the role of a representative of their party, as they do for themselves personally, it is also interesting to investigate the network spanned by parties. For example if Mette Frederiksen mentioned Lars Løkke, then that would count as Social Demokratiet mentioning Venstre.

Since the parties were not on twitterpolitikere.dk, the Parliament’s official website, ft.dk was scraped to achieve this extra data. Additionally, to get information on the politicians not in Parliament a multitude of places was scraped. The journey began looking at the five regions in Denmark, as each region had its own council with elected members. Doing this, inspired the addition of a region attribute to the politicians, in the project nothing was made of this but it is available for future work.

Examining the data, hundreds of politicians were still missing a party and a region, after looking up some of these politicians, it was clear that the large majority of the Twitter profiles belonged to politicians that were council members of their local municipalities. Unfortunately there are 98 municipalities in Denmark, so scraping all of these wasn’t feasible.

In the end, about half of the 650 politicians were assigned a party and a region!

Parliament Meetings

The most official business of the politicians must be what they say in the Parliament. The data related to the meetings in the Parliament is collected following the guide on its homepage here.
Transcripts from all meetings going back to 2009 are available for download in XML format using a login described in the guide and some specific FTP software. Because it is interesting to compare topics from Twitter with topics in the Danish Parliament, only the transcripts from the same period as the tweets are used for further analysis. 71% of the available tweets are posted in 2018 and after.

The years in the Danish Parliament do not follow the calendar year, as they start and end the first Tuesday of October. So, the meetings from 2017 are actually from October 2017 to October 2018. The data from 2017 are kept for the purpose of having slightly more data and because it is assumed that topics vary little enough for it to still be relevant.

In total 395 meeting transcripts amounting to 218Mb of data has been downloaded and parsed for analysis.

It is not stated how the transcripts are made, however, they are proofread before publication.

Network analysis

Preliminary statistics

The network contains 561 Danish politicians who have a Twitter profile, but since some of the profiles do not interact with anyone, 555 are left.

The maximum distance between any two politicians in the network is 6, which actually relates to an interesting phenomenon called “Six degrees of separation”. The phenomenon states that between any two individuals on Earth, there’s a path of at most six acquaintances between them. However, the average distance between any Danish politician on Twitter is only 2.

The network can be visualized by coloring the nodes according to the associated party. By further having the distance between nodes relate to the similarity between them it gives an idea of potential polarization and groups within politics. Finally, the size of the nodes determine the “popularity” in the sense that bigger nodes means more mentions suggesting higher popularity. The network is shown below with these traits. Notice how the biggest node is the black one in the middle representing the Government’s official profile, regeringDK. From this it can be seen that this profile on Twitter is mentioned and/or mentions the most other profiles.

The top 5 most central profiles on Twitter, the ones who connect to the most of the other politicians are: the Government (regeringDK), Lars Løkke Rasmussen (larsloekke), Jakob Ellemann (JakobElleman), Kristian Jensen (Kristian_Jensen) and Morten Østergaard (oestergaard). Surprisingly, the current Prime Minister Mette Frederiksen, among others, does not have Twitter.

Is it a random network?

This project aims to build models that reproduce the properties of real networks. To examine whether the graph reproduces a real network or if it is just a random network, the degree distribution of a random network is compared to this network. One thing influencing the structure of a network, is the probability of nodes linking together. For this network, the probability is 6.6 % meaning that there is a 6.6% chance that two randomly chosen nodes are connected.

There are two extreme cases. If p=0, there’s zero probability that any node links to another – all nodes are isolated. If p=1, there’s 100% probability that any node links to another – the graph is complete, every node links to all other nodes. This network is in the so-called “connected regime”, which means that the Twitter network will emerge to a giant connected component (GCC), which absorbs all nodes and components. To further analyze the Twitter network, the GCC is extracted and it contains 555 politicians – that’s almost everyone!

The degree of a random network follows a poisson distribution. Therefore to assess if the Twitter network is completely random or follows some general rules the degree is compared to that of a random network.

To yet examine the randomness, the above plots can be inspected. On the log-log plot, the degree distribution of the GCC follows the power-law and therefore the GCC of the Twitter network is not random. According to Network Science Book – section 4.2 it is even a scale-free network.

A property of a scale-free network is the nature of preferential attachment. This affects the degree of the largest node, so new politicians joining Danish politics (and Twitter) will prefer to connect to some of the hubs in the network. One or a few large hubs connect to most of the notes, which can represent some of the most influential Twitter profiles. Or, at least be a great potential source of bringing a message.

The graph is in the connected regime, and the GCC of the Twitter network absorbs all nodes. The properties of the politician Twitter network are therefore consistent with some of the properties of other real-world networks!

House of Cards - the Danish version

If a politician should sow the seed of a political agenda among other politicians and the public who follows the politicians - who should he or she address?

This question reminds one of the plot from House of Cards:

"Congressman Frank Underwood (Kevin Spacey), a Democrat from South Carolina's 5th congressional district and House Majority Whip, and his equally ambitious wife Claire Underwood (Robin Wright). Frank is passed over for appointment as Secretary of State, so he initiates an elaborate plan to attain power, aided by Claire. The series deals with themes of ruthless pragmatism, manipulation, betrayal, and power." - Wikipedia

This story is possibly more dramatized than the real life of Danish politicians. Nevertheless, this case is called "House of Cards - the Danish version". If a few politicians on Twitter connect to many others, then these could potentially have a great influence on the formation of public opinion - and maybe also the opinion of other politicians.

We have chosen a totally random Danish politician: StemClausson (Jesper Clausson). On Twitter, he writes that he is a regional council member for Socialdemokratiet at Region Hovedstaden. He is now the main character for the case called "House of Cards - the Danish version".

The social network graph representing all the Danish politicians on Twitter can help identify the connection between Jesper Clausson and all the other Danish politicians. In the graph below Jesper Clausson is the green node. The politicians that he interacts directly with (mentions others or gets mentioned) are "1 step away". Politicians, who do not interact directly with him, but with the 1-step-away'ers, are "2 steps away". Then you got the point with the "3 steps away" and "4 steps away"...

As you notice, many nodes are 2 steps away from Jesper Clausson, which is then consistent with the previously stated fact - that most politicians are 2 steps away from each other.

One of the most central politicians in the network is Lars Løkke Rasmussen (larsloekke) with connections to 213 other politicians on Twitter. According to Lars Løkke Rasmussen's profile, he is a member of The Danish Parliament, former chairman of the party "Venstre" and former Prime Minister. There is no doubt why he is central in the social network of Danish politicians.

If Jesper should influence as central a person as Mr. Rasmussen, what should he then do? What if Jesper can not talk directly to Rasmussen, but is able to talk to some of the politicians closer to him. Who should he talk to directly? By finding the politicians which Lars Løkke connects to, we can identify the politicians he interacts with and thereby those who are more likely to influence him than Jesper Clausson.

Politicians that Lars Løkke Rasmussen connects with. From the top centre and clockwise around: Søren Pape Poulsen, Rasmus Jarlov, Louise Elholm, Bjørn Brandenborg, regeringDK, Statsmin, Frank Jensen, Rasmus Nordqvist, Jesper Petersen, Mai Mercado, Jan E. Jørgensen, Rasmus Stoklund, Jakob Ellemann and Kristian Thulesen Dahl.

Not surprisingly, a lot of the politicians that Lars interacts directly with on Twitter, are members of the Parliament. He also interacts with the Twitter-profile of the Prime Minister's Office and the official profile of the Danish government. Several of the politicians "closer" to Lars is from the party "Venstre", but among others are also "Det Konservative Folkeparti", "Socialdemokratiet" and "Dansk Folkeparti". So Jesper Clausson has around two handfuls of politicians to go directly to, if Lars Løkke is unavailable.

What if Jesper Clausson should hope to have a more indirect influence? He does not necessarily want to go directly to all the members of the Danish Parliament. Maybe he does not know any of them personally or professionally - at least he does not interact with them on Twitter. In network theory, there's a term called "Shortest Path", which is the shortest path between two nodes through the graph. This method can help find the people making up the minimum number of interactions between Jesper Clausson and Lars Løkke Rasmussen. What is important to keep in mind is, that we need to find the shortest path FROM larsloekke TO StemClausson, since the network is directed, meaning that there is a difference between if Lars tags someone or someone tags Lars. We need to look at who Lars Løkke mentions on Twitter, then, who do these mentions, and who do these mention etc... The next House-of-Cards'ish question is: "Who should StemClausson talk to if words should spread through the shortest path form Jesper to Lars?"

The path shortest path from StemClausson to larsloekke: Jesper Clausson (StemClausson) -> Marianne Frederiksen (mariannefrede20) -> Daniel Panduro (Danielpanduro) -> Jakob Ellemann (JakobEllemann) -> Lars Løkke Rasmussen (larsloekke).

StemClausson interacts with marinannefrede20 on Twitter. Regionh.dk informs that both StemClausson and marianne20 are members of the Regional Board. mariannefrede20 is member of the party "Enhedslisten", a party, who also Danielpanduro is a member of. marinanne20 and Danielpanduro also interact on Twitter. He is among other titles municipal board member of Frederiksberg. JakobEllemann is member of the parliament and interacts with DanielPanduro on twitter. At the same time JakobElleman is also of the party "Venstre" - the party where larsloekke is member too. Now we've found the shortest path from StemClausson to larsloekke.

The mapping of the shortest path was not necessarily easy to identify by browsing through Twitter. This insight shows how network theory can model complex social networks. If you should find the shortest path from Jesper Clausson to Lars Løkke Rasmussen how would you do it? With 555 politicians connecting with each other there's a lot of possible paths to asses.

Text analysis

Preliminary statistics

For the text analysis of Twitter data 83000 tweets has been collected using Twitter's API. The average length of the tweets is 22 words.

For 312 of the 555 politicians, their last 200 tweets has been downloadet. If a politician has less than 200 tweets overall though time, all his/hers tweets are then downloadet. 25% of the politicians has 20 or less tweets. It should be kept in mind that there may be a time lag between tweets across politicians'.

Meetings at the Parliament

Speech in the Danish Parliament is much more formal than it is on Twitter. Therefore, it is no surprise that the average sentiment for all parties is positive as shown in the bar chart below. They often start their speech by being appreciative towards the one posing the question as well as the moderator for receiving the word. Also, they often say that they understand the cause of the question or the like, which adds to a positive sentiment score as well. On the other hand, they primarily discuss disagreements on current issues, contributing to the negative side.

Notice that Nye Borgerlige, infamous for being xenofobic, has the lowest average sentiment. One should also keep in mind, that one can choose to focus on negative aspects of a topic and another on the positive ones and thereby have different sentiments in the same conversation.

So in relation to the above, it is important to be aware of how the sentiments are calculated as it is very simple. A lot of words in a range of different languages are given a value indicating the sentiment. In the package that we have used, the range is between -6 and 6 for each word. The total sentiment of a long speech or a tweet is then simply the sum of sentiments from all the words. To exemplify this, take a look at the below quote from the most negative speech in Parliament, made by Karina Adsbøl from Dansk Folkeparti.

“Tak for det. Og I får æren af at høre ligestillingsordføreren i dag. At udøve vold er fuldstændig uacceptabelt – og det gælder alle former for vold. Lev Uden Vold har beskrevet flere voldsformer, og det er fysisk vold, psykisk vold, stalking, seksuel vold, materiel vold, økonomisk vold og digital vold. Den fysiske vold er den mest velkendte form for vold og er ofte kendetegnet ved slag, spark, skub, angreb med kniv eller kvælningsforsøg, som påfører den udsatte fysisk smerte og skade(...)”

Karina Adsbøl, Dansk Folkeparti

Notice how she uses the word 'vold', which is Danish for violence, a lot. Each time the sentiment is decremented by 3 as it is considered a very negative word. This snippet of the text has a sentiment of -36 and yet to the reader who understands Danish it leaves the impression of a more or less objective description of violence. This is important to be aware of when assessing the sentiments across people and parties, such that one does not jump to the conclusion that Karina Adsbøl is an angry person who scolds people or objects to everything. It may very well be that the topic of discussion is merely a negative one such as violence.

Cross-party sentiments

In order to examine cross party relationships on Twitter, each tweet was examined in terms of which party the tweet belonged to, and which party it mentioned. Then a sentiment score was given for each tweet.

In the above table, an overview of the inter-party relationships are given. On the positive side, results are quite mixed and no apparent pattern can be found. However, on the most negative parties, the results indicated the most of the parties tweeted with negative sentiment towards the Government profiles and Nye Borgerlige profiles. For those that critisize the government profiles, it’s indicative of criticism towards certain decisions made. The data shows that the parties; Dansk Folkeparti, Alternativet, and those outside parliament disagree the most with the government. In Danish politics, the “red bloc” is in control right now, and these parties, are either in “blue bloc”, “green bloc” or no bloc at all, supporting this theory.

Let’s also look at the overall sentiment per party, so without considering the mentions.

We see that every party has a median score of 0 or above. Furthermore, the Government, Venstre, and Det Konservative Folkeparti, seem to have a smaller variance in the sentiment of their tweets.

Furthermore, it can be seen that Nye Borgerlige, Alternative and Inuit Ataqatigiit have far fewer outliers when compared to the rest, this could be a result of fewer tweets but could also suggest less varying opinions. Lastly look at the outliers, excluding the UNKNOWNs the most negative tweet comes from Socialistisk Folkeparti and the most positive comes from Socialdemokratiet.

Lastly, a network could be generated where edge colors represent the mean sentiment between the parties

Click here to see table with sentiment scoring between the parties
PartyHighest scoring party: sentimentLowest scoring party: sentiment
SocialdemokratietAlternativet: 2.04Inuit Ataqatigiit: 0*
VenstreRadikale Venstre: 2.06Inuit Ataqatigiit: 0*
Det Konservative FolkepartiVenstre: 1.59Nye Borgerlige: -1.0*
Radikale VenstreInuit Ataqatigiit: 8.0*Nye Borgerlige: -0.66
EnhedslistenDansk Folkeparti: 1.17Nye Borgerlige: -1.6*
Inuit AtaqatigiitEnhedslisten: 3.5*Socialdemokratiet: -4.0*
Dansk FolkepartiDet Konservative Folkeparti: 1.37Government: -0.61
Uden for folketingsgrupperneNye Borgerlige: 3.0*Government: -0.33
Nye BorgerligeVenstre: 1.37Socialistisk Folkeparti: -2.33
GovernmentSocialistisk Folkeparti: 1.67Enhedslisten: -0.5*
Socialistisk FolkepartiUNKNOWN: 1.21**Nye Borgerlige: -0.86
AlternativetRadikale Venstre: 3.33Government: -0.097
Liberal AllianceRadikale Venstre 1.45Uden for folketingsgrupperne: -1.33
* low amount of tweets so might be misleading **UNKNOWN party for these profiles are unknown

See that the sentiments are close to 0 in sentimentscore indicating no apparent polarization between the parties. The most immediate observation is the positive score between Radikale Venstre and Iniut Ataqatigiit. Nye Borgerlige and the Government appear most on the lowest score of average sentiment between parties.

Parties and word clouds

In this subsection, the examination of the following questions will be carried out: "Do the parties tweet about the same topics as they talk about at the parliament?"

Each of the politicians are grouped in their associated political parties. Then word clouds are generated based on the text from all tweets belonging to the members of each of the parties. Additionally, word clouds are generating using meetings from the Parliament - now also grouped by the parties.

Now the topics of tweets and topics of the meeting can be compared. This comparison takes the eight main topics of meetings and twitter for each party. Notice that we manually de-select all words that are verbs or non-important words like adverbs. The following three parties shows some of the interesting results.

Let’s start by looking at Socialdemokratiet.

Top 8 Meeting topics: work, people, children, possibilities, folks, forward, time, people's party

Top 8 Twitter topics: "spolitik", new, good, children, regions, "randers", "venstredk", "s"

Socialdemokratiet talks about work, people and children at the meetings. The topic "børn" (children) corresponds to some of the main topics at Twitter - which is also children. The topics at the meetings (people, possibilities, time) are more general terms, where the topics on Twitter are more specific. One of the Twitter topics is "randers", which is a city in Denmark in Jutland. Socialdemokratiet also mentions "venstredk" which relates to the party Venstre. What is interesting to see is that the word "børn" is a topic of the cloud. At the new-years speech, Mette said that she stand up for the children in Denmark link.

Lets have a look on Nye Borgerlige…

Top 8 Meeting topics: "nye borgerlige", people, folks, money, "venstre", foreigners, possibilities, Islam

Top 8 Twitter topics: "nye borgerlige", "dkmedier", "klr15", children, "madswibeck", the Danes, EU, foreigners

Nye Borgerlige's mentions the party "venstre" in the meetings, and the more unique topics in relation to the other parties, is the topics "udlændinge" (foreigners) and Islam. At Twitter, foreigners is also a topic! Theres som similarity in that topic. At Twitter Nye Borgelige also talks about children and the EU.

Let’s look at Radikale Venstre…

Top 8 Meeting topics: "radikale venstre", decline, people's party, children, work, folks, people, money

Top 8 Twitter topics: "radikale", "dkgreen", "oestergaard", eu, "sofiecn", "s", children, "næstved"

Radikale Venstre's meeting topics related to children, people and work. At Twitter the topics relate to clima ("dkgreen"), the EU and children. The topic "næstved" relates to a city in Jutland. One could perhaps question whether the tweets topic concerning e.g. clima corresponds to the topics they actually talk about in the Parliament. 

Now we’ve provided some insights into three of the Danish parties. This project can not with certainty conclude whether the parties tweet about the same topics as they talk about at the parliament. But the word clouds gives some indication: some parties tweets and meetings seems very alike. Other parties talk more “conceptual” about people, work and money. In the end - we’ll let the readers judge by themselves. Word clouds are generated for all of the parties and located in the bottom of this webpage in the section “The word clouds for the parties”. 

Community detection and word clouds

Community detection

By translating Twitter relationships and mentions into a network, it is possible to shed light on how politicians are connected. Some politicians may be more connected than others, and with the use of network theory, it is possible to divide the policies into groups so that those who are most connected belong to the same group.

This connection can provide new insights into how politicians can perhaps more effectively gather up and discuss relevant political issues with other politicians talking about the same thing. 

To generate communities from the Twitter network, the best partition algorithm was used. It seeks to maximize the modularity of each community using Louvain heuristics. More on this here. Below is a visualization of the best partitioning of the network.

With the communities in place, it was of interest to see what these communities talked about, so a series of words clouds were produced to summarize this data.

For example the word cloud for the first community looks like this;

The three most central profiles in this community, (Morten Østergaard, Sofie Carsten Nielsen, and Kristian Hegaard) are all from the same political party “Radikale Venstre”, which could be the reason why “Radikale” are one of the main topics of this community. After looking into the community members, it is observed that there are a lot of members from the “Radikale Venstre”. Some of the main topics from the community are also opdagdanmark, which is a webpage dedicated to informing about the activities in Denmark. Furthermore, the community talks about “gin”, which indicates a more non-formal language.

Let’s have a look on another community word cloud.

Marianne Vind ("Socialdemokratiet"), Karen Melchior ("Radikale Venstre"), and Jan E. Jørgensen ("Venstre") are the most central politicians in this community. This community tweets the most about the EU. Marianne and Karen are both members of the EU-Parliament and Jan is EU-moderator for "Venstre". Therefore it is not surprising, that these are the main topics of these politicians. Regardless, this could support that these politicians, which officially are attached to political posts regarding the EU - are actually also tweeting about the EU. There is therefore some link between their political role and their tweet topics.

Looking across all of the most central politicians in each of the communities, each of the communities actually represents the parties. This applies to four of the identified communities. Most of the communities even only contain members of the same political party. This indicates, that the partitioning of the network did not give any surprisingly new communities. Other than it emphasizes that politicians on Twitter connect the most with members of their own party. However, the community described above is an example of how politicians connect (potentially) in relation to which topics they tweet about. If a more efficient way of gather with other politicians, should be based on this analysis - it could be recommended that members of the community should meet up and discuss topics like the EU.

Summary

A network based on tweets from Danish politicians. It revealed that the constructed network has the properties of a true social network. An interesting finding, is that the average distance between any two politicians on Twitter is only 2 acquaintances! 

Sentiment analysis on the meetings in the Parliament and on Twitter reveals a more formal language in the Parliament - but more personal communication on Twitter.  There’s a difference between the parties' overall sentiment score in the Parliament. The least positive party at the Parliament meetings is Nye Borgerlige. Interestingly, Nye Borgerlige and the Government has the lowest sentiment score from other parties on Twitter. 

Looking at word clouds from Twitter vs. the Parliament for the party Socialdemokratiet, it can be observed children is one of the main topics - both at Twitter AND in the Parliament meetings. Could this mean that Mette Frederiksen is actually the Prime Minister of the children?

Using cool network theory, the politicians have been divided into communities depending on the mentions on Twitter. Most of the communities are very similar to the actual political parties of the community-members. However, one community is different! The community-members do not belong to the same party BUT are all especially engaged in the EU. This information could in the future be used to more efficiently gather politicians based on their political engagements and make the shortest path EVEN shorter. Potentially, if a politician realizes who he/she is in a community with, they could have more in common than initially thought, which could lead to greater discussions of relevant political issues.

Downloads

Link for explainer: https://colab.research.google.com/drive/1ezGDpo4C-tn6zqIPBhYVd97n-_C4MV1W?usp=sharing

If you are interested in doing network science yourself, you can clone our Github repository. Please keep in mind - the files containing access-keys for the Twitter APIs are removed.

The word clouds for the parties can be found here - [LINK](https://github.com/LauJohansson/LauJohansson.github.io/tree/main/images/party_clouds)