NEW YORK — U.S. stocks climbed Friday after a two-day slide, as consumer shares rebounded amid data showing household purchases rose the most in three months. Biotechnology shares extended losses, weighing on the Nasdaq Composite index.

NEW YORK — U.S. stocks climbed Friday after a two-day slide, as consumer shares rebounded amid data showing household purchases rose the most in three months. Biotechnology shares extended losses, weighing on the Nasdaq Composite index.

H&R Block and GameStop climbed at least 6.2 percent, leading gains among consumer shares. Cognizant Technology Solutions rallied 4.4 percent after Morgan Stanley raised its recommendation on the stock. The Nasdaq Composite almost erased a 1.3 percent rally as Gilead Sciences and Biogen Idec tumbled more than 4 percent, capping the week’s sell-off in riskier assets.

The Standard & Poor’s 500 index added 0.5 percent to 1,857.62, trimming its loss for the week to 0.5 percent. The Dow Jones industrial average rose 58.83 points, or 0.4 percent, to 16,323.06 today. The Nasdaq Composite increased 0.1 percent to 4,155.759, completing the week with a 2.8 percent drop.

"It’s been a choppy market," Mike McGarr, a portfolio manager at Becker Capital Management in Portland, Ore., said by phone. The firm oversees $2.8 billion. "There has been a very noticeable change this month, away from those sorts of high flyers, and back toward value. It’s nice to see the market coming back to more fundamentally real stories."

Investors have been selling the bull market’s biggest winners, locking in gains as they assess how much of the recent economic weakness is weather-related and if the situation in Ukraine will worsen.

The Nasdaq Biotechnology index slumped 2.8 percent Friday, pushing its loss this week to 7 percent. The gauge rallied 79 percent in the 12 months through February. The Russell 2000 index fell all but one day this week for a 3.5 percent decline. The measure for smaller companies is down 1 percent this quarter, poised to snap a six-quarter streak of gains, the longest stretch since 1996.

Gilead, the world’s largest maker of HIV medicines, sank 4 percent Friday to $68.55. Biogen Idec, maker of the multiple sclerosis drugs, tumbled 5.1 percent to $294.12.

Money is flowing to large companies with stable earnings. Microsoft surged 2.4 percent today to $40.30 for the biggest gain in the Dow. Energy shares climbed 1.2 percent while Exxon Mobil added 1.5 percent to $97.70.

Consumer-discretionary shares rallied 0.8 today as data showed household spending in the U.S. rose in February by the most in three months as incomes increased.

Americans were shaking off the effects of the coldest winter in four years as they ventured out to shop, supported by a job market that’s also picking up speed.

Separate data indicated consumer confidence fell less than previously estimated in March.

"If consumers go back in and are confident enough to start spending again, that supports earnings and will certainly support the equity market," Chris Gaffney, senior market strategist at EverBank Financial in St. Louis, said by phone. "I feel like we’re forming a base that we can move high now."

The Chicago Board Options Exchange volatility index, a gauge for U.S. stock volatility known as VIX, retreated 1.4 percent to 14.41. About 6 billion shares changed hands on U.S. exchanges, 12 percent below the three-month average.

Consumer stocks in the S&P 500 rebounded from a five-day slide. H&R Block, the biggest U.S. tax preparer, climbed 6.2 percent to $30.36 while GameStop, a video-game retailer, advanced 8.8 percent to $40.62.

Restoration Hardware Holdings surged 13 percent to $71.93. The home-furnishings retailer forecast that adjusted profit will be between 9 cents a share and 11 cents in the first quarter, compared with analysts’ estimates for 6 cents. It said annual profit will be as much as $2.22 a share, beating the average projection for $2.18.

Cognizant gained 4.4 percent to $49.69. The provider of consulting and outsourcing services was boosted to overweight, an equivalent of buy, by Morgan Stanley. The company’s growth potential may have been under-estimated, analyst Katy Huberty wrote in a note.

PG&E fell 4 percent to $41.89. Charges to be filed by the U.S. Attorney’s office will accuse the company of violating the federal Pipeline Safety Act, leading to the explosion and deaths, according to a company statement. PG&E didn’t say when it expects the charges to be filed, and said it believes they aren’t merited.

Red Hat slipped 7 percent to $52.23. The largest seller of Linux operating-system software said it expects to earn $1.56 a share this year. That trailed the average analyst estimate of $1.62 in a Bloomberg survey.

BlackBerry dropped 7.1 percent to $8.41. The smartphone maker said sales won’t grow until the fiscal year that begins next March, even after cost-cutting helped the company post a smaller quarterly loss than analysts estimated.

- - -

With assistance from Corinne Gretler in Zurich.