search for: fortranesqu

Displaying 1 result from an estimated 1 matches for "fortranesqu".

Did you mean: fortranesque
2009 Oct 09
1
Substituting the extracted coefficients into the formula, exctracted from the result of nls()
...<- 0.1*x^2 - rep(3, length(x)) + rnorm(length(x), sd = 0.5) yfit <- nls(y ~ a*x^2 + b*x + c, start = list(a = 1, b = 1, c = 1), trace = TRUE) plot(x, y) curve(coef(yfit)[1]*x^2 + coef(yfit)[2]*x + coef(yfit)[3], 0, 10, add = TRUE) However, this code is rather fortranesque, and most likely there exists a much more elegant way in R/S, something like abline() which exists for straight lines. Since both the formula and the coefficients are available as a result of nls() (here as formula(yfit) and coef(yfit)), I thought there ought to be a way something along the follow...