(Fortune Magazine) -- Tucked away in the briefcase of Liz Ann Sonders, chief investment strategist at Charles Schwab & Co., is a chart so scary she's hesitant to show it to investors. It plots the National Association of Home Builders' Housing Market index - a monthly measure of builder confidence - against the Standard & Poor's 500 stock market index, with a one-year lag.

It turns out that the mood of builders is a terrific stock market bellwether: The correlation between current builder confidence and future stock market returns over the past ten years is downright unnerving.

Not only did the NAHB index presage the start of the post-1994 bull market in stocks, but its decline starting in 1999 foreshadowed the equity market collapse that came the following year. Builder confidence rebounded in November 2001 - a year ahead of the stock market upswing that began in October 2002.

Why is Sonders worried now? Just look at the chart. Over the past year, the NAHB housing index plummeted 54 percent. Were stocks to follow suit, the S&P - 1400 in late October - would be trading below 700 this time next year.

Sonders isn't predicting anything so apocalyptic, but she doesn't hide her concern about housing and her pessimism about stocks.

"In terms of consumer spending, I don't think we've felt anywhere near the brunt of all the adjustable-rate-mortgage resets and the massive increase in defaults and foreclosures in states like California," she says. "Housing downturns happen in a fairly slow-motion way, and I really think we're just at the beginning of the impact on the market and the economy."

The latest omen: GDP grew at its slowest pace in three years in the third quarter, hurt by the housing slump.

Such bearishness flies in the face of the euphoria now rampant on Wall Street. The Dow Jones industrial average keeps hitting new highs, and the S&P is a stone's throw away from its own record (although in inflation-adjusted terms, they're still below their peaks).

Third-quarter earnings? One report seems better than the next, with key companies like Google (92 percent profit growth), IBM (54 percent), and Bank of America (41 percent) all posting stellar numbers.

"The effects of the housing correction will be entirely contained within the housing sector," says Mike Englund, chief economist of Action Economics. Corporate balance sheets are stronger than they've been in years, with U.S. companies sitting on $600 billion in cash. Interest rates are stable, and may decline. Falling energy prices are easing the burden on energy-intensive industries like chemicals and airlines.

And as PNC chief investment strategist Jeff Kleintop points out, there have been only two midterm election years since World War II when the stock market did not stage a fourth-quarter rally. The bulls' bottom line: Housing may be a risk factor, but there's too much other good news for it to be the catalyst for a recession or stock market meltdown.

That may turn out to be wishful thinking. All the economic activity generated by home sales - new mortgages, realtor fees, outlays to painters and handymen, the inevitable shopping trips to Home Depot and Best Buy - played a huge part in digging the economy out of a recession in 2001 and 2002. Given the importance of home sales on the way up, it may be shortsighted to minimize their importance on the way down.

"The historical record is extremely negative in terms of what comes next," says economist Ed Leamer, director of the UCLA Anderson Forecast. "We've had 11 sharp declines in the housing market since World War II, including this one. Eight of the last ten were followed by a recession."

For now, there's little hard evidence that the housing slowdown is dragging down the economy. Construction materials like concrete, wallboard and structural steel should be the canaries in the economic coal mine, yet their prices keep climbing.

Construction-related employment has been rising too - up fractionally from August to September and up 3 percent over the past 12 months, according to the U.S. Bureau of Labor Statistics.

But folks in the trenches paint a much darker picture, lending credence to the idea that we're living through the lag - the period before the realities on the street show up in economists' spreadsheets.

Business is so bad for real estate brokers that Steve Murray, a realty consultant and publisher of the Real Trends newsletter, thinks the industry might end up paring 15 percent of its workforce. That equates to 200,000 agents, which is more than the total layoffs at Ford Motor Co. since 2000.

"I don't think the macro statistics reflect accurately what's going on in many local markets," says Bruce Karatz, CEO of national home-builder KB Home. In many once-hot regions, order cancellation rates are running above 40 percent, new-home sales volume has dropped 50 percent, and new-home prices are down 10 percent to 25 percent. Karatz says the current downturn is worse than any he has seen - even the early 1990s market that left so many big builders reeling.

If housing starts and sales were the only casualty, the economy probably wouldn't be in such peril. Gary Gordon, an executive vice president at mortgage investment firm Annaly Capital and a former chief U.S. equity strategist at UBS, expects construction to fall to 4 percent of gross domestic product from 6 percent today - itself not enough to push the economy (now growing at a 2.6 percent annual rate) into recession.

The big risk is the ripple effect. Consider Annamarie and James Vasiloff, a New Castle, N.Y., couple who until recently had been shopping for a bigger home. Had they found the right one, Annamarie says, they were prepared to spend a few thousand dollars on new furniture. But frustrated with high prices and worried that real estate was about to crash, they put their home search on hold.

Housing turnover is a leading indicator of furniture sales, which is why analysts keep trimming earnings estimates for home furnishing retailers like Pier 1 and Ethan Allen.

Another big concern is what happens if consumers can't keep using their homes as cash machines. By Gordon's estimate, U.S. homeowners pulled more than $450 billion in equity out of their homes last year and are on pace for a similar bonanza in 2006.

