If you want to play with numbers, the New York Times has an excellent tool:
http://www.nytimes.com/2007/04/10/business/2007_BUYRENT_GRAP...
It allows you to play with multiple variables and then tells you how many years you need to own a home for in order for it to become profitable.