This is by far the best calculator I have found online that provides an estimate between the cost of renting vs the cost of buying. I love this calculator because it takes into account all the costs of owning a house, which are underestimated by some people, in addition to the opportunity cost of not investing in other assets that might yield better returns, in particular on the value of the down payment.
This should be used to evaluate the pros and cons of buying the apartment/house you will live in. Do not make the mistake of just comparing the monthly bank payment with the monthly rent. Much more (significant) costs have to be considered when owning a house.