You decide gold is a good bet to hedge against inflation, and suddenly the news seems to be teeming with signs of a falling dollar and rising prices down the road. Or you believe stocks are going to outperform other assets, and all you can hear are warnings of the bloodbath to come in the bond and commodity markets.

In short, your own mind acts like a compulsive yes-man who echoes whatever you want to believe. Psychologists call this mental gremlin the “confirmation bias.”

A recent analysis of psychological studies with nearly 8,000 participants concluded that people are twice as likely to seek information that confirms what they already believe as they are to consider evidence that would challenge those beliefs.

Why is a mind-made-up so hard to penetrate?

“We’re all mentally lazy,” says psychologist Scott Lilienfeld of Emory University in Atlanta. “It’s simply easier to focus our attention on data that supports our hypothesis, rather than to seek out evidence that might disprove it.”

It also is easier for people to rationalize than to be rational. “We’re very good at cooking up post-hoc explanations of why our predictions didn’t work,” Prof. Lilienfeld says. “We reinterpret our failures as near-misses: ‘This stock would have gone up if only X had happened,’ or ’99 times out of 100 I would have been right if not for this freak event.'”

The more you learn, the more certain you become that you are right. While gathering more data makes people more confident, it doesn’t make their predictions much more accurate. Each new fact makes you more inclined to find another fact that resembles it, reducing the diversity and value of your information.

Confirmation bias contaminates the thinking of professional investors, too. “We’ve made tons of errors like this,” says Staley Cates, president of Southeastern Asset Management, the Memphis, Tenn., value-investing firm that runs the Longleaf funds. “A lot of psychological traps can be combated with humility, but on this one, that doesn’t help.” Longleaf, Mr. Cates says, clung too long to a big position in General Motors, letting product improvements and cost savings “blind us to the fact that GM might not make it” without government help.

So how can you counteract confirmation bias?

Gary Klein, a psychologist at Applied Research Associates, of Albuquerque, N.M., recommends imagining that you have looked into a crystal ball and have seen that your investment has gone bust. Next, come up with the most compelling explanations you can find for the failure. This exercise, which Christopher Davis of the Davis funds has integrated into the research process at his value-investing firm, can help you realize that your beliefs mightn’t be as solid as you thought.

Try estimating the odds that your analysis is wrong. Let us say that you reckon there is a 20% chance of an adverse outcome; that is like saying you will be proven wrong one in every five times. This way, if the investment does go awry, you will be less likely to dig in your analytical heels and desperately try to prove that you are still right. This procedure, says Michael Mauboussin, chief investment strategist at Legg Mason Capital Management, provides “psychological cover for admitting that you’re wrong.”

Show your investment to another person you respect whose ego isn’t already invested in the decision. Ask: If you didn’t own this, would you buy it now? If you did own it, would you sell it now?

Run an imaginary portfolio alongside your real one. There, you can buy or sell at will, with no risk to your wealth. On that blank slate, would you own more—or less—of this investment? Mr. Cates says at Southeastern Asset Management requires each of its analysts and portfolio managers to run a paper portfolio and to justify any differences between their paper holdings and the firm’s real-world bets. “It helps us know what people really think,” Mr. Cates says.

Before you buy in the first place, write down a statement of what would compel you to change your view of the investment. If any of those events come to pass, the written record will make it harder for you to pretend nothing has changed or that you don’t have to do anything in response.

Messrs. Cates, Davis and Mauboussin help run funds that posted steep losses last year clinging to stocks in the face of evidence that they might be wrong. They all say that fighting confirmation bias is a never-ending battle. But if you can’t conquer this gremlin of your own mind, you don’t stand a chance of outwitting the market.