Hi All,
I have a question about WLS using basis functions. I am tasked with writing some code to automate a WLS procedure.
Initially I am taking Ordinary Least Squares on some data (X & Y). I achieve this by using a polynomial basis function, resulting in a matrix [X] corresponding to 1,X,X^2.
From this I generate a BLUE using:
b = (X'X)^{-1} X'Y
(so far so good), this gives an regression fit, y = aX^{2} + bX + c.
Now, the problem relates to the automation, it is assumed that the data is heteroskedastic and that WLS should be used instead of OLS.
The various books I have read have suggested using the OLS answer to then weight the X & Y data corresponding to the inverse of each measurement's variance (1/(sigma_{i}^{2})) from the average measurement variance. Creating a weighting matrix ''W'' with the diagonal the inverse of the measurements variance.
Therefore the estimator is given by:
b = (X'WX)^{-1} XW'Y
Such that there is now a weighting towards each measurement.
The problem I encounter is that the OLS provides a fit to the data, the WLS fit, however, does not look correct (the polynomial function is vastly different from the OLS estimate).
Is there a problem with my methodology anywhere?
Many thanks,
Hob
I have a question about WLS using basis functions. I am tasked with writing some code to automate a WLS procedure.
Initially I am taking Ordinary Least Squares on some data (X & Y). I achieve this by using a polynomial basis function, resulting in a matrix [X] corresponding to 1,X,X^2.
From this I generate a BLUE using:
b = (X'X)^{-1} X'Y
(so far so good), this gives an regression fit, y = aX^{2} + bX + c.
Now, the problem relates to the automation, it is assumed that the data is heteroskedastic and that WLS should be used instead of OLS.
The various books I have read have suggested using the OLS answer to then weight the X & Y data corresponding to the inverse of each measurement's variance (1/(sigma_{i}^{2})) from the average measurement variance. Creating a weighting matrix ''W'' with the diagonal the inverse of the measurements variance.
Therefore the estimator is given by:
b = (X'WX)^{-1} XW'Y
Such that there is now a weighting towards each measurement.
The problem I encounter is that the OLS provides a fit to the data, the WLS fit, however, does not look correct (the polynomial function is vastly different from the OLS estimate).
Is there a problem with my methodology anywhere?
Many thanks,
Hob