All that glitters is not gold. Or so appears to be the case with some gold stocks right now. While players across the gold industry have taken a beating in recent months, Agnico Eagle Mines (AEM 0.58%) and Yamana Gold Inc. (AUY) have been hit particularly hard. They're down nearly 21% and 41%, respectively, in the past six months. Compare that to the relative resilience that larger gold miners like Barrick Gold (GOLD 0.71%) and Goldcorp Inc. (GG) have displayed and you're bound to wonder whether there's trouble brewing at Agnico and Yamana.

AEM Chart

AEM data by YCharts.

If you ask me, I think the big price drops in both stocks offer a great opportunity for precious metal investors. But how do Agnico and Yamana stack up and which one should you buy? It's a tough match, as you shall soon see, but one stock looks particularly compelling right now based on three key aspects.

1. AISC: Agnico leads

Gold prices aside, two other factors drive a gold miner's profits: production and costs. While production can differ considerably depending on the size and scale of a miner, costs are where things get really interesting because in a volatile industry like precious metals, low costs can prove to be one of the strongest competitive advantages.

Gold nuggets placed on stock charts

Image source: Getty Images.

Gold miners use all-in sustaining cost, or AISC, to measure costs, which is a comprehensive metric that includes nearly every element of operating expenses. From a cost standpoint, Agnico had a strong 2016 as it beat its own target and ended the year with AISC of only about $824 per ounce, substantially lower than Yamana's 2016 AISC of $911 an ounce. It's worth noting, though, that Yamana reports AISC on a co-product basis or before deducting by-product metal revenues from production costs. Agnico's co-product AISC was $894 per ounce last year.

Agnico is clearly more cost efficient than Yamana, but its investment thesis gets even stronger when you stack it against other players in the industry.

Gold miner AISC for 2016
($ per ounce)
Agnico Eagle $824
Yamana Gold $911
Barrick Gold $730
Goldcorp $856
Newmont Mining $912

Data source: Companies' financials. 

You guessed it right: Agnico is among the lowest-cost producers in the industry today -- a status unlikely to change in 2017 given the miner's projected full-year AISC of $850-$900 an ounce versus Yamana's AISC guidance of $890-$910 an ounce. Agnico clearly wins this round.

2. Cash flows: Yamana makes the cut

Do you wonder why most miners suffer losses or barely make profits even when precious metal prices are on the rise? I believe net income isn't a great metric metric to judge a miner's standing. That's because the nature of the mining business is such that miners periodically revalue their reserves based on spot prices, which could mean big writedowns when prices are falling as exploration and development of mines becomes unviable.

That's not to say the mines aren't valuable anymore, but miners still end up with huge non-cash expenditures (read: writedowns) that make their profits look smaller than what they really are. Remember how Barrick sent shockwaves through the industry when it announced writedowns worth $3 billion early last year? Now here's the deal: Barrick ended 2016 with net profit worth only about $861 million but generated operating and free cash flows worth nearly $2.6 billion and $1.5 billion, respectively.

The point I'm trying to drive home is that if you want to see how healthy a gold miner is, focus on its cash flows instead of profits. Here again, Agnico trumps Yamana in terms of growth in cash flows in recent years.

AUY Cash from Operations (TTM) Chart

AUY cash from operations (TTM.) Data source: YCharts.

Let me warn you that Agnico's free cash flow could suffer for a year or two as it spends money on developing its Meliadine and Meadowbank mines in northern Canada, having recently reversed asset impairments on them. Agnico expects to start production at both mines by the third quarter of 2019, which should push its total its production to 2 million ounces by 2020 from about 1.6 million of ounces for 2019.

In contrast, I expect Yamana's cash flows to improve going forward as it brings its seventh mine, Cerro Moro, on line by early next year. Yamana's efforts to strengthen its balance sheet -- it recently spun off subsidiary Brio Gold and hasn't ruled out the possibility of selling its stake in Brio to raise cash to invest in growth and repay debt -- should provide further support.

It's a tight call, but I believe Yamana wins this round given its immediate cash flow potential.

3. Valuation: The winner is...

So far, it's a tie, so the final decision boils down to valuation. My favorite valuation metrics are based on cash flow, especially when it comes to mining stocks.

AUY Price to CFO Per Share (TTM) Chart

AUY price to CFO per share (TTM). Data source: YCharts.

It's a clear verdict: Yamana looks incredibly undervalued on a cash flow basis. When you factor in the growth potential in its cash flows in coming years, the stock could turn out to be a bigger winner than Agnico.