NEW YORK, Feb 27 (Reuters) - U.S. stocks rose on Thursday after comments from Federal Reserve Chair Janet Yellen offered some relief to investors worried about the central bank’s tapering of economic stimulus.

Tech shares, including Apple Inc, helped lead the advance, which pushed the S&P 500 above the 2013 year-end closing level and within points of surpassing Monday’s intraday record high. The gains lifted the benchmark index into positive territory for the year.

Addressing the Senate Banking Committee, Yellen said the Fed would be on alert to make sure that recent signs of economic weakness are due to cold weather and storms, rather than a more fundamental slowdown.

“Yellen came in and did exactly what she was supposed to do, and said, ‘Listen, the weather is still a variable.’ But she made it clear the Fed is ready to stand up and do what’s necessary to continue to support the economy, and that’s exactly what Wall Street wanted to hear,” said Adam Sarhan, chief executive officer of Sarhan Capital in New York.

The theory that some recent lackluster data was due to the weather rather than worsening fundamentals had helped investors shrug off the recent weak economic numbers.

Retailers ranked among the top gainers for a third session, with the shares of both J.C. Penney Co Inc and Best Buy Co Inc jumping after the companies posted strong results. Late Wednesday, J.C. Penney forecast more improvement in its comparable sales and gross profit margin this fiscal year. On Thursday, Best Buy reported adjusted earnings that topped forecasts.

Among other big gainers, shares of Mylan Inc rose 10.1 percent to $56.59 after the U.S. generic drugmaker gave a 2014 forecast above Wall Street’s estimates and said it plans to make a “substantial” transaction this year that would add to future earnings.