Reputation: 41
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). 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):
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))))
Upvotes: 2
Views: 4344
Reputation: 4647
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:
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
Upvotes: 1