CALCULATING THE COEFFICIENTS (SLOPE AND INTERCEPT)

OF THE WEIGHTED LEAST SQUARES LINE

 

 

The equation of the Weighted Least Squares line is :

y* = a + b.x

with "b" the slope, and "a" the intercept.

The residual in i is :

yi* - yi  =  (a + b.xi ) - yi  

WLS wants to minimize the sum of the weighted squares of the residuals :

SSRw = i wi.(yi* - yi)² = i wi.(a + b.xi - yi

The coefficients "a" and "b" are obtained by setting to "0" the partial derivatives of SSRw with respect to "a" and to "b", that is :

            *  SSRw /a = 2.(a.i wi + b.i wi.xi  - i wi.yi ) = 0

            *  SSRw /b = 2.(a.i wi.xi   + b.i wi.xi² - i wi.xi.yi ) = 0

 

This linear system is easily solved to yield the solutions :

 

b =   [(iwi ).(iwi.xi.yi) - (iwi.xi).(i wi.yi)] / [(i wi).(iwi.xi²) - (iwi.x)²]           Slope

a = [(i wi.xi²).(iwi.yi) - (iwi.xi).(iwi.xi.yi)] / [(i wi).(iwi.xi²) - (iwi.x)²]          Intercept

 

 These equations are to be used as such only when each weight wi can be evaluated individually as the reciprocal of the (supposedely known) local variance of y.

 

Note :

    1) Set all wi to the same value w (homoscedasticity), and these equations reduce to the ordinary normal equations of Simple Linear Regression :

b = i(xi -  ).(yi -  ) /i(xi -  

a = - b.

 

    2) If var(y) is assumed to be inversely proportional to x, these equations reduce to :

 

b = (I.Sy - J.n) / (I.Sx - n²)     Slope

a = (J.Sx - n.Sy ) / (I.Sx - n²)    Intercept

 

 with the following notations :

    * I = i (1/xi) ,

    * J =  i (yi /xi).

    * Sx = i xi 

    * Sy = i yi 

 

I and J are infinitely large if one of the xi, say x0, is 0. But you can easily find the limits of "a" and of "b" when w0 .