5PL曲线的非线性最小二乘(scipy)中的异常值处理

时间:2017-09-29 13:15:04

标签: numpy scipy least-squares non-linear-regression loss-function

我目前需要将5PL曲线拟合到我所拥有的一些数据点。 5PL是通常用于生物测定分析的不对称逻辑函数。其公式如下:

F(x)= D +(A-D)/((1 +(x / C)^ B)^ E)

我能够在python(duh)中使用scipy获得适合度。 我第一次使用我的数据知识来确定函数的起始参数: -

A is the lower asymptote so guess it with min(y)
B is the Hills slope so guess it with the slope of the line between first and last point.
C is the inflection point (the concentration of analyte where you have
 half of the max response) so guess it finding the concentration whose 
response is nearest to the mid response.
D is the upper asymptote so guess it with max(y)
E is the asymmetric factor and so guess it with no asymmetry (E=1) for starters.

有了这个我然后使用res = least_squares(residuals, p0,bounds=bnd args=(x, y))其中残差是计算我的数据和5PL函数之间的残差的函数,p0包含我的初始参数,bnd问题的界限和args =是传递给的参数残差(我的数据)。

现在结果是可以接受的,但我怀疑我的测量值有很强的异常值,我希望得到更强大的结果。我发现你可以通过添加一个损失函数并修改nonlin LS来实现这一点(如here所述。

解决此问题的行变为res_loss = least_squares(residuals, p0, bounds=bnd,loss='soft_l1', f_scale=1000, args=(x, y)),其中loss =' soft_l1'确定我使用的损失函数的类型,并f_scale内联和异常值之间的阈值。

现在,在我能找到的每个例子中,人们只是使用他们想要适合的曲线生成数据,并为该信号添加噪声。然后,他们可以将f_scale值设置为等于它们引入的噪声。

这很好,除了不知道异常值的值是什么外,如何选择f_scale?有没有办法自动确定使用数据传播的每个数据集?

如果我的问题是线性的,我只会使用每个X处数据的SD来创建权重矩阵并求解加权最小二乘法。是否存在类似的非线性问题方法?

提前致谢

0 个答案:

没有答案