It has been an ugly couple weeks in the stock market. Share prices have swung wildly, to levels down about 8 percent at midweek from the summer's all-time highs.

Anyone who owns stocks is on high alert. No one can forget the dizzying collapse in stock prices during the financial crisis. It is reasonable to worry about a repeat now. It's especially disconcerting for baby boomers who are quickly approaching retirement and watching their nest eggs get smaller.

What should you do in response to the market's slide? Your instinct may be to run for the hills and sell your stock portfolio. That would be a mistake. Your best course of action is simply to do nothing.

Why? If you've invested in stocks, you should be committed to that investment for at least several years. Stock prices can go way up and way down, even in a single day, but over a five-year period this volatility gets ironed out and prices generally end up higher.

The value of a company's stock is ultimately tied to its profits. Profits depend on a company's sales, which are driven by the broader economy. The economy clearly doesn't move in a straight line, but more often than not it grows. Indeed, a good adage to invest by is: Never bet against the American economy.

And this isn't the time to be giving up on our economy. Consider that nearly three million jobs were created over the last year. The last time so many jobs were created in a year was at the height of the technology boom in the late 1990s. The economy - and thus businesses' sales, profits, and stock prices - are on very solid ground.

Worries that the stock slide could undermine the economy are misplaced. I'm reminded of Nobel Prize-winning economist Paul Samuelson's quip that "the stock market has predicted nine of the last five recessions." I don't think this stock sell-off signals anything about the U.S. economy's future health.

To be sure, China's economic slowdown is a weight on the global economy. China is struggling with lots of debt, a corruption crackdown, and a broken environment. The bursting of its stock market bubble has overwhelmed Chinese authorities, and they have bungled efforts to revive the economy by reducing the value of their currency.

But there is no indication that the Chinese economy is caving, certainly not to the extent that it seriously threatens the U.S. economy or warrants a deep and prolonged decline in U.S. stocks.

Prospects that the Federal Reserve will soon raise interest rates may also be a factor in the stock sell-off. The Fed has kept rates near zero since the recession struck. If the Fed feels comfortable raising rates, however, it would indicate the economy is finally returning to full employment - that is, anyone who wants a job or more hours can find them. That can't be bad for stocks.

Investors in the stock of energy companies have lots of agita over the collapse in oil prices in the last year. Energy stocks had been high fliers, leading the broader stock market's rise. But while lower energy prices hurt these companies, they benefit everyone else, especially companies that use lots of energy and all of us who fill our gas tanks each week. Lower energy prices are a big plus for our economy, and eventually also for the stock market.

It is also important to put the current stock market decline into a broader historical context. A 10 percent decline in stock prices isn't unusual, especially after a long period of strong price gains like the threefold increase we enjoyed between the market's bottom in the last recession and this summer's peak. So far, at least, the market's recent decline is nothing more than a garden-variety correction.

One could even argue that what has happened is somewhat therapeutic. Fed Chair Janet Yellen had done some public hand-wringing about high stock prices. She was openly nervous that the market was overvalued. The last thing she wanted was the market to turn into another bubble that would burst and hurt the economy. Well, that no longer appears to be a threat.

Of course, the script is still being written. The stock market could fall further, perhaps because China's problems are more serious than we know, or simply because the stock-selling begets more selling. Investors may not follow my advice to hold on to stocks. They may be overtaken by fear and dump them.

Though possible, that doesn't seem likely. There are no guarantees, but if you keep your head you should ultimately be rewarded.

Join me at the Union League at 4 p.m. Tuesday to discuss the stock market turmoil and prospects for the global and Philadelphia economies in support of Students Helping Students, a nonprofit that fosters educational equity in Philadelphia.

Mark Zandi is chief economist at Moody's Analytics in West Chester.