Peter Lynch once said retail investors should "invest in what you know," and it's likely that a lot of readers will have shopped at either Kroger (NYSE:KR) or Costco (NASDAQ:COST) recently. Kroger is the largest pure-play supermarket in the country, operating under brand names Kroger, Ralphs, King Soopers, and others. Meanwhile, Costco is the largest discount wholesale membership club, with 90.3 million members as of its most recent quarter.

Similarly to Lynch, Warren Buffett once quipped, "Whether we're talking about socks or stocks, I like buying quality merchandise when it is marked down." Given the steep price declines in both Kroger and Costco this year, which is the better buy?

25 percent off sign above a rack of jeans in a store

Image source: Getty Images.

Growth

As you can see, both companies were mid-single-digit growers until recently, when Costco took off, growing a whopping 15.7% in the most recent quarter.

COST Revenue (Quarterly YoY Growth) Chart

COST Revenue (Quarterly YoY Growth) data by YCharts.

Of course, Costco's big increase is mainly due to its June price hikes on membership fees, which make up 65% of company profits. It should also be noted that Costco's quarterly results include an extra week compared with last year, so the true growth number was probably closer to 14.8%. Still, that is significantly higher than Kroger. In addition, Costco outperformed in the all-important same-store sales figure (excluding fuel), posting 5.7% growth versus Kroger's 0.7%. 

Clearly, Costco's membership model (which allows for periodic price hikes) seems to give it a better growth profile. Since Costco sells goods near breakeven anyway, it's also more immune to the price wars currently seen at grocery stores. It's the clear winner here.

Winner: Costco

Valuation

When we turn to valuation, however, we get a different story. The lower numbers from Kroger have caused it to trade at only half the valuation of Costco on a price-to-earnings basis.

COST PE Ratio (TTM) Chart

COST PE Ratio (TTM) data by YCharts.

Of course, Kroger also has more debt than Costco, as it has largely grown via acquisition. A good way to factor debt into a company's valuation is to look at the enterprise value-to-EBIT ratio, which normalizes for a company's debt profile. On this basis, Costco is not quite as overvalued but is still about 50% more expensive than Kroger.

COST EV to EBIT (TTM) Chart

COST EV to EBIT (TTM) data by YCharts.

Winner: Kroger

Shareholder returns

Investors in Kroger or Costco may also be concerned with dividends, and Kroger and Costco don't disappoint in that area. Both companies pay a regular dividend, and each company raised its payout this year. Kroger's current dividend yield is almost double that of Costco's, which is probably a function of Kroger's lower valuation.

COST Dividend Yield (TTM) Chart

COST Dividend Yield (TTM) data by YCharts.

Of course, this regular dividend only tells part of the story. Costco also occasionally pays a special dividend, as it did back in May, as well as in 2015 and 2012.

Factoring in Costco's special dividends over a multiyear period, long-term Costco shareholders might receive a similar dividend yield to Kroger should the trend continue.

However, there's another way to return cash to shareholders besides dividends, and that is through share repurchases. Here, the scales tip back in favor of Kroger, which has paid out almost five times as much in the way of share repurchases as Costco did over the last 12 months.

COST Stock Buybacks (TTM) Chart

COST Stock Buybacks (TTM) data by YCharts.

Winner: Kroger

Who's got the Amazon antidote?

Of course, the 800-pound gorilla in the room is Amazon, which caused both stocks to drop after it bought Whole Foods Market earlier this summer. Everything I've just said up until now may be irrelevant if Amazon is successful in luring away either company's core customers in large numbers.

To me, while Costco has a better business model than Kroger, but it's also more vulnerable to Amazon due to Amazon's Prime service, which is a membership subscription not dissimilar to Costco's. Moreover, Costco estimates its average customer is 52 years old, which means Amazon has an opportunity to compete for millennials' loyalty.

In addition, a recent piece by Thasos Research showed Costco lost slightly more customers (on a percentage basis) to Whole Foods than Kroger did after Amazon slashed prices at Whole Foods on Aug. 28. The effect was small for both companies but is still something to keep an eye on.

Winner: Kroger

Better buy: Kroger

Costco arguably has a better model and is growing faster than Kroger, but investors will have to pay up for the stock, and it seems more vulnerable to Amazon than Kroger is. Therefore, I'm going with the bigger bargain in Kroger.

Billy Duberstein owns shares of Amazon and Kroger. The Motley Fool owns shares of and recommends Amazon. The Motley Fool recommends Costco Wholesale. The Motley Fool has a disclosure policy.