Gun violence at schools increases when jobs disappear, according to a new investigation of school shootings that took place between 1990 and 2013. This troubling relationship means that more, not less funding should go to schools and communities during economic downturns to prevent and protect against possible attacks, the authors of the study say.

Adam Pah, a research professor at Northwestern University, decided to study gun violence at schools when the school where his mom works erected bullet-proof glass around her desk. Was there some trend or risk factor, he began to wonder, that he could use to predict when someone was more likely to pick up a gun and head to the nearest school?

What predicts when someone’s more likely to pick up a gun, and head to the nearest school?

His research revealed that economic insecurity, especially high unemployment, seems to be linked to an increase in school shootings, according to results published this week in Nature Human Behaviour. But whether a dip in the economy actually causes that increase, and why, is still a mystery. It might be a challenging one to solve, since there could be many different causes that underlie the range of school shootings — from targeted, non-fatal attacks to mass shootings with multiple fatalities, the Associated Press reports.

Despite a glut of media coverage, it’s difficult to tally how frequently school shootings take place. That’s because in 1996, Congress blocked the Centers for Disease Control and Prevention from funding research that might “advocate or promote gun control.” In 2012, the ban extended to the National Institutes of Health — although they continue to fund research in this field. In 2015, the Republican majority Congress reaffirmed the funding bans.

So professors Pah and Luis Amaral, another professor at Northwestern, along with a team of undergraduate researchers, combed through 535 shootings across six different data sets. (Amaral says they used unrestricted funds for this.)

It’s difficult to tally how frequently school shootings take place

The pickings were slim: one of the datasets came from Wikipedia, and another from Slate. Even after the researchers confirmed the information for each of the shootings, there was a problem: “We started reading through all of these events and we quickly realized that one of the biggest problems is that it’s not clear what gun violence at schools should mean,” Pah says.

So they created a new dataset, in which each shooting had to meet three key criteria: A gun had to go off, even if by accident; it had to take place on school grounds; and students or employees at the school had to participate in some way — as victims, bystanders, or the shooters. If two people agreed that a shooting matched all three criteria, into the database it went. By the time they were done, they’d whittled it down to 379 shootings at elementary, middle, and high schools as well as at colleges. They’ve published their dataset online.

When the researchers plotted school shootings over time, they saw that there’s been an overall increase from 2007 to 2013, driven by a jump in shootings at colleges. The number of shootings at K12 schools have, overall, stayed fairly steady, despite increases in school security. Still, Pah and Amaral noticed massive variation in the numbers of shootings from year to year. At first, they thought that the ebbs and flows of gun violence at schools might track with rates of gun ownership. But they didn’t find a correlation.

“One of the biggest problems is that it’s not clear what gun violence at schools should mean.”

They did, however, find a link between years with higher unemployment rates, and years with more school shootings. What’s more, they found that as the national unemployment rate rises, the time period between these shootings shrinks. When they took a more granular view of the unemployment rate first regionally, and then in cities across the US, they found the same thing: Periods of higher than average unemployment tracked with more shootings at local schools. That means that even when the national unemployment rate decreases, pockets of the US where unemployment is still high might still remain at risk for a rise in school shootings.

Amaral and his colleagues speculate that one reason for the connection they see could be that economic insecurity causes more students to get lost in that school-to-work transition. “You’re chasing the carrot and the carrot gets ripped out from in front of you,” Pah says. “The amount of demoralization and disillusionment that that induces is disproportionate than at any other point.”

“The study is well done and quite interesting,” Richard Rosenfeld, a professor of criminology at the University of Missouri, St. Louis, told The Verge in an email. “My primary comment is that the authors do not show that economic conditions drive school shootings specifically, as opposed to firearm violence in the US more generally.” Other studies suggest that the homicide rate and violent crime have a complicated relationship with the economy that has been difficult to interpret. More research needs to be done. But the question remains, who will pay for it?