KNOWLEDGEBASE - ARTICLE #1355

R2 of weighted nonlinear fits.

Last modified October 8, 2013

When you fit a model to data with nonlinear regression, it is often useful to weight the data. This is most often done when the amount of variation is proportional to the Y value, so there is more scatter with large values. 

While weighted nonlinear regression is standard, there doesn't appear to be any standard way to compute the R2. We've changed the method used by Prism several times. 

Prism 6 and later

We realized there are two problems with the method used by Prism 5. First, it only works with weighting by 1/Y or 1/Y2, even though Prism offers some other choices (which are not used often). Second, and more serious, the sum of the weights used for fitting the curve is not the same as the sum of weights used for fitting the horizontal line. It doesn't make sense to take the ratio of the two weighted sum of squares, when the sum of weights was not the same for both. 

Prism 6 solves this problem in a simple way.

  1. Fit the model using relative (1/Y2) or Poisson (1/Y) weighting to compute the weighted sum-of-squares (wSSmodel)
  2. Remember the exact weight that each point gets in that fit. 
  3. Fit the data to a horizontal line model (Y=Mean + 0*X) using the same weights for each point,  to compute the weighted sum-of-squares (wSShorizontal). 
  4. The weighted R2 is:

                1.0 - (wSSmodel/wSShorizontal)

So the difference is that Prism uses exactly the same individual weights for each point when it fits the curve and when it fits the horizontal line. The sum of weights, of course, is identical in both cases, so it makes sense to take the ratio of the two weighted sum of squares to compute the R2

I don't know of any papers or texts that discuss the details of how to compute R2 in weighted nonlinear regression fits. Please let me know if you find such a reference. 

Prism 5.02 to 5.04 and Prism 5.0b to 5.0d

Prism 5 (except for the first releases) calculated the R2 of a weighted fit as detailed below:

  1. Fit the model using relative (1/Y2) or Poisson (1/Y) weighting to compute the weighted sum-of-squares (wSSmodel)
  2. Fit the data to a horizontal line model (Y=Mean + 0*X) using the same weighting scheme to compute the weighted sum-of-squares (wSShorizontal). 
  3. The weighted R2 is:

                1.0 - (wSSmodel/wSShorizontal)

This method will work with weighting by 1/Y or 1/Y2, but not the other weighting methods (which would result in different weights for different points in the horizontal fit case). 

From Prism 2 up to Prism 5.01 and 5.0a

 Even when you choose a weighed nonlinear regression, Prism calculated and reported the unweighted R2 for the fit determined by weighted nonlinear regression (and correctly labeled it 'unweighted'). 

 



Keywords: weighted r squared, unequal weights

Explore the Knowledgebase

Analyze, graph and present your scientific work easily with GraphPad Prism. No coding required.