Investment return rate, rent/buy cost ratio, inflation and home appreciation (or depreciation) rates all matter. It's a lot to consider.
Luckily, the NYTimes put out a great calculator for just this:
http://www.nytimes.com/2007/04/10/business/2007_BUYRENT_GRAP...