Restaurant companies should brace for a challenging period as consumers grapple with the rising costs of rent, prescriptions and car loans and take advantage of cheaper groceries to eat at home more.

That’s the verdict of Moody’s Investors Service, which on Tuesday slashed its operating-profit growth forecast for the restaurant sector and revised its outlook to stable from positive. The ratings agency is now expecting operating profit to grow 2% to 4% in the next 12 to 18 months, down from a previous forecast of growth of 5% to 6%.

“Consumers are wrestling with higher nondiscretionary spending needs, while restaurant companies face higher operating costs, predominantly labor and challenged traffic trends,” Moody’s analyst Bill Fahy wrote in a note.

Sliding sales

His comments come after a string of downbeat earnings from the sector, with the likes of Sonic Corp US:SONC, Burger King parent Restaurant Brands International Inc. QSR, +1.03% and Chipotle Mexican Grill Inc. CMG, +2.85% reporting declines in same-restaurant sales. Analysts who were warning of a restaurant recession in the summer are looking prescient right now — and agree that there is more pain to come.

Read:There’s a recession coming, and it could be the ‘worst ever’ for restaurant stocks

See also:Fear a restaurant recession? Here’s more evidence

McDonald's Struggling to Win Burger Battle

Stifel, which downgraded 11 restaurant stocks to sell in July, last week warned of the saturated and mature nature of the U.S. industry: “Investors should think about returns on invested capital (ROICs) on a ‘market-level’ basis as opposed to a ‘unit-level’ basis,” Stifel’s analysts wrote in a note.

So what’s keeping consumers away from restaurants?

“ ‘Consumers are wrestling with higher non-discretionary spending needs, while restaurant companies face higher operating costs, predominantly labor and challenged traffic trends.’ ” — Bill Fahy, Moody’s

One factor is pressure on discretionary income from the rising costs of staples such as rent, medicine and education. Then there’s the steady rise in the cost of eating out, which has come just as grocery bills are getting cheaper. The cost of food purchased for home use—that is, groceries—has fallen 2.4% in the past year, government data showed in October. That’s the biggest decline over a 12-month period since the end of the Great Recession in 2009, as MarketWatch’s Jeffry Bartash reported.

Food costs have shrunk because of a global glut in farm products such as wheat, rice, soy and corn. Then there’s the effect of U.S. producers increasing the size of egg-laying chicken flocks and cattle herds, which has helped bring down the cost of eggs, beef and milk—egg prices alone have tumbled a staggering 50% in the last year.

Don’t miss:Oreos, Trix, Coke and other famous foods are changing, but are they better?

At the same time, the cost of food away from home—takeout dinners and restaurant meals—climbed 2.4% in September from the year-earlier period.

“People need to eat, but they don’t need to go out to eat,” said Mark Kalinowski, restaurant analyst at Nomura, who said he believes there’s a “general consumer unease” that is also impacting spending habits.

Companies like Wendy’s Co. WEN, +0.30% have talked of the impacts on consumer confidence of the contentious U.S. presidential election and general civil unrest, as well as terror attacks in Europe and elsewhere.

Buffalo Wild Wings. Inc. US:BWLD said its earnings were hurt by higher wing prices, as well as the destruction caused by Hurricane Matthew, which caused severe flooding in the Carolinas in October.

“[W]hen a store is closed for three days, you take it out of the comp group,” Chief Executive Sally Smith told analysts on the company’s earnings call last week. “We had a number of stores that were closed for two days.”

McDonald’s Corp. MCD, +0.84% CEO Stephen Easterbook lamented the lack of tailwinds for the sector on his company’s recent earnings call. “If you look hard, there aren’t many tailwinds at the moment,” he told analysts. “There’s not great economic growth to help provide a lift. Consumer confidence is muted. We’re at a rather unusual stage of the election cycle. So none of that is really providing a tailwind for us.”

Competition from supermarkets

Moody’s is expecting restaurant operators to increase the use of promotions and discounts to win back diners, further crimping earnings at a time when commodity costs are historically low. Commodity deflation has already created greater competition from supermarkets, which are better able to pass higher costs on to consumers.

Already, restaurants looking to drive growth are investing in technology such as apps; using social media to reach millennials, in particular; and expanding loyalty programs. But that, too, is hurting margins and in some instances creates less interaction between customer and server.

Casual-dining restaurants—such as or Olive Garden DRI, +0.02% or Cheesecake Factory CAKE, +1.65% —are expected to hurt most, while fast-casual and fast-food restaurants—including the likes of Shake Shack SHAK, +0.76% and Chipotle as well as McDonald’s and Wendy’s—should outperform.

“Overall, the bifurcation between the better performers and laggards in each segment will continue to widen,” wrote the Moody’s analyst Fahy.

The Restaurant ETF US:BITE was up 0.3% Tuesday afternoon and has gained 2.6% on the year, while the S&P 500 SPX, -0.67% has gained 3.5%.

The Dow Jones Industrial Average DJIA, -0.30% has gained 3.3% in the year to date.

Follow MarketWatch on Facebook.