R nlsLM / nls拟合质量,数据点数低

时间:2016-02-02 20:08:06

标签: r nls

虽然我在nlsLM使用了minpack.lm一段时间并取得了很好的效果,但我现在面临着在提供质量方面遇到意想不到的麻烦而且提供的数据点较少。

在该示例中,您会看到一个配有750个数据点,另一个配有50个。

http://i66.tinypic.com/33cn9jq.jpg

http://i64.tinypic.com/14cb4a0.jpg

是单指数拟合B(1-exp(-x * tm))+ C其中CB是预定义的,tm是时间。

示例数据:

mxf <- structure(list(tm = c(0.604, 0.705, 0.805, 0.905, 1.005, 1.105, 
1.205, 1.305, 1.405, 1.505, 1.605, 1.705, 1.805, 1.905, 2.005, 
2.104, 2.204, 2.304, 2.405, 2.505, 2.605, 2.705, 2.805, 2.905, 
3.005, 3.105, 3.205, 3.305, 3.405, 3.505, 3.605, 3.705, 3.805, 
3.905, 4.005, 4.105, 4.205, 4.305, 4.405, 4.505, 4.605, 4.705, 
4.804, 4.904, 5.004), mxxp1m = c(15.2, 24.5, 30.1, 35.3, 38.6, 
40.9, 42.7, 46.3, 47.1, 47.8, 48, 48.6, 51.1, 51.7, 52.6, 52.3, 
52.2, 51.8, 54.4, 54, 52.7, 51.7, 54.4, 52.5, 53.5, 52.8, 54, 
53.5, 52.5, 53.4, 52, 52.9, 52.7, 52.4, 53.7, 52.3, 53.1, 52.2, 
52.8, 53.1, 52.9, 53, 53.3, 51, 52.5)), .Names = c("tm", "mxxp1n"
), class = "data.frame", row.names = c("1", "2", "3", "4", "5", 
"6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", 
"17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", 
"28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", 
"39", "40", "41", "42", "43", "44", "45"))

这是我在两个样本中使用的代码:

    mxf = data.frame(mxf,b,c)
    ## c = 0.2 (y starting point)
    ## d = 0.6 (y - span from start to end)

    fit = nlsLM(mxxp1m ~ b-(b*exp(-x*tm))+c, data = mxf, start = list(x=0.5))

我已经考虑过对值进行加权,或者更改maxiter选项,但没有得到足够好的结果。

1 个答案:

答案 0 :(得分:0)

最后找到我自己的解决方案:

问题是nls拟合算法不能处理x-start值(这里是时间范围)&gt; 0.如果数据点从t = 0.6开始,则拟合不正确。如果它然后设置为t = t-t [1]它的工作正常。

因此,总是将t向量修改为以t = 0开头而不是t = 0.603。