edit deleted reply as it was incorrect
I have a couple of questions regarding weighted linear regression that i will be using for the data analysis of my research work. I work in the area of Analytical chemistry, but i have to do a lot of data analysis stuff that includes linear regression (finding the best fit line and the corresponding slope, intercept etc.).Please share your opinions regarding my following questions.
1. Suppose i have an independent variable "X" and a dependent variable "Y". For different values of X and Y, I can obtain a best fit line in Microsoft Excel without using any weighting. How can i obtain a best fit line if i use a weighting scheme such as 1/x , 1/x/x , etc. ? Are there any free Statistical softwares available for drawing these best fit lines?
2. Also, in my research i will be having some baseline value of "Y" when X=0 (for example, for x=0, y = 10 units). In such a case, how is the weighting considered when x=0 ? I have this question because 1/x, 1/x/x cannot be defined when x=0 . How do these statistical softwares consider weighting in such a case? Will these softwares ignore the point (x,y) when x=0? What is the right thing to do in such a scenario?
Please provide information to the concerned questions.
disclaimer: I made this up.
Your regression line is
You want to minimise:
where is the weight applying to data point i.
(subscripts are dropped for the rest of this post)
Take derivatives with respect to a and set to 0
Take derivatives with respect to b and set to 0
if you solve those simultaneously i think(!) you get
So, to answer your question:
You can get the WLS fit line by solving those two equations simultaneously for a and b.
If you try to use a weighting of 1/x at x=0, you will get an undefined answer. You could choose a more suitable weighting function, manually set a very high weighting (eg 100000000000000) for x=0, or discard those data points.
Once again, i remind you that i made the above algebra up, and you should check it yourself!
google also suggests the following:
an excel implementation of WLS:
a formula for WLS:
Google Answers: Weighted Least Linear Square Method simple example