No mentorship is perhaps more vital and sensitive than that between a teacher and their student.

So retaining a low student-to-teacher ratio — the number of students for every one teacher — is heralded by many parents and experts as one of the most important ways to foster that relationship.

But an analysis of 10 years of data found that the number of teachers in Massachusetts public schools is highly responsive to changes in the economy, leading to a fluid student-teacher ratio.

From the 2006-07 school year to 2010-11, the number of teachers hired by public school districts in the state went down by more than 4,400. That number has since bounced back, almost to where it was before the recession severed jobs nationwide.

According to nine education experts, school administrators and former state officials, the fraught economics of the mid-2000s recession are mainly to blame for the loss in educators. A number of reasons, including a rejuvenated economy and the prioritization of special-needs education programs, accompanied the boost in teachers.

Less explainable? A drop in enrollment by more than 15,000 students over the five years from 2006-07 to 2011-12. Experts said private school enrollment or a declining birth rate could be a factor, but an analysis found no definitive reasons for why enrollment has dipped, and failed to rebound.

Budgetary pitfalls

Public schools in the commonwealth are funded by a combination of local and state taxes. A perfect storm of economic hardships and legislative decisions last decade led to a decline in public school funding and, in turn, the loss of thousands of teacher jobs, data and budget research shows.

And school districts are still recovering.

"Many school districts, public school districts, particularly those in working-class areas, were hit hardest by the Great Recession and began to lay off teachers," said Travis Bristol, a Boston University education professor who has studied educational leadership and policy.

"Even the talk of a hiring freeze or a potential layoff make it more likely for people to think about other professions."

The state's public schools, including charter schools, hired a total of 68,754 teachers in the 2010-11 school year, down from 73,176 four years earlier, according to data provided by the Massachusetts Department of Elementary and Secondary Education.

In fiscal 2007, before the brunt of the recession hit, the Legislature altered the way the state calculates aid for public schools — known as Chapter 70 aid. Those 2007 reforms aimed to increase funding for schools through several smaller steps, according to the Massachusetts Budget and Policy Center.

But as the recession hit, those reforms — which were planned to be phased in over five years — were slowed down, and didn't take effect as they were supposed to. Chapter 70 aid was actually cut "across the board" from 2009 to 2011, according to MassBudget.

And in fiscal 2010, the state calculated education funding using a lower inflation factor than required by state law, MassBudget said, meaning public schools got less money than usual. The federal government had to step in and provide stimulus provisions to protect some districts.

The main victims from this, the data shows, were teachers.

"Any time there's a downturn in financing available to schools districts, typically they're going to have to lay off people," said Paul Reville, the state secretary of education from 2008 to 2013. "And the largest category of people districts hire is, of course, teachers."

Laura Chesson, the superintendent of Groton-Dunstable Regional School District, said she knows "for a fact" that the district endured financial difficulties last decade.

"All districts in Massachusetts did during the recession," she said. "Groton-Dunstable was no different."

The district lost more than 30 teachers during and after the recession — a significant number for a relatively small district that employs less than 200 teachers.

But perhaps nowhere was this trend more present than in Lowell Public Schools, which lost 182 teachers from 2006-07 to 2010-11. Anne Sheehy, Lowell's director of human resources, personnel and recruitment, also said that was most likely budget-related.

The drop in teachers might not have been solely because of budget-based layoffs. Rather, public school teachers who retired over that time period might not have been replaced as they usually would have, said Kenneth Ardon, the chairman of the economics department at Salem State University.

"There are probably a fair number of teachers who just retire every year," Ardon said. "That's how I think most districts would prefer to deal with it. They'd rather not lay people off."

The poor economics of the mid-2000s could have led some teachers to change professions, or discouraged them from entering teaching in the first place.

"It's a more subtle thing that happens ... the working conditions become such that people say `I can't do this,'" said Barbara Madeloni, the president of the Massachusetts Teachers Association union. She added that a climate heavily focused on testing, as well as funding struggles, could have contributed.

