(CNN) An important transition is happening across the United States: Cancer was the leading cause of death in more counties in 2015 than 13 years earlier, a new study finds. However, the opposite was true for heart disease during that period; fewer counties reported it as the top killer.

In fact, cancer will replace heart disease as the leading cause of death in the United States within two years, according to US Centers for Disease Control and Prevention projections referenced in the study, published Monday in the medical journal Annals of Internal Medicine.

"We're just on the cusp of the transition from heart disease to cancer as the leading cause of death," said Dr. Latha Palaniappan, lead author of the study and an internist, professor and clinical researcher at Stanford University Medical Center.

Shifts in socioeconomic, ethnic groups

A decades-old theory described a shift that occurred in health and disease patterns in the United States during the last century. Early in the 100-year period, infectious diseases including tuberculosis, diphtheria and flu took more American lives than other illnesses. Yet by the end of the century, chronic diseases, including heart disease and cancer, had become the leading cause of death. The theory described these complex patterns and suggested that such shifts stemmed from economic and social conditions.

Recent data suggests that the nation is experiencing a new transition, this time within the chronic disease category itself. To understand these changes, Stanford Medical School researchers examined more than 32 million death records across 3,143 American counties for 2003 through 2015. The research team looked not only at medical information but at demographic data, including income and race.

Over the 13-year study period, the mortality rate decreased in the total population by 12%, from about 823 deaths per every 100,000 people to roughly 724 deaths per 100,000.

In more than three-quarters of all counties (79%), heart disease was the leading cause of death in 2003, yet this remained true for only 59% of counties in 2015.

By contrast, cancer caused the most deaths in about two of every 10 counties during 2003, with the same true for four of every 10 counties in 2015.

While the overall heart disease mortality rate decreased by 28%, high-income counties experienced a 30% drop, versus a 22% fall in low-income counties. The cancer mortality rate also dropped, though less dramatically: It declined by 16%, with an 18% drop seen in high-income counties versus 11% in low-income.

According to the researchers, lower-income areas may see a slower shift in the cause of death due to socioeconomic, geographic, demographic and other factors that influence health and death.

The researchers also compared shifts in patterns for racial and ethnic groups. Here, they found that among Asian-Americans, Hispanics and whites, cancer replaced heart disease as the leading cause of death. However, a similar pattern was not seen among American Indians/Alaska Natives or blacks.

Economic factors also affect the new pattern of mortality rates across the nation. Heart disease surpassed other causes of death in the lowest-income counties for all racial and ethnic groups during 2015, the researchers found, yet only Asian-Americans, Hispanics and whites in the highest-income counties saw cancer outpace heart disease as the leading cause of death in 2015.

Making improvements in cancer care available to all

The research "provides another lens" for interpreting dynamics related to the transition in mortality patterns, wrote Silvia Stringhini, a researcher at Switzerland's Lausanne University Hospital, and Dr. Idris Guessous, a practicing physician and epidemiologist at Switzerland's Geneva University Hospitals, in an editorial published with the study.

"The driving force behind the transition from the age of 'pestilence and famine' to the age of 'manmade diseases' is improvement in socioeconomic conditions, such as standards of living, health habits, hygiene, and nutrition," Stringhini and Guessous wrote.

How genetic testing, screening and personalized medicine affect cancer rates is still unclear, they noted. New and expensive cancer therapies are being introduced, yet they might contribute to "increasing social inequalities in cancer survival, with better-off persons experiencing more rapid decreases in mortality," they added. And the same may be true of genetic testing and cancer screening, they noted.

It's likely that any differences in mortality trends could be explained by differences in smoking, obesity and diabetes trends among high and low income groups, the authors stated. "For example, between 1960 and 2015, the prevalence of smoking in the United States decreased from 39% to 6% among college graduates but from 46% to 23% among persons who did not complete high school," they wrote.

With cancer about to overtake heart disease as the leading cause of death, what do most Americans need to know?

Get CNN Health's weekly newsletter Sign up here to get The Results Are In with Dr. Sanjay Gupta every Tuesday from the CNN Health team.

"Undergo all of the recommended cancer screenings," Palaniappan advised, and adopt "lifestyle prevention practices, such as healthy diet and exercise, which are beneficial in lowering both cancer and heart disease mortality."

"The investments in research in both heart disease and cancer have paid off over the last decades because both heart disease and cancer rates are going down," she said. "Without all of the wonderful new therapies that we have now, this would not have happened."

Still, there's more work to be done, she said: "We need to work harder in lower income areas of the US so they can see the same improvements in mortality. We need to focus more on heart disease and cancer prevention and treatment efforts in African-American populations particularly."