But with home values falling, homeowners may lose that source of ready spending money. Should cash-out refinancings fall back to 2001 levels, he estimates, it would drain $300 billion from the economy - which would have roughly the same impact as a $60 jump in the price of a barrel of oil.

And that doesn't include the added bite when homeowners who took out adjustable-rate mortgages a couple of years ago face rate resets that raise their payments.

It's hard to overstate the damage of losing so much potential buying power. Merrill Lynch economist David Rosenberg has argued that cash-out refis were the only reason the economy weathered the gas-price hikes this year and last. Gordon is so worried about the disappearance of cash-out refi money that he's predicting a recession in 2007 or 2008.

When stock investors hear dire warnings like this, one natural response is to get defensive. That's tricky when some signals - namely equity markets hitting new highs - are bullish.

The smartest (and safest) way to protect a portfolio against a real-estate-fueled slowdown may be to shift some assets to intermediate-term bonds (which would benefit if the Federal Reserve starts cutting rates next year to spur growth).

A more aggressive tactic would be to start bargain hunting among troubled housing stocks. This approach is obviously for only the patient and steely-nerved.

Even some badly battered stocks may have further to fall, while others haven't been battered enough. With that caution in mind, here's a look at the prospects for seven prominent stocks in three housing-related sectors.

Homebuilders

Stocks like KB Home (Charts), DH Horton (Charts), and Lennar (Charts) are all trading at four or five times their earnings for the past 12 months - making homebuilding the cheapest sector in the S&P 500. Problem is, P/Es are meaningless if you can't predict the "E."

Bruce Karatz, KB's CEO, thinks it will be next summer at the earliest before homebuilders work through all existing inventory. In the meantime, he's hopeful that a big upswing in free cash flow - builders have essentially stopped buying new land - will get companies like KB back into Wall Street's good graces.

If not, don't be surprised if some builders emerge as takeover candidates. One investor to keep an eye on is Warren Buffett. His company, Berkshire Hathaway, has been nibbling around the edge of the housing industry for years, with various acquisitions.

A bargain-priced homebuilder would fit nicely into Berkshire's portfolio - something that has occurred to Karatz, though he hastens to add he is not talking to Berkshire about selling KBH. "I'm very good friends with [Berkshire vice chairman] Charlie Munger, and I just know he's a very astute student of real estate markets," says Karatz.

Mortgage lenders

With homebuilders, an argument can at least be made that much bad news is already priced into their stocks. The same can't be said of mortgage lenders. This year, shares of Washington Mutual (Charts) and Countrywide Financial (Charts) have returned 3 percent and 11 percent, respectively, despite questions about how they'll fare during the housing downturn.

Not only is there the likelihood of declining: mortgage and home-equity-loan origination but they face increased credit risks as well, particularly if a weakening economy sparks defaults. UBS analyst Eric Wasserstrom is already predicting a 40 percent increase in credit losses at Washington Mutual in 2007.

Countrywide Financial is even more mortgage-dependent than WaMu. Bank of America analyst Robert Lacoursiere, who has a neutral rating on WaMu, calls Countrywide a sell, citing a cooling housing market and the likely downturn in mortgage originations. So we'd avoid these stocks for now.

Home-improvement stores

We recently recommended Home Depot (Charts) as a potential long-term play for patient investors. Trading at 11 times estimated 2007 earnings, the stock already reflects a lot of pessimism. While the price may drop further - the company's earnings tend to rise and fall with home sales - Home Depot is using its ample cash to revamp stores, make strategic acquisitions, repurchase stock, and boost its dividend.

Home Depot's archrival Lowe's (Charts) has its own virtues, including brighter, friendlier-looking stores. The stock is trading at 14 times this year's estimated earnings, its lowest valuation since 1991.

Lowe's smaller size - 1,300 stores nationwide, vs. 2,100 for Home Depot - makes it easier to open new stores without cannibalizing existing ones. And according to Morgan Stanley analyst Gregory Melich, Lowe's has significantly less exposure than Home Depot to extreme "bubble markets" like San Diego and Miami. Analysts expect Lowe's to earn $2.20 a share this year. Were the market to bump Lowe's P/E back to 18, that would translate to a share price of $40, up from $30 today.

Some real estate stocks are still sizzling

The housing market may be sagging, but you wouldn't know it from the stellar performance this year of real estate investment trusts. Some of the big winners: Equity Office Properties (EOP) and Vornado Realty Trust (VNO) have both gained 39 percent; Simon Property Group (SPG) is up 26 percent. REIT Mutual funds like Cohen & Steers Realty (CSRSX.) have soared as well.

Most REITs fall into one of two categories -office REITs that own and manage commercial properties and residential REITs that specialize in apartment buildings.

Office REITs are benefiting from the flood of private-equity money bidding up building prices. The impact of private equity has been less pronounced on the apartment side, but there the cooling housing market has actually helped, encouraging more people to rent rather than buy.

The problem is, REIT share prices have been rising faster than earnings. As a result, the rich dividend yields that are REITs' calling cards aren't so rich anymore, with Equity Office Properties and Vornado yielding 3.1 percent and 2.8 percent, down from their ten-year averages of 6.4 percent and 4.8 percent, respectively. The last time Equity Office's yield was this low was early 1998, a year the stock fell 16 percent.

_________________________

Fixing a real-estate heavy portfolio