Over the past several years, one of the best investments has been in shares of prison owners and operators. There are two publicly traded that dominate the industry in the United States – Corrections Corp. of America (NYSE:CXW) and Geo Group (NYSE:GEO).

Both stocks have provided investors with exceptional long-term returns. In 2012, both of these companies converted their businesses into real estate investment trusts for tax purposes. This added substantial value to these companies and the stocks began to spike, and an intermediate top was put in towards the beginning of 2013. Since then, the stocks have corrected about 20 percent and it looks attractive again.

There are several fundamental reasons to like these companies as long-term investments. First, there is a secular trend towards privatization in the prison system. According to Corrections Corp. of America, back in 2001, less than 7 percent of the U. S. inmate population was housed in a privately run prison. That figure exceeds 10 percent today. As private companies, Corrections Corp. of America and the Geo Group are answerable to its shareholders, and therefore, operational efficiency is a priority. Governments in the U. S. have failed to beat these companies’ strong track records for achieving efficiency, and now that it is short on capital, it is motivated to outsource prisons to these private companies.

Second, the prison industry is recession-proof. While a falling stock market will likely drag these stocks lower, a weak economy will not hit these companies’ earnings. Prisons are essential, and governments aren’t going to let convicts walk free unless there is a fiscal emergency that necessitates it. Furthermore, private prison operators may benefit from a weak economy. If a recession lowers a state’s income, it may be motivated to seek savings by privatizing prisons.

Given these points, it seems that prison stocks are compelling. This becomes clearer when we consider that these companies are selling at attractive valuations. Unlike most stocks, it is trading near 52 week lows, although it seems to have put bottoms in.

While they trade at somewhat high prices relative to net earnings (nearly 20-times) for a real estate investment, trust a more appropriate measure is funds from operations (FFO.) Both Corrections Corp. of America and the Geo Group trade at P/FFO ratios that are in the low double digits (about 12 times), and I think this can rise somewhat.

Both companies, having converted into real estate investment trusts, now pay substantial dividends. Corrections Corp. of America pays about 6.5 percent and the Geo Group pays 7 percent. This distribution policy ensures that these companies satisfy the conditions to quality for real estate investment trust tax treatment. This means that the income distributed to the shareholders is taxed as ordinary income, although it is not subjected to the corporate tax (in other words, it is not doubly taxed like dividends coming from normal publicly traded companies.) It also means that these are excellent stocks for retirees who live off of dividend income.

Ultimately, these stocks aren’t going to make you rich, although it appears to be excellent vehicles for generating income, and it is less expensive than other real estate investment trusts. It also has the tailwind of positive secular trends, and it is recession resistant. This last point is crucial for someone who is dependent upon consistent income, which can be jeopardized during a recession.

Regarding which company to buy, the Geo Group is a little less expensive, but Corrections Corp. of America is larger, and it is the market leader. The Geo Group also has about 15 percent of its operations overseas, primarily in Australia. Given that the differences are minor, and given that they have both been excellent performers in the long run, it seems pointless to take the time to construct a prima facie case for one over the other, and interested investors should simply buy some of each.

Disclosure: Ben Kramer-Miller has no position in Corrections Corp. of America or the Geo Group.

More From Wall St. Cheat Sheet: