Canada response to COVID-19

Published in GitHub.com, 2021

The idea of this project was born on March 11th of 2020, when the Prime Minister of Canada, Justin Trudeau, announced a series of policies to help Canadians cope with the COVID-19. The objective is to measure the impact of the Government policies to help Canadians cope with the COVID-19, studying people’s perception by making sentiment analysis on users’ tweets, before and after the Prime Minister’s announcement.
$\bigstar$ Click here to look at the original GitHub repository of this project.

Authors: Leo Cuspinera (cuspime), Victor Cuspinera (vcuspinera)



“Our message to Canadians is clear: to every worker and business, in every and
territory, we have your back and we will get through this together.”

— Justin Trudeau, Prime Minister of Canada. Press conference on March 11th, 2020.

Downloading tweets

To compare the public opinion before and after Trudeau’s announcement in the Twittersphere, the first obvious step is getting the tweets. We decided to make a thorough scrapping of tweets using snscrape library, from February 1st 2020 to April 30th 2020 that mentioned at least one of the four aforementioned accounts of the Canadian Government: @Canada, @CanadianPM, @JustinTrudeau and @GovCanHealth. After this step, we clean the database by preprocessing sensible information as emails and urls, and droping tweets with adds.

Explanatory Data Analysis (EDA)

When plotting tweets that mention at least one of the Canadian Government Twitter accounts we find that between February and April 2020, the @JustinTrudeau account had between 3.0 and 21.4 thousand tweets per day, @Canada had between 98 and 470 tweets per day, @CanadianPM had between 104 and 1,179 tweets per day, and @GovCanHealth between 30 and 1,182 tweets per day.

To identify the days with more tweets, removing weekly seasonality, we calculate the Moving Averages with 7-day window, and normalize these averages by account using minimum and maximum number of tweets. In this plot we can identify an increase in number of tweets for all the Canadian Government’s Twitter accounts around March 11th, 2020, with a peak of tweets between March 14th and 17th, decreasing from this point on until return to lower levels in mid-April 2020.

⭐️ More details of the EDA are available in this link.

Sentiment Analysis

When making sentiment analyses, we must first know what languages we will be considering. For this project, most of the scrapped tweets were written in English (about 85.5% of all tweets), so for the main analysis we used tweets wrote in English. This enhanced the reach of powerful tools like spaCy, TextBlob and wordcloud, mainly developed for this language.

When comparing word clouds of tweets published before and after the announcement on March 11th, 2020, we found that most used words and their repetitions are very similar among both groups.

Wordclouds are always nice but they hardly tell us anything about the trends or distribution in opinions. For our sentiment analysis we made use of spaCy’s modules to extract the polarity and subjectivity of texts.

As wee can see in the plot below, the information conveyed by the downloaded tweets before and after the announcement provide very similar Polarity and Subjectivity curves. While the polarity in both groups is very similar, mainly centered on 0, in both cases it is slightly skewed for positive tweets (however, remember the scale is logarithmic!). In the other hand, when looking at the subjectivity we can notice the huge outlier on the left-hand side when subjectivity equals 0, which tells us that there are many tweets that give no opinion and are only informative, they are not biased to give a positive or negative opinion in any sense whatsoever.

Additionally, we perform hypothesis testing polarity and subjectivity on tweets before and after the announcement on sub-samples of tweets, but we couldn’t reject that both means of these measures were different.

We also use Time Series to find the Trend of polarity and number of tweets. From this analysis, while the trend in sentiment decrease for the @Canada account, tweets related with the Canadian Prime Minister (@CanadianPM and @JustinTrudeau) had a positive impact after the announcement. In addition, the @GovCanHealth had a steady trend in polarity levels.

Finally, the announcement also impacted in the volume of tweets, as well the actions and reactions of users increasing the number of likes, replies, retweets and quotes.

⭐️ Click here to see the complete Sentiment Analysis.

Final comments

On the analysis we find that the announcement on March 11th, and the following announcements of the Government policies related with COVID-19, had an impact in the sentiment of tweets and their volume:

  • Sentiment: while the overall sentiment of tweets is positive, the announcement had different effect for the Government accounts. While the effect on @Canada account was a decrease in the average polarity, in the other hand we identify a rise in the positive sentiment of tweets related with the Canadian Prime Minister (which means an increase in the polarity levels of @CanadianPM and @JustinTrudeau accounts). The @GovCanHealth account was stable in polarity level before and after the announcement.
  • Volume: we observed an increase in the total number of tweets and the average tweets per day. Also, the announcement affected the volume of actions and reactions of users increasing the volume of likes, replies, retweets and quotes.

Main references

⭐️ Click here to access the complete list of references for this project.