I would like to do a non-linear regression with a logit function like brian s. cheng, based on Fox & Weisberg.
I wanted to go the most pain-free way
and went with nls
, but got the error
Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
NA/NaN/Inf in foreign function call (arg 1)
I checked that I don't have any NaN, Inf or similar and found that I have Singular gradient error
. However I don't use zero-residue artificial data (as one should not). As it has something to do with the internals of nls
I turned to nlsLM, but the error remains. What can I do?
My data is https://pastebin.com/iTXQcBzB
My code is
nlsLM(y ~ SSlogis(x, Asym, xmid, scal), mydata) % Error in lm.fit
nlsLM(y ~ theta1/(1 + exp(-(theta2 + theta3 * x))), mydata) % Singular gradient
The data provided is actually just a part and my complete code is more like
mydata %>%
group_by(groupNr) %>%
do(regmodel = nls(.$y ~ SSlogis(.$x, Asym, xmid, scal), .,
start = c(Asym = max(.$y), xmid = mean(.$x), scal = 1)))