check_residuals function

Check model residuals