Added residual calculations to regression