More "substitute jobs" might have also been available for those who would have otherwise taught, according to Harvard University education professor Ebony Bridwell-Mitchell, "jobs offering similar salaries and benefits — material, psychic and social."

A spokesperson for the state education department said they have not studied the trends in the data for teachers.

Fewer teachers, fewer students

The drop in teachers had an effect on the student-teacher ratio over the course of the recession. The average ratio statewide rose from 13.2 in 2006-07 to nearly 14 in 2010-11.

The change does not seem overly dramatic since the number of students and teachers decreased by a similar rate over that same time period.

Enrollment statewide dropped from 968,661 in 2006-07 to 953,369 in 2011-12. But it has not rebounded strongly. Last school year, total enrollment sat at 953,748.

Smaller districts, especially several in the Merrimack Valley, were hit especially hard by an enrollment decline.

The number of students in Chelmsford Public Schools went down more than 11 percent from 2006-07 to last year — 644 fewer students. In nearby Tyngsborough, more than 500 fewer students attended public school in 2016-17 than they did 10 years ago.

Similarly, the Groton-Dunstable district has seen an overall decrease in enrollment by 512 students over the past 10 years, despite a slight uptick last school year.

Chesson, the superintendent, said the high schools in the district have received less foreign exchange students, a trend she said has reverberated statewide.

"There are a number of social and political reasons for that to be the case," she said. "Just about every school in the commonwealth that takes foreign exchange students has been experiencing the same thing."

Another potential reason for the decrease is that people have simply been having fewer children. Ardon said Massachusetts saw a drastic increase in enrollment as baby boomers' children went through school, but it plateaued as they grew older.

Birth rates, Reville said, are often used as a way to predict enrollment and prepare for changes.

"Generally speaking, enrollments in schools are going to reflect birth rates five or six years beforehand, and then catch up over time," he said. "We can pretty well predict who's going to be in school if we assume a certain level of immigration, and then if we look at how many children are born in a community."

Another possibility for the decrease in public school enrollment, some experts said, is a rise in students going to private school.

In Lowell, enrollment dropped by more than 350 between 2006-07 and 2011-12, but has seen a major increase since then — contrary to the state trend. Sheehy attributed that to a "concerted effort" by the district to bring back students who had special needs and had been going to school out of the district.

Bouncing back

As the economy leveled out, revenue for public schools increased, allowing them to hire more teachers.

Since 2010, Lowell has hired more than 100 teachers, accompanying the rise in students with special needs.

"We are bringing back students that were previously out of district, in placements for special-education students," Sheehy said. "Those students are typically in classrooms with a smaller number of children. They do require additional specialized teachers to fit their needs."

This year, she said, Lowell opened a separate schooling program for students with autism.

"We need to make sure that we have teachers that meet our students' needs," she said, "so that trend makes me happy."

Groton-Dunstable was also able to hire several more teachers after the recession, and hit a student-teacher ratio of 13.8 last year, its lowest of the decade.

The state's total number of public school teachers reached 72,090 last year (just 1,086 less than it had 10 years ago), and its average student-teacher ratio returned to where it was before the recession.

For certain students, keeping a low student-teacher ratio is especially important at various points in their education, said Reville, the former education secretary.

"In primary reading for low-income and disadvantaged students lower ratios seem to make a difference," he said, adding that "it's simply easier for a teacher to work with fewer students than to work with more."

But he said sometimes, the public tends to overestimate the impact of a low student-teacher ratio.

"Parents typically tend to care deeply about student-teacher ratio," he said. "From a research standpoint, student-teacher ratios don't appear to be nearly as important as some people think they are."

Ardon said the changes over the last 10 years could have still had an impact on individual classrooms, due to the high level of fluctuation and teacher turnover.

"If you have a lot of experienced teachers leaving and then being replaced by new teachers you're losing a lot of experienced teachers with a lot of skills," he said. "That happens every year; this might have just expanded the process just a little more dramatically [than] in a normal year."