I see that in various non-linear least squares minimization libraries a robust loss function is used to reduce the influence of outliers. See rho in here or here. This rho is applied to the squared residuals.
Now, I'm using the Levenberg Marquardt implementation available in the C++ Eigen library, which is based on MINPACK lmdif (I'm using finite differences to compute the jacobian). This implementation of LM doesn't support for providing an external robust loss function. What I've done, instead, is to apply a robust loss function, such as Cauchy or Huber, directly to the residuals just after I calculate them in my error function and return this to the minimizer. So I'm applying rho before the residuals are squared (inside the minimizer). This seems to work for some tests I've done but I'm not sure if that is correct or may give me some problems (I wonder how this affects the jacobian if it's calculated with finite differences).
Is what I'm doing Ok? or is there a better way of making a simple LM minimizer(read MINPACK lmdif) robust to outliers?