Skip to main content

Leshner Fellow Lyle Ungar Uses Twitter to Predict Our Physical, Mental Health

Lyle Ungar
Lyle Ungar. Credit: Photographer Felice Macera, University of Pennsylvania

Deep in an office in West Philadelphia sits a scientist who takes great interest in the most mundane rhetoric on social media, from a nonchalant tweet about eating lunch alone to an expletive-laced tirade about public transportation.

Each word we type – be it self-deprecating, angry or joyous – helps researcher Lyle Ungar unravel the fabric of our lives, including job satisfaction and health conditions.

After all, we are what we tweet.

“You can predict mortality from heart disease better from the language of Twitter than you can from all sorts of other things, including age, smoking or diabetes,” says Ungar, a professor of computer and information science at the University of Pennsylvania.

This year, Ungar is participating in public engagement and science communication training as a AAAS Alan I. Leshner Leadership Institute Public Engagement Fellow in the field of artificial intelligence. He was selected for his use of machine learning and text mining on social media to study physical and mental health.

In a culture of oversharing, our tweets provide unfiltered windows into our souls and key insights into public health. The data are arguably less biased – and less expensive to harvest – than traditional survey responses.

When overlaid with localized health and U.S. Census statistics, trends emerge between frequently tweeted topics and rates of depression, anxiety and disease-related death, for example.

In one study, Ungar and his team evaluated the words – down to the emoticons – from millions of tweets using self-reported Twitter bio information to map users to specific U.S. counties.

Trends in word usage were then overlaid with location-based data on heart disease mortality from the Centers for Disease Control and Prevention. The prevalence of words indicative of hostility and stress – known risk factors for heart disease – correlated with community-level death rates from the condition.

Ungar says his method is simple and easy to replicate, describing it as a “fancy linear regression” with words as features capable of predicting mortality.

The initial results for Ungar’s research confirmed ties between poorer populations and increased heart disease rates. For example, communities tweeting about their fun jobs, personal trainers and robot vacuums showed a lower likelihood of heart disease-related death.

After controlling for socioeconomic factors, Ungar discovered underlying psychological correlations. Communities tweeting about boredom, anger or fatigue – paired with increased profanity – saw greater heart disease fatalities than communities with more optimism and posts about overcoming challenges.

Such findings can provide valuable insight to governments and organizations looking to improve the welfare of citizens, exemplifying the mission of the World Well-Being Project, where Ungar is the principal investigator.

When the COVID-19 pandemic emerged, his team hustled to leverage the real-time power of Twitter to measure shifting anxieties, perceptions and symptoms of the virus reflected in a state-by-state live map. Tweets revealed interesting and surprising aspects of COVID-19 infections that were little talked about during the time period. 

“Before it showed up in the New York Times, people were tweeting about COVID toes,” Ungar says, referring to an unusual foot rash linked to the virus. “It first showed up on social media.”

Lyle Ungar
Lyle Ungar.

Ungar hopes his models can be a resource for local governments to inform messaging around contact tracing or the importance of face coverings. If public health officials better understand the moods and behaviors of locals, they can deploy more targeted interventions.

“There are many reasons not to wear masks – all of them bad – but if you wish to address the issue of mask-wearing, you need to understand it,” Ungar says. “This is a public health crisis. Social media can help us grasp a very rapidly changing norm.”

The methods and insights gleaned from community-level analysis, he adds, can also be applied to help individuals.

By exploring trends in the words used by recovering drug addicts on social networks, Ungar hopes even their phones will eventually be able to predict future relapses and proactively intervene before it’s too late. Doctors or patients, Ungar says, could be notified when patterns of language indicate certain conditions, such as depression or suicidality.

As a Leshner Fellow, Ungar aspires to improve his communication strategies when it comes to interacting with busy public health officials, helping them leverage his findings to make a positive mark on society.

This idea of using digital data for public good may seem contrary to headlines about the dearth of information privacy over the last several years. But Ungar plays by the rules, requesting individual consent to monitor Facebook posts and text messages, which – unlike Twitter posts – aren’t publicly available.

Meanwhile, he notes, big tech companies constantly analyze our media consumption and behaviors to serve us the right ads for the right products at the right time.

“But nobody is selling me friendship – or a walk to enjoy the sunshine,” Ungar says. “I’d like to take the same techniques Google uses to sell you products and use them to promote happiness, well-being and social connection. Every tool can be used for good and evil.”

Blog Name


Lauren Boyer