I’m not sure whether to be amazed or amused that so many professional economists don’t understand the first thing about the stock market.

Exhibit A is Paul Krugman, a Nobel laureate and regular columnist for The New York Times.

Four years ago, he predicted a market collapse and “a global recession with no end in sight” if Donald Trump were elected president.

He then spent the next three years pooh-poohing the economic boom – and bull market – that followed.

The pandemic and government-imposed economic lockdown ended both, of course.

But when the market rallied off its March lows, Krugman wrote column after column declaring that investors had lost their minds.

Despite the egg on his face, he still has plenty of company…

The Washington Post recently ran an article by economist Heather Boushey, president and chief executive of the Washington Center for Equitable Growth, with this understated headline: “The Stock Market Is Wildly Detached From Reality.”

Boushey cannot fathom how the economy could be so bad and the stock market – up more than 50% since the March lows – so good.

I’ve written before about how the troubles affecting so many small companies have benefited cash-rich public companies.

But let’s start at the beginning…

A public company’s valuation is determined by where buyers and sellers can agree on its share price. (There is a buyer for every share sold and a seller for every share bought.)

Stock prices are based on information specific to the company – such as sales, earnings and margins – as well as information about the general economy, like inflation, interest rates, commodity prices, currency values, Federal Reserve policies, government spending, etc.

Opinions about these things change day to day and even minute to minute – as do share prices.

Boushey is right when she says the stock market is not the economy.

It could be better described as a public opinion poll on the outlook for the economy.

Unlike questions asked by Gallup or Pew, however, the opinions reflected in the stock market carry risk.

Bet that a company’s shares are undervalued and you may lose money, at least temporarily and perhaps permanently.

Bet that a company’s shares are fully valued and you give up the upside potential.

Mindless Robinhood gamblers notwithstanding, self-interested traders and investors give serious consideration to the stocks they buy and sell – and try to base their decisions on the best information available.

That’s why the market is often described as “efficient.”

Every bit of publicly available information – both good and bad – is immediately reflected in share prices by investors.

Those prices also include quite a bit of information that is not widely known.

People are out talking to customers, employees, suppliers and competitors every day, trying to glean information to gain an edge.

This information filters into the stock market and is reflected in share prices.

That’s why you often see a stock move higher a few days before good news is released or lower in the days just before bad news is reported.

In essence, the stock market is like a public opinion poll, but only for knowledgeable, risk-savvy individuals and the financial institutions that represent them.

What’s important to understand – and what apparently crosses Krugman’s and Boushey’s noggins at 30,000 feet – is that these men and women are not basing their opinions on the current economy, but on what the economy will be like in the future.

If you were buying a private company in its entirety, you would certainly visit the operations, pore over the books, and talk to the workers and suppliers.

But what you would ultimately pay for the business would be based primarily on what you believe it will earn in the months and years ahead.

Stock market investors think the same way.

Their buying and selling reflects their thoughts on the state of the economy six to nine months out, and how it will affect business.

In the aggregate, these price fluctuations determine how stocks – including benchmarks like the Dow, the S&P 500 or the Nasdaq – are moving.

Like other opinion polls – the 2016 election comes immediately to mind – the stock market is sometimes wrong.

That’s why economist Paul Samuelson famously quipped that the stock market had predicted “nine of the past five recessions.”

(I give Samuelson credit for understanding – unlike Krugman and Boushey – that the stock market is a leading indicator, not a lagging one.)

Investors do sometimes get the big picture wrong. But not usually.

(The exceptions are bubbles and panics, where extreme emotions overcome reason and common sense.)

Making economic prognostications is a treacherous business under the best of circumstances.

The world is a messy, complicated place. Human behavior is unpredictable.

Moreover, the global economy is affected by politics, war, consumer prices, interest rates, energy prices, the value of the dollar, consumer and business confidence, scientific advances, and technological innovation, to name just a few.

Then there is the occasional bolt out of the blue…

Consider the stock market crash of 1987, Saddam Hussein’s invasion of Kuwait (which led to the first Gulf War), the collapse of the highly leveraged hedge fund Long-Term Capital Management (requiring a massive Wall Street bailout), 9/11 and the second Gulf War, the housing bubble (and bust), the financial crisis, and the current pandemic.

You’d have to be clairvoyant to see these events ahead of time.

Yet the consensus is generally spot-on. (That’s why “the trend is your friend.”) Investors generally do get the outlook more right than wrong.

We witnessed the longest bull market in history over the last 11 years because we also experienced the longest economic expansion in U.S. history.

The stock market cratered in the first quarter because investors correctly anticipated an enormous economic contraction as a result of the coronavirus and economic lockdown.

And the market rallied strongly since March because investors correctly anticipated a record economic rebound.

Here’s the bottom line…

There are smart people who know more than most of us on certain subjects, including economics.

But the stock market doesn’t reflect what some smart person thinks. It reflects what investors everywhere think.

So when someone tells you that the stock market has it all wrong, they’re not just saying they’re smarter than some people.

They’re saying they’re smarter than everybody.

And that’s rarely the case.

It’s know-it-alls and bloviators like Paul Krugman and Heather Boushey who are “wildly detached from reality.”

Stock market investors? Not so much.