Predicting conditions for migration: effects of density dependence and habitat quality