Is there any way to allow my nls to have 0 residual error when it makes a non linear fit? I have cases in my data where the fit made should have 0 error, but nls always fails and spits out an error.
Can anyone show me:
- How do I test if this is the error being spit out by nls?
- How to allow for 0 error cases? (Perfect fits)
This is my nls call:
fit <- nls(y ~ ifelse(g, m1 * (x - x0) + y0, m2 * (x - x0) + y0),
start = c(m1 = -1, m2 = 1, y0 = 0, x0 = split),
algorithm = "port",
lower = c(m1 = -Inf, m2 = -Inf, y0 = -Inf, x0 = split),
upper = c(m1 = Inf, m2 = Inf, y0 = Inf, x0 = (split+1)),
data=data.frame(x,y))