Activist investor William Ackman's Pershing Square Capital Management agreed in October to sell 5.97 million shares of Canadian Pacific Railway (NYSE:CP), but the stock has climbed 9% since then and is up 42% year to date.

On Sept. 30, Pershing Square owned 23.12 million shares, comprising 27.7% of Pershing's portfolio, down 4% from June 30. Ackman's firm hired three banks to lead the sale of 5.97 million shares of the railway -- a move that reduced Pershing Square's holdings in it to 17.15 million shares, or 9.8% of the company -- still the largest ownership position in Canadian Pacific.

Let's consider why Ackman sold some Canadian Pacific shares and compare those shares to those of its peers to see whether or not it's a good time to sell.

Activist history with Canadian Pacific
Ackman first began buying Canadian Pacific shares in 2011, when they were trading at about $49 per share. In May 2012, Ackman won a public battle with the board at Canadian Pacific, removing Fred Green as CEO, and replacing the board's chairman and four other board members. He then brought in E. Hunter Harrison, a former chief executive of Canadian National Railway (NYSE:CNI), a rival to Canadian Pacific.

Ackman's original purchases in Canadian Pacific tripled in value. Yet Ackman has admitted that his funds' performance suffered from losses in other investments this year.

Pershing Square funds declined by more than 5% during the third quarter of 2013 generating flat performance net of all fees for the first nine months of the year. The third quarter's negative performance was driven by losses in J.C. Penney and Herbalife.

It appears Ackman is selling some Canadian Pacific to invest in other stocks, including Air Products & Chemicals, which he raised his stake in substantially in the third quarter. Bloomberg reported that Ackman's funds rebounded in October, with a 7.9% return. His year-to-date return through October was 8.1% -- still well below the S&P 500's 25% return this year.

Let's compare Canadian Pacific to its peers and see whether the stock is overvalued. The following chart shows key metrics for the railroad and its competitors:

  Forward P/E Operating Ratio (Q3) Dividend Yield Payout Ratio
Canadian Pacific  18.08  65.9 0.9% 31%
Canadian National  18.15  59.8  1.4%  27% 
Union Pacific (NYSE:UNP)  15.25  64.8 1.93%  32% 
Kansas City Southern (NYSE:KSU)  23.79  67.8  0.71% 28% 

Source: Yahoo Finance and company reports

Comparing rails
Looking at the chart, we can see Canadian Pacific's forward price to earnings ratio of 18 is not out of line with its peers. Union Pacific appears attractive on this measure with its forward P/E of 15. Union Pacific also offers the highest dividend yield at 1.90%. All four railroads' payout ratios are slightly under one-third of earnings -- which is healthy.

Canadian Pacific used to have a reputation as having one of the worst operating ratios (total expenses divided by total revenue) in the business, but that is quickly changing. Harrison, the CEO, has improved operating ratio from 74.1% to 65.9% in third quarter 2013 by reducing workforce, selling assets, and obtaining better pricing for services.

Rival Canadian National has the lowest operating ratio in the industry. Canadian National's operating ratio improved by 0.8 of a point to 59.8% in the third quarter.

Ackman has been selling Canadian Pacific stock at a time when Canadian railroads are experiencing a 2.4% increase in carloads during the first 47 weeks of 2013, according to the Association of American Railroads. Canadian railroad intermodal units were up 4.3% from last year. Fourth-quarter volumes are improving too. Canadian railroads reported 81,723 carloads for the week ended Nov. 23, up 5.6%, and 54,540 intermodal units, up 7.9% compared with the same week in 2012.

Canadian Pacific's third-quarter profit was up 44.6% from the same period a year ago.

Risks against the operations of Canadian Pacific, and railroads in general, are weather and accidents. If Canada has another long hard winter with flooding in the spring, Canadian railroads' on-time performance to customers may suffer in early 2014. 

Rail stocks have had a big run-up this year: Canadian National stock is up 25%, Union Pacific is up 28%, Kansas City Southern is up 44%, while Canadian Pacific's stock is up 50% year to date. It's hard to predict stock returns in 2014, but I do expect most railroads, especially Canadian Pacific, to grow earnings due to improved operating ratios and higher volumes of freight moving through North America in the fourth quarter.

Ackman sold some shares in Canadian Pacific Railway to invest in other businesses. It was a good choice for him because stock in the the railroad represents more than a fourth of his fund's investments, and Canadian Pacific appears fully valued compared to its peers. If investors are overweight this stock, they may want to follow Ackman and sell some shares. However, if investors have a long-term outlook, they may want to hold on to the stock. The outlook for this railroad is positive; I'm holding onto my Canadian Pacific shares.

Michael Hooper owns shares of Union Pacific, Canadian National Railway, and Canadian Pacific Railway Limited (USA). The Motley Fool recommends Canadian National Railway. Try any of our Foolish newsletter services free for 30 days. We Fools may not all hold the same opinions, but we all believe that considering a diverse range of insights makes us better investors. The Motley Fool has a disclosure policy.