It’s big business to know what people are thinking.

By one estimate, market research and public opinion polling is a $20 billion industry in America. Businesses want to know if people like their products. Politicians want to know if they’re popular. And frequently, governments — or the politicians that comprise them — want to know what the public thinks about various issues.

But finding that information out is pretty difficult. You can pay people to participate in a focus group. You can call hundreds or thousands to conduct a poll, and hope some answer the phone. You can pay per click for online surveys, and trust that people are reading them and not just filling them out as quickly as possible.

Or, you can just listen to what people are already telling you. On social media every day, people share their opinions on every topic imaginable; and recently that has meant a lot of tweets about the coronavirus. With that in mind, I wanted to look at how people responded to different Utah coronavirus topics and leaders.

So I cobbled together a Twitter sentiment analyzer to quantify people’s opinions on any topic. How does it work? Here’s a brief overview.

First, it searches all of Twitter for a specific person, word, or set of words. On Twitter, users can search all tweets for any topic in any timeframe, but Twitter only allows programs to search through the past 10 days or so of tweets. There’s a workaround, though: the GetOldTweets3 project in the programming language Python scrolls through results, scrapes them, and saves all of the tweets.

From there, we want to quantify the sentiment behind each one. To do that, we use the open-source sentiment analyzer available in the TextBlob library, which puts every tweet on a negative-to-positive scale of -1 to 1. It does this by searching for positive or negative words, then averaging the coefficients of each word.

Tweets were labeled as positive if they returned a score greater than 0.1. Note that a tweet not being positive doesn’t necessarily mean it’s negative: there are plenty of tweets that used completely neutral language. Any tweet that the analyzer was unsure on was also removed.

There are plenty of sources of error in an analysis such as this, we should note. The sentiment analyzer struggles with sarcasm, for obvious reasons. If you’ve been on Twitter, you know there are plenty of tweets where even a human can’t tell what someone is trying to say, let alone a computer program. There’s also a certainty of response bias in the data: people who tweet about something or someone are not necessarily representative of the population as a whole.

Still, I believe there is signal through the noise, when you analyze the opinions of Twitter users on a topic, day after day for months. Here’s what the results show, starting with some prominent people.

Dr. Angela Dunn

First, we’ll take a look at all of the replies to Dr. Angela Dunn, Utah’s state epidemiologist. Dunn’s account is new: her first tweet came Feb. 29. And at the beginning of March, Dunn’s Twitter mentions were sparse: in fact, her first reply didn’t come until March 6. But from there, it grew: people were eager to talk directly to Dr. Dunn. In one day in late June, 215 people replied to her.

And at first, people were generally really positive. Here’s one example from mid-March, a tweet that earned a +0.53 on the positivity scale:

However, as time went on, people started to blame Dunn for the problems of the pandemic, either the quarantine or the growth in cases. Where Dunn had once received 72% positive tweets, by June, she received only 42% positive tweets. People became more mean.

As you can see, Dunn got a ton of tweets on June 22 and 23, after her public health memo that warned of a “complete shutdown” if cases didn’t improve. Gov. Gary Herbert quickly responded to the memo, knocking down the idea of a shutdown, prompting more tweets to Dunn and Herbert.

Gary Herbert, Spencer Cox and Jon Huntsman

Dunn’s not the only one who had their Twitter mentions explode once the pandemic began. While Herbert averaged 33 mentions per day in the days before the virus dominated our lives, for the three and a half months since, he’s averaged 332 mentions per day. Government is more important to people during a pandemic, it turns out.

But the responses to him have stayed just under 50% positive essentially since the pandemic began. Not since March 14, the day ski resorts closed in Summit County, has Herbert received 60% positive tweets or more in a day. Herbert’s worst day, June 7, featured only 31% positive tweets.

His lieutenant governor, Spencer Cox, leads the coronavirus task force. But whether it was because of his campaign for governor or slow coronavirus growth in Utah in the first couple of months, Cox’s mentions stayed relatively positive for much of the time, peaking on May 16. When Utah’s coronavirus picture worsened, so too did Cox’s mentions. Cox’s worst day in the past couple of months came June 23, just one week before the primary election. Then, only 44% of his mentions were positive. Again, these tweets were probably a mixture of responses to the coronavirus and his close campaign against former Gov. Jon Huntsman. Cox has a nearly 11,000 vote lead as ballots are still being counted.

I was surprised to see how few mentions Huntsman had at various points of his campaign — from March 1 to March 9, for example, we could only analyze an average of 2.8 tweets per day. That’s incredibly low, and caused much of the variability early on in his positive percentage.

Once more tweets came in, there were small spikes downward that Huntsman quickly recovered from. One came in mid-May, when Huntsman went on Fox News to discuss the U.S. coronavirus investigation into China. The other came on June 8, when Huntsman first tested negative for COVID-19 after a staffer tested positive. Huntsman would later receive a positive test on June 10, which also meant Huntsman received well-wishes from the community.

The lesser number of responses to Huntsman came despite a larger Twitter following. Huntsman has almost 105,000 followers, while Cox only has 41,600. Herbert has 64,000.

Masks

The face mask conversation was one of the latest-developing in the pandemic. Only twice has the conversation about masks in Utah reached over 100 tweets per day: when the state of Utah announced that any resident could get a free mask in late April, and two months later, when the conversation about requiring masks reached a boiling point.

When Salt Lake and Summit counties required masks, Utah got a lot of positive press about the issue, from outlets like CNN and the New York Post. That drove a temporary bump in positivity. But besides that, the mask conversation has gotten increasingly negative, especially as debate raged about the mask mandate.

Note that negative tweets can still support mask wearing, they just do it in a negative way. This tweet, for example, scored a -0.71 on the -1 to 1 scale:

TestUtah

TestUtah, a public-private partnership between the state of Utah and tech companies, was announced on April 2 as a way to get more tests to Utahns. And that they did: Utah was a nationwide leader in terms of testing per-capita among states that weren’t hardest hit by the pandemic.

But questions were pretty quickly raised about TestUtah’s process, contracts and the quality of its tests, led by Tribune reporting. All of this meant that people grew skeptical, and quickly.

The sentiment analyzer used here was a pretty basic analysis tool: there are far fancier resources available in this $20 billion industry. But even just armed with the analysis equivalent of a Revolutionary War musket can be enough to give us something — a look at how public perception of the politics surrounding the coronavirus has changed over time.

As we settle in to this pandemic, our online conversations have become less positive. The debates more intense. And the case count continues to rise.