简体   繁体   中英

Getting covariance matrix when using Levenberg-Marquardt (lsqcurvefit) in MATLAB

I am using the lsqcurvefit function in Matlab to model some experimental data. The data takes a specific shape and so the algorithm is just adjusting the coefficients of this shape to change its amplitude etc.

The model works fine and gives a good fit (I have calculated chi-sq). Other implementations of the Levenberg-Marquardt algorithm give covariance as an output but in Matlab it is not an option for output (only 1st order optimality, no of iterations, Lambda and Jaccobian along with the bounds) .

Does anybody know how to calculate the covariance matrix either from the outputs given (I'm not 100% on what use lambda and jaccobian could be or 1st order optimallity) by lsqcurvefit or independantly?

Any help would be greatly appreciated, thanks!

I think I have solved this myself but will post how here if anyone else is having the same trouble.

The covariance matrix can be calculated from the Jacobian by:

C = inv(J'*J)*MSE

Where MSE is mean-square error:

MSE = (R'*R)/(Np)

Where R = residuals, N = number of observations, p = number of coefficients estimated.

Or MSE can be calculated via iteration.

Hopefully this will help someone else in the future.

If anyone spots error please let me know. Thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM