This headline isn't a projection. It's not a dream. It's reality. Some stock markets are at all-time highs. Right here in the U.S.

I'm talking about the S&P 400 MidCap Index (NYSE: MDY), which closed at a record high on Friday.

Mdyjan

Source: Capital IQ, a division of Standard & Poor's.

Impressive. The index's better-known large-cap cousin, the S&P 500 Index, is still about 20% below its 2007 peak.

Why the outperformance? I wanted to know. So I did some Excel gymnastics until my head almost burst, and here's all I came up with: Mid caps are more expensive than large caps.

Before coming to that conclusion, I assumed the reason mid caps were at an all-time high was because they never became as overvalued as large caps in 2007. But that wasn't the case. Both the mid-cap index and the S&P 500 traded at similar P/E ratios in 2007.

My next hunch was that financials made up a larger portion of the S&P 500, and battered bank stocks like Citigroup (NYSE: C) -- still down more than 90% since 2007 -- were keeping the S&P 500's 2007 high out of reach. No luck there either. Proportionally, the mid-cap index actually holds more financials than the S&P 500.

Here's what seems to be the distinguishing factor: The average stock in the mid-cap index has a forward P/E ratio of 17, whereas the average company in the S&P 500 trades for 13.6 times forward earnings. If the S&P 500 traded at the same earnings multiple as the mid-cap index, it'd also be at an all-time high. Mystery solved.

In hindsight this shouldn't have surprised me. We've been banging on about this for over a year now. If you want to find good, cheap stocks, large caps are where to dig.

A few names stick out. One is Microsoft (Nasdaq: MSFT), which trades at 10 times forward earnings, and has cash in the bank equivalent to 18% of its market cap. Another is Intel (Nasdaq: INTC), which also trades at 10 times forward earnings and throws off a 3% dividend to boot. Johnson & Johnson (NYSE: JNJ) also looks cheap at 12 times earnings as it muddles through the fog of recalls. Some have called these bargains of a lifetime. Hard to disagree.

In a recent Barron's article, Fred Hickey gave an interesting reason why smaller companies have outperformed large caps, and why to doubt smaller companies' valuations:

Small-caps are less liquid than large-caps. When liquidity is pumped back into the economy, they do well. When it comes out of the system, small-caps and real estate collapse. If the Fed stops reliquefying the system after June [when QE2 ends], that isn't good for small-caps.

In the same article, Goldman analyst Abby Joseph Cohen highlights another advantage large caps hold over mid caps:

Companies in the S&P 500 are well positioned. These are large companies with access to the public markets. They can borrow money when they need it. There will be ongoing pressure for small and midsize companies that are dependent on small and midsize banks, which aren't particularly robust. Roughly 40% of S&P profits comes from outside the U.S., which is also a benefit. 

Should you avoid smaller stocks then? No. Good investments can be fond there, too. But in general the bargains aren't as obvious and the quality of the companies aren't as great compared with what can be found in large caps.

With all markets surging with abandon over the past six months, being picky and selective is now as important as it's ever been. If there's a class of stocks to avoid in general, it's those at all-time highs.

Check back every Tuesday and Friday for Morgan Housel's columns on finance and economics.