拟合Sigmoid曲线

时间:2016-03-18 00:34:44

标签: r regression

我正在寻找一种基于某些数据点创建S形曲线的方法。我看过http://kyrcha.info/2012/07/08/tutorials-fitting-a-sigmoid-function-in-r/我已经按照提供的步骤进行了操作。

但是,我正在尝试使用他的指南中所写的函数nls。但是,我收到错误"singular gradient."这是什么意思?我该如何修复它以便我可以继续绘制这条曲线?

有关我正在使用的数据的附加信息。曲线应该在减少。

示例数据

Concentration   Viability
0   88.9
0   86.6
0   89.4
0   76.5
0   61.6
0   85.5
0   92.8
0   92.3
---
--- 
---

数据

structure(list(Concentration = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 1e-08, 1e-08, 1e-08, 1e-08, 1e-08, 1e-08, 
1e-08, 1e-08, 1e-08, 1e-07, 1e-07, 1e-07, 1e-07, 1e-07, 1e-07, 
1e-07, 1e-07, 1e-07, 1e-06, 1e-06, 1e-06, 1e-06, 1e-06, 1e-06, 
1e-06, 1e-06, 1e-06, 1e-06, 1e-06, 1e-06, 1e-06, 1e-06, 1e-06, 
1e-06, 1e-06, 1e-06, 1e-06, 1e-06, 1e-06, 1e-05, 1e-05, 1e-05, 
1e-05, 1e-05, 1e-05, 1e-05, 1e-05, 1e-05, 1e-05, 1e-05, 1e-05, 
1e-05, 1e-05, 1e-05, 1e-05, 1e-05, 1e-05, 1e-05, 1e-05, 1e-05, 
5e-05, 5e-05, 5e-05, 5e-05, 5e-05, 5e-05, 5e-05, 5e-05, 5e-05, 
5e-05, 5e-05, 5e-05, 1e-04, 1e-04, 1e-04, 1e-04, 1e-04, 1e-04, 
1e-04, 1e-04, 1e-04, 1e-04, 1e-04, 1e-04, 1e-04, 1e-04, 1e-04, 
1e-04, 1e-04, 1e-04, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 
0.001, 0.001, 0.001), Viability = c(88.9, 86.6, 89.4, 76.5, 61.6, 
85.5, 92.8, 92.3, 92.1, 60.8, 86.4, 87.5, 83.3, 83.6, 81.7, 81.1, 
80.4, 79.8, 86.7, 87.5, 88.6, 84.7, 86.5, 91.8, 76.6, 87.5, 86.3, 
86.2, 73.2, 88.1, 92, 90.9, 92.3, 79.2, 89.7, 93.4, 89.5, 91.1, 
87.5, 70.4, 82.4, 80.6, 89.5, 88.9, 89.8, 86.5, 86.6, 87.2, 84.4, 
71.68, 78.6, 95, 86.6, 79.78, 90.1, 93.5, 95.7, 84.3, 83.2, 80.9, 
83.6, 86.5, 85.1, 80.4, 85.2, 84.6, 61.2, 52.6, 54.6, 47.8, 64.1, 
73.4, 64.2, 61.3, 61.9, 52.7, 46.3, 42.4, 15.8, 18.1, 16.7, 12.2, 
11.8, 12.9, 16.2, 16.7, 15.2, 13.8, 12.1, 12.5, 21.6, 21, 21.5, 
11.4, 11.1, 10.5, 13.8, 16.4, 12.8, 23.8, 21.7, 23.2, 33.4, 27.4, 
24.3, 21.6, 21.1, 19.5, 21.2, 18.2, 16.4, 26.3, 22.8, 14.7, 17.3, 
15.2, 17.6)), .Names = c("Concentration", "Viability"), class = "data.frame", row.names = c(NA, 
-117L))

工作代码

df1 <- read.delim("C:\\Users\\Nicholas Hayden\\Desktop\\Data.txt")
x = df1$Concentration
y = df1$Viability
sigmoid = function(params, x) {
    params[1] / (1 + exp(-params[2] * (x - params[3])))
}

fitmodel <- nls(y~a/(1 + exp(-b * (x-c))), start=list(a=1,b=.5,c=25))
  

nlsModel中的错误(formula,mf,start,wts):     初始参数估计时的奇异梯度矩阵

0 个答案:

没有答案