residuals function

One-step and multi-step residuals