Estimating the vulnerability and loss functions of residential buildings