从《Modern applied statistic with S》(pp216-217)中看到一种不需要精确起始参数,即可进行非线性函数模型拟合的方法。我在R语言运行时出现错误,请教高手指点解决方法,运行脚本及错误如下:
cl<-data.frame(
- Area=c(521.5, 689.78, 1284.71, 2018.8, 2560.46, 524.91, 989.05, 1646.32, 2239.65, 2972.96, 478.54, 875.52, 1432.5, 2144.74, 2629.2),
- Retention=c(95.3, 87.18, 44.94, 26.36, 18.12, 84.68, 37.24, 33.04, 23.46, 9.72, 97.92, 71.44, 44.52, 24.44, 15.26)
- ) negexp <- selfStart(model = ~ exp(b0*exp(b1*x^th)),
- initial = negexp.SSival, parameters = c("b0", "b1", "th"),
- template = function(x, b0, b1, th) {}) wtloss.ss <- nls(Retention ~ negexp(Area, B0, B1, theta),
- data = cl, trace = T) B0 B1 theta 4.208763 144.205455 1035.324595 Error in qr.default(.swts * attr(rhs, "gradient")) : 外接函数调用时不能有NA/NaN/Inf(arg1)
可以去知乎还有github上面搜索一下