Tweets and other social media posts could be used to spot early warning signs of influenza, depression, and other health issues in a specific area, according to new research.

This means problems can be identified and dealt with as soon as possible, whether or not people are visiting their doctors for check-ups – and the data crunching even works on tweets that don't specifically mention illness.

It's all to do with the sentiment behind the tweet, says the team from the Pacific Northwest National Laboratory (PNNL), and the way people act differently on social media when they're not feeling well.

"Opinions and emotions are present in every tweet, regardless of whether the user is talking about their health," says lead researcher Svitlana Volkova. "Like a digital heartbeat, we're finding how changes in this behaviour relate to health trends in a community."

You're probably already aware of the way marketers mine data in public tweets to bombard you with adverts for toothpaste or running shoes, but the same tricks can be used to find evidence of sickness too.

tweets sad faceCredit: PNNL

The researchers looked at 171 million anonymised tweets associated with the US military: military personnel, their families, and people living near US military bases. This gave a large sample of both military and civilian tweeters, including six international locations and 25 locations in the United States.

While this isn't the first study to look at relationships between tweets and illness, it goes a step further by looking at the underpinning sentiments rather than any direct reference to being unwell.

Machine learning algorithms and natural language processing were used to drill into the collected data and to work out the types of emotion being expressed based on the words – and of course the emojis – used in the tweets.

Regardless of health, tweets from military populations were found to contain more negative opinions, and increased emotions of sadness, fear, disgust, and anger.

There were also correlations with health issues, but the patterns varied by location and between groups.

The researchers did spot links between a higher number of flu-related check-ups and a higher number of tweets expressing neutral opinions and sadness. During times of better general health, meanwhile, positive opinions, surprise, and anger were expressed more.

If these data mining techniques can be developed further, social media posts could eventually give us a much more accurate way of monitoring the health of a community, rather than the existing system of logging the number of visits to the local doctor.

At the moment it can take weeks before an outbreak of flu is discovered, so getting an earlier warning would be most helpful.

The next step for Volkova and her team is to see if tweets can actually predict particular patterns of health ahead of time. Other data, such as web searches for a certain illness, have also been shown to be useful.

It's not an exact science at the moment, but it seems that your tweets could be revealing more than you think about how you're feeling – especially when analysed across a large section of the population.

The findings have been published in EPJ Data Science.