In R I use nls to do a nonlinear least-squares fit. How then do I plot the model function using the values of the coefficients that the fit provided?
(Yes, this is a
coef(x) returns the coefficients for regression results x.
model<-nls(y~a+b*x^k,my.data,list(a=0.,b=1.,k=1)) plot(y~x,my.data) a<-coef(model)[1] b<-coef(model)[2] k<-coef(model)[3] lines(x<-c(1:10),a+b*x^k,col='red')
For example.