By Anora Mahmudova and Barbara Kollmeyer, MarketWatch

S&P 500, Nasdaq book modest weekly gains

U.S. stocks ended Friday's choppy session modestly lower, though the S&P 500 and Nasdaq Composite Index booked modest weekly gains.

On Friday, stocks sold off toward the end of the session, after Federal Reserve Chairwoman Janet Yellen said she still expected the central bank to raise interest rates sometime this year, as a part of a speech delivered in Providence, R.I., discussing the U.S. economic outlook.

The S&P 500 (SPX) closed 4.76 points, or 0.2%, lower at 2,126.06, but gained 0.2% over the week. The Dow Jones Industrial Average (DJI) closed 53.72 points, or 0.3%, lower to 18,232.02 and ended the week with a 0.2% loss. Meanwhile the Nasdaq (RIXF) ended the session 1.43 points lower at 5,089.36, but posted a 0.8% gain over the week.

Stocks were already weaker in early trade after a stronger-than-expected reading of a measure of price inflation. An increase in the consumer-price index along with the improving labor market gives the Federal Reserve reserve ammunition to raise interest rates sooner than later, even as minutes from the most recent meeting of the Federal Open Market Committee seemed to suggest that a June rate hike was unlikely.

Yellen's comments on Friday added support to the view that Fed is preparing to hike rates sometime this year, if not as early as June, despite economic reports that have at times suggested that the U.S. economy wasn't on the firm economic footing after the Great Recession.

Similar to previous remarks, Yellen in her Friday speech (http://www.marketwatch.com/story/yellen-unmoved-by-soft-data-says-she-expects-rate-hike-this-year-2015-05-22)referred to a string of weak economic data as "transitory." The U.S.'s central bank boss stated that economic signs looked strong enough for the Fed to hike rates this year, followed by gradual moves thereafter.

Maris Ogg, president at Tower Bridge Advisors, said the market is digesting the possibility of a rate hike this year pretty well. "At this point investors know that a rate increase means an improving economy. A 25 or 50 basis point increase will not affect the companies or the economy much and starting from zero means it will take a while before rates start having a negative effect on markets," she said.

"The second half of this year will show us whether housing and capital expenditures really pick up and whether that will drive earnings in 2016," Ogg added.

As long as bond yields are moving sideways or lower, equity investors are "happy putting money to work," said Chris Weston, chief market strategist at IG, in a note. He added that the CBOE Volatility index (VIX) is testing the year's lows around 12.11%, and is now 33% below the five-year average.

U.S. consumer prices (http://www.marketwatch.com/story/housing-healthcare-behind-strong-rise-in-core-inflation-in-april-2015-05-22) rose a seasonally adjusted 0.1% in April, according to the Labor Department. Energy prices slumped 1.3% last month while food prices were unchanged. The core CPI, which excludes volatile food and energy costs, jumped 0.3%, driven by another increase in housing expenses and a gain in medical care costs.

In corporates, (http://www.marketwatch.com/story/why-consumers-are-so-cautious-2015-05-19)shares of Deere & Co.(DE) are up 4.4% after financial results. Campbell Soup Co. (CPB) profit beat expectations (http://www.marketwatch.com/story/campbell-soup-profit-beats-views-while-sales-slip-2015-05-22), but sales slipped. Shares rose 2.1%.

Shares of Hewlett-Packard Co.(HPQ) rose 2.8% after earnings squeezed past forecasts late Thursday, but the company also provided a cautious outlook.

Marvell Technology Group Ltd. (MRVL) fell 8.6% after the chip maker late Thursday after announced its chief executive will retire.

Expedia Inc.(EXPE) shares jumped 6.7% after the travel booking company said it sold its majority stake in eLong Inc. to a group of buyers for $671 million.

For more on notable movers read Movers & Shakers column (http://www.marketwatch.com/story/campbell-soup-deere-foot-locker-earnings-in-focus-2015-05-21).

Other markets: European stocks finished slightly lower on Friday, but booked the best weekly gain in six weeks. Asia stocks rose with the Shanghai Composite Index (http://www.marketwatch.com/story/china-shares-hit-seven-year-high-2015-05-21) marking its best performance since 2008.

Oil prices (http://www.marketwatch.com/story/oil-holds-onto-recent-gains-wti-trades-above-60-a-barrel-2015-05-22)(CLN5) fell 1.7%, to settle at $59.72 a barrel, the same level prices settled a week ago. Gold prices (GCM5) lost 10 cents to end at $1,204 an ounce, recording their first weekly loss in three weeks (http://www.marketwatch.com/storyno-meta-for-guid). The dollar (DXY) rose against the euro (EURUSD), booking its first weekly gain in five weeks (http://www.marketwatch.com/story/dollar-slips-against-yen-as-investors-await-boj-kuroda-remarks-2015-05-22).

Subscribe to WSJ: http://online.wsj.com?mod=djnwires