Suppose I have x values, y values, and expected y values f (from some nonlinear best fit curve).
How can I compute coefficient of determination (R2)? Note that this function is not a linear model, but a nonlinear least squares (nls) fit, so not an lm fit.
You just use the
lmfunction to fit a linear model:Note that the r squared is not defined for non-linear models, or at least very tricky, quote from R-help:
If you want peer-reviewed evidence, see this article for example; it's not that you can't compute the R^2 value, it's just that it may not mean the same thing/have the same desirable properties as in the linear-model case.