A drive-through McDonald's in Denton, Texas. Image source: McDonald's.

In an effort to figure out why McDonald's (NYSE:MCD) stock has done so well since the beginning of 2015, I recently compared its performance to Wal-Mart's (NYSE:WMT). What I found surprised me:

MCD Chart

MCD data by YCharts.

If you saw this chart but knew nothing about the companies, you would conclude that things must be going great for McDonald's and horribly for Wal-Mart. After all, since the beginning of 2015, McDonald's stock is up 35% while Wal-Mart's stock is down 20%.

But this isn't the case. The number of people who eat at McDonald's has declined for three years in a row. The worst was 2014, when the hamburger chain's guest count dropped by 3.6%. It improved in 2015, thanks in part to the rollout of its all-day breakfast menu, but traffic still declined by 2.3%.

Numbers like this for a restaurant chain are disturbing. Consider the scale of McDonald's response. It hired a new CEO, reorganized its operating divisions, is refranchising thousands of restaurants, ratcheted up its debt by 62%, and is simultaneously pacifying the market by inflating the amount of capital it's distributing to shareholders.

It's the latter tactic in particular -- returning more capital to shareholders -- that helps explain why McDonald's stock has done so well over the past year.

McDonald's has promised to return $30 billion of capital over the three years from 2014 through 2016. It paid out $15.8 billion of this in the first two years, leaving $14.2 billion to distribute this year. After subtracting dividends, and assuming the company doesn't pay a special dividend, this means that McDonald's will have to repurchase upwards of $11 billion worth of stock this year.

That's a huge number. It's roughly twice the amount that McDonald's spent on buybacks last year. And it spent about twice the amount on buybacks last year as it did the year before that. Excluding 2015, McDonald's typically spends around $2.7 billion a year on repurchases. If it sticks to its plan, then, McDonald's will spend four times as much this year on buybacks as it does in a normal year.

This goes a long way toward explaining why McDonald's stock has increased so much since the beginning of 2015. Either the company's own purchases have inflated its stock price or investors did so in anticipation of the purchases. It doesn't matter which is the case because the cause and the outcome in each are the same. That is, McDonald's stock price seems to be inflated because of its buybacks.

The comparison to Wal-Mart's performance backs this up. Wal-Mart has struggled like McDonald's has over the last few years to grow. It recorded same-store sales of only 0.5% in 2015. And that was a year when gas prices had dropped by half from the prior year, implying that consumers should have had more money to spend at Wal-Mart.

The retail chain has also dealt with the migration of customers to e-commerce, supply chain issues that left shelves bare, a bribery scandal in Mexico, and most recently an increase in the minimum wage it pays employees. But, importantly, even though all of this is bad, it's no worse than McDonald's predicament, in which fewer customers have visited its restaurants for three years in a row.

Long story short, there is no fundamental reason for the divergence between Wal-Mart and McDonald's stocks that we saw in the chart at the top of this article. The only way to reconcile it is to conclude that McDonald's buybacks are artificially inflating its stock price.