我想在我的数据中使用sigmoidal函数,我已经尝试过类似的问题: Using R to fit a Sigmoidal Curve 问题是我的曲线太平,所以它没有达到我的数据的上部点(我希望它至少在2轴上变为2或在y轴上变为2.3然后离开图表)。你有什么提示我在代码中需要改变吗?
提前致谢!
这里的数据(它实际上更多的点,所以如果拟合的曲线只能达到1.5的y值,它会看起来有线):
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)
我使用的代码:
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))))
答案 0 :(得分:0)