简体   繁体   English

将S形曲线拟合到R中的数据

[英]Fit sigmoidal curve to data in R

I would like to fit a sigmoidal function to my data, I have tried according to a similar matter like here: Using R to fit a Sigmoidal Curve The problem is that my curve is too flat, so it does not reach the upper point of my data (I want it to go to 2 at least or 2.3 on the y-axis and then leave the diagram). 我想将S型函数拟合到我的数据中,我已经按照类似类似的方法尝试过: 使用R来拟合S型曲线问题是我的曲线太平坦了,所以没有达到我的曲线的上限数据(我希望它至少在y轴上达到2或2.3,然后离开图表)。 Do you have any hint what I have to change in my code? 您是否有任何提示我必须更改代码?

Thanks in advance! 提前致谢!

Here the data (its actually more points, so it would look wired if the fitted curve would just reach y-values of 1.5): 此处的数据(实际上是更多点,因此,如果拟合曲线刚好达到y值1.5时,它将看起来是有线的):

T<- c(1.45151262, 1.23861251, 2.25986937, 1.50269889, 1.96593223, 1.25365243, 1.98465413, 1.96593223, 0.98585134, 1.45151262,  1.23861251, 2.25986937, 1.96593223, 1.96593223, 2.53257897, 0.53892040, 0.39919629,  0.49431555, 0.37490131,  0.61959698,  1.30069888,  0.34356933,  0.32231250,  0.60307860,  0.46739360,  0.23849933,  0.22491460, 0.18751264,  0.43795313,  0.35338655,  0.44306278, -0.04577398,  0.23924335,  0.36656968,  0.17550798,  0.39912386, 0.86993214,  0.70492281,  1.09849071,  1.49913528,  0.99460365,  0.48011272,  0.73764538,  2.04877202,  0.88241166,1.08291537,  1.58361191,  1.20293826,  1.37084470)

W<-c(-1.100000, -1.150000, -0.850000, -0.850000, -0.650000, -0.700000, -0.650000, -0.650000, -0.700000, -1.100000, -1.150000, -0.850000, -0.650000, -0.650000, -0.750000, -1.250000, -1.350000, -1.200000, -1.266667, -0.950000, -1.000000, -1.150000, -1.100000, -1.150000, -1.200000, -2.000000, -1.700000, -1.550000, -2.150000, -1.850000, -1.600000, -1.500000, -1.500000, -1.550000, -1.700000, -0.650000, -0.550000, -1.100000, -0.500000, -0.950000,       -0.950000, -0.800000, -1.050000, -0.600000, -0.750000, -1.200000, -0.700000, -0.600000, -0.950000)

The code I used: 我使用的代码:

plot(T~W)

M1 <- nls(T ~a/(1 + exp(-b * (W-c)) ), start=list(a=2.5,b=1,c=-1))

lines(seq(-6,0, length.out = 100), predict(M1, newdata = data.frame(W = seq(-6,0, length.out = 100))))

This may not be sufficient for your needs, but I was able to fit the Lomolino sigmoidal equation with the below plot and parameter statistics: 这可能不足以满足您的需求,但是我能够使用下面的曲线图和参数统计量来拟合Lomolino Sigmoidal方程:

乙状结肠

T = a / (1.0 + pow(b, ln(c/W))) + Offset

Fitting target of lowest sum of squared absolute error = 1.0217387563792354E+01

a =  1.2760743831471755E+00
b =  2.8233200470290357E-05
c = -1.1164548271725272E+00
Offset =  2.4350187846845511E-01

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM