Take the 2-minute tour ×

I would first like to say, that I understand that calculating an R^2 value for a non-linear regression isn't exactly correct or a valid thing to do.

However, I'm in a transition period of performing most of our work in SigmaPlot over to R and for our non-linear (concentration-response) models, colleagues are used to seeing an R^2 value associated with the model to estimate goodness-of-fit.

SigmaPlot calculates the R^2 using 1-(residual SS/total SS), but in R I can't seem to extract the total SS (residual SS are reported in summary).

Any help in getting this to work would be greatly appreciated as I try and move us into using a better estimator of goodness-of-fit.


share|improve this question
Perhaps math.stackexchange.com might be able to offer more assistance? –  Aurum Aquila Apr 13 '11 at 21:50
Are you using fit <- nls(y ~x); summary(fit)? –  SiggyF Apr 13 '11 at 21:55
@DiggyF -- yes, exactly that. –  aule Apr 13 '11 at 22:05
There's an old discussion on it here: stat.ethz.ch/pipermail/r-help/2002-July/023461.html –  SiggyF Apr 13 '11 at 22:14
@aule You should post your answer in the Answer box. Give yourself a little checkmark :) –  mcpeterson Apr 13 '11 at 23:07

2 Answers 2

up vote 5 down vote accepted

I answered this in the comments earlier, but am posting it again as the solution I worked out.

Instead of extracting the total SS, I've just calculated them.

test.mdl<-nls(ctrl.adj~a/(1((conc.calc/x0)^b)), data=dataSet, start=list(a=100,b=10,x0=40), trace=T);


I get the same r^2 as when using SigmaPlot, so all should be good.

share|improve this answer

So the total variation in y is like (n-1)*var(y) and the proportion not explained my your model is sum(residuals(fit)^2) so do something like 1-(sum(residuals(fit)^2)/((n-1)*var(y)) )

share|improve this answer

Your Answer


