NEW YORK — Consumers may not be confident, but the stores that sell to them certainly seem to be.

Walmart and Home Depot, two of the nation’s largest retailers and bellwethers of the U.S. economy, on Tuesday joined a string of other merchants that have raised their outlooks for the year despite a flow of bad economic news that suggests they have no reason to be optimistic.

TJX Cos., which owns TJ Maxx and Marshall’s, Macy’s Inc., Kohl’s Corp., and Nordstrom Inc. have all boosted their profit outlooks in the past week.

Retailers’ results are a closely-watched barometer of how willing Americans are to loosen their purse strings, which is important since consumer spending accounts for 70 percent of the economy. But at a time when families are being squeezed by higher costs, high unemployment, scant pay raises and a weak housing market, the positive forecasts seem to fly in the face of other indicators.

“It’s cautious optimism. Retailers want to be optimistic but they know consumers can turn on a dime,” said Wall Street Strategies analyst Brian Sozzi.

Merchants want to avoid a repeat of the aftermath of the financial crisis in 2008 when shoppers pulled back so much that revenue and profits suffered and some were forced to close their doors. Merchants are better positioned to weather a severe downturn now, but the recovery has been painfully slow for many Americans who still feel like they’re living in a recession.

Consumer sentiment hit a 31-year low in August, according to a key survey completed last week, as stock market turmoil and political strife over raising the federal debt ceiling shook already nervous shoppers. And the International Council of Shopping Centers-Goldman Sachs index has shown three consecutive weeks of declines.

Still, consumers spent more on cars, furniture, electronics and other goods in July — and more in May and June than previously thought.

Walmart posted a 5.7 percent second-quarter profit increase due to strong international sales growth and cost cutting.

Home Depot reported that its second-quarter profit rose 14 percent, with strong sales of lawn and garden products and people making storm-related repairs.