Investors like a good deal. The problem is, most of us wouldn't know a bargain if it hit us in the face.

At least that's what hedge fund manager, and value investing icon, Joel Greenblatt says. Greenblatt argues that by following the simple formula, his "magic formula," we can take the guesswork out of picking bargain stocks. Right now, two food and beverage stocks, Kellogg (NYSE:K) and Dr Pepper Snapple (NYSE:KDP), look like bargains by Greenblatt's metric. 

What is the magic formula?
I'm glad you asked. It's the combination of stocks with a low earnings yield and a high return on capital. The idea is it helps you not only find cheap stocks but, by focusing on businesses that earn a high return on capital, you find good businesses too. While that may sound intuitive, the formula often picks scary stocks. 

Bad news, good gains
The essence of the "magic formula" is finding great businesses at steep discounts to their intrinsic value. If a company truly is a value pick, and is trading at a discount, negative headlines are almost always the cause. 

That's certainly the case when it comes to the soda business. Over the past few years North American soda sales have slowed amid a drumbeat of health concerns. Not only has the scrutiny of regular soda's link to diabetes and obesity intensified, some studies have also compared the health risks of diet soda to those of illegal drugs.

This negativity has kept Dr. Pepper's stock in check, even though the business is returning cash to investors, which makes it a bargain according to this formula. It ranks among the best fifty large-cap value stocks by the magic formula, with an earnings yield of 5.83% and a return on capital of 13.9%.  

DPS Earnings Yield (TTM) Chart

DPS Earnings Yield (TTM) data by YCharts

So here's the (potential) downside for Dr Pepper. The trick is determining what is going to happen with carbonated beverages next. While Dr Pepper's total sales volume increased 1% in its most recent quarter, North American beverage sales sank 2%. That is somewhat troubling when you consider that 73% of Dr Pepper Snapple's revenues come from North American carbonated beverage sales. 

Kellogg's health concerns are not nearly as severe, but the company is facing headwinds. Kellogg's most recent quarter saw better profits, but sales were down again, 1.7%. Management cited continued worries about traditional cold cereals, for the second straight quarter, it seems American's tastes may be changing. There's also the matter of healthier trends. Organic groceries still make up a small percentage of sales, but they're growing at a rate of 13% or more. At some point, we may need to wonder how big a part Kellogg's packaged foods will play in our future. 

Due to these headwinds Kellogg's stock has been held back, despite continued profitability. The stock has an earnings yield of 7.75% and a return on capital of 17.85%. 

K Earnings Yield (TTM) Chart

K Earnings Yield (TTM) data by YCharts

Weighing the good and the bad
The magic formula ranks both stocks in the top fifty, but buying them takes a leap of faith. You really need to weigh the risks and growth potential of each. They're better than "cheap" stocks, because they're also earning high returns on capital, but they carry risks.

Yet, on average, if you buy enough high-performing businesses, at bargain stock prices, you'll come out ahead. When you buy 20 or 30 stocks that meet this criteria, the winners strongly outweigh the losers. So buy these two stocks but only as part of a broader, diversified, portfolio.

Adem Tahiri has no position in any stocks mentioned. The Motley Fool has no position in any of the stocks mentioned. Try any of our Foolish newsletter services free for 30 days. We Fools may not all hold the same opinions, but we all believe that considering a diverse range of insights makes us better investors. The Motley Fool has a disclosure policy.