A residence time model of housing markets