Home improvement is one of the few sectors of retail that had a good run in 2017. The two biggest competitors in the industry, Home Depot (NYSE:HD) and Lowe's (NYSE:LOW), have soundly beaten the broader market's returns this year.

Improving home prices and home sales have led consumers to invest more in their homes, fixing them up before or after a sale and investing more in home maintenance. It's also a market well-insulated from e-commerce, with its heavy and pricey inventory. These trends put both Home Depot and Lowe's in strong positions for continued growth.

Investors looking to get into the home-improvement retail space might have trouble deciding between the two market leaders. Home Depot is an ultra-efficient retail machine, but Lowe's may offer better value for the money.

A tape measure and pencil on a wooden table

Image source: Getty Images.

Get out your tape measures

Here's a quick side-by-side comparison of the two companies:

Metric

Home Depot

Lowe's

Market cap

$222 billion

$76 billion

Sales growth*

6.4%

7.9%

Gross margin*

34.1%

34.2%

Operating margin*

14.9%

10.3%

Earnings per share*

$5.76

$3.42

Price-to-earnings ratio

26.4

22.2

*Through the first nine months of 2017. Data sources: Company quarterly earnings releases.

Home Depot is nearly three times the size of Lowe's.

While it's growing slightly more slowly, it's doing so with less invested capital; Home Depot has one of the highest returns on invested capital of any company. Lowe's, meanwhile, is building out more store locations, and acquiring smaller retailers in new verticals and geographic markets.

Another thing that separates the two companies is their operating margins. They have similar gross margins, but Home Depot's scale and operating efficiency allows it to produce a considerably higher operating margin. Lowe's is starting to close the gap Home Depot opened up after the housing recovery started, but its acquisition of lower-margin retailers like Rona will keep it from reaching the same levels as its bigger rival.

Indeed, Home Depot is firing on all cylinders when it comes to execution. Lowe's has certainly had a couple of missteps, but its operations are nothing to sneeze at, either.

You might need an extension ladder

The main thing that gives me pause with Home Depot is its valuation: Its price-to-earnings multiple is at a 15-year high. What's more, the gap between Home Depot's P/E and Lowe's P/E hasn't been this wide since last decade; Home Depot stock is priced at a premium on both a historical and a relative basis.

That's not to say Home Depot doesn't deserve a premium price -- see the discussion above -- but Lowe's is trading near a multiple it hasn't seen since 2014. Its price is much more in line with its historical average. Granted, Lowe's outlook for earnings growth over the next five years isn't as strong as it was the last few years, but its capital returns program looks to be in strong shape, which will bolster earnings per share through aggressive share buybacks.

As a result of its share buyback program and continued improvements in its operating margin and return on capital, Lowe's should be able to produce better growth in earnings per share than Home Depot for the foreseeable future. While Home Depot's operations are extremely appealing, its shares are simply priced for perfection. With Lowe's stock trading closer to its historical fair value than Home Depot's, the better investment right now seems like Lowe's.

Adam Levy owns shares of Lowe's. The Motley Fool has the following options: short May 2018 $175 calls on Home Depot and long January 2020 $110 calls on Home Depot. The Motley Fool recommends Home Depot and Lowe's. The Motley Fool has a disclosure policy.