问题描述
我正在Matlab中使用lsqcurvefit函数对一些实验数据进行建模.数据采用特定的形状,因此算法只是调整该形状的系数以更改其幅度等.
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.
该模型运行良好且拟合良好(我已计算出chi-sq).Levenberg-Marquardt算法的其他实现将协方差作为输出,但是在Matlab中,它不是输出的选项(仅一阶最优,无迭代,Lambda和Jaccobian以及边界).
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) .
有人知道如何通过lsqcurvefit或独立地从给定的输出(我不是100%使用lambda和jaccobian或1阶最优性)上计算协方差矩阵吗?
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
C = inv(J'*J)*MSE
其中MSE是均方误差:
Where MSE is mean-square error:
MSE =(R'* R)/(N-p)
MSE = (R'*R)/(N-p)
其中R =残差,N =观测次数,p =估计系数的数量.
Where R = residuals, N = number of observations, p = number of coefficients estimated.
或者可以通过迭代来计算MSE.
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
这篇关于在MATLAB中使用Levenberg-Marquardt(lsqcurvefit)时获取协方差矩阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!