1
I’m trying to include the curve predicted in my graph, but it doesn’t fit. I’m using the following argument:
plot(df$n.kill, df$body)
lines(df$n.kill,predict(fit,df$n.kill))
Dice:
n.kill<-c(79,4,86,9,10,49,45,260,10,8,182,16,824,2,11,112)
body<-c(160,1.5,23,40,4.5,4.5,0.8,3,1.2,60,70,0.5,35,30.5,4,47)
df<-data.frame(n.kill, body)
ca=max(df$n.kill)
eps <- .Machine$double.eps^0.5
fit <- nls(n.kill ~ a*(1 - exp(-b*body))^c, data = df,
start = list(a = ca, b = 0.05, c = 1),
algorithm = 'port',
control = nls.control(maxiter = 100, tol = eps))
Try it the other way around,
n.kill
is the answer, should be on the y axis as the result ofpredict
. On the x-axis shall bebody
.– Rui Barradas
The curve adjustment still continues with "error", several entangled lines are plotted, instead of only one with the predicted curve.
– Milton de Paula
See the third answer here, the one that uses the function
curve
https://answall.com/questions/6267/como-coloca-a-linha-de-regress%C3%a3o-em-um-gr%C3%a1fico– Jorge Mendes