Compute residual variances and add elbow method