I'm sorry, I have to set a single function for the parameters that I have to estimate with non-linear regression.
Parameters:
- c1 = midpoint if x <0
- c2 = midpoint if x> 0
- a1 = slope of the first growth (which should be x <0)
- a2 = slope of the second growth (x> 0)
- qmax = final value of double sigmoide curve
The function is:
q_ds = qmin + (qmid - qmin)/(1+exp(-a1*(spread-c1)))+(qmax - qmid)/((1+exp(-a2*(spread-c2))))
i have the value of qmid and i know that:
qds(deltat = 0) = qmid
so, i can make qmin (initial value of the function) explicit as a function of all the other parameters.
qmin = function(a1, a2, c1, c2, qmax) {(exp(-a1(val_spread-c1)+1)(2*qmid+qmid*exp(-a2(val_spread-c2))-qmax))/(exp(-a1(val_spread-c1))(1+exp(-a2(val_spread-c2))))}
I substitute qmin in the qds formula, to have to estimate one less parameter.
qds = function(spread, a1, a2, c1, c2, qmax) {(((exp(-a1(val_spread-(c1))+1)(2(qmid)+qmidexp(-a2(val_spread-c2))-qmax))/(exp(-a1(val_spread-c1))(1+exp(-a2(val_spread-c2)))) + (qmid - (((exp(-a1(val_spread-c1))+1)(2(qmid)+qmidexp(-a2(val_spread-c2))-qmax))/(exp(-a1(val_spread-c1))(1+exp(-a2(val_spread-c2))))))/(1+exp(-a1(x-c1)))+(qmax - qmid)/((1+exp(-a2(x-c2))))))}
Now, by running the nls command:
ds = nls(y ~ qds, data = data)
the error comes out:
Error in object[[3L]][[1L]] : object of type 'symbol' is not subsettable
Inoltre: Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf
Can you help me?