I am newbie to WLS regression topic. I am being asked to fit a line to a data using WLS. I am working in minitab. My data is as follows:
cost (independent variable) (x-axis);
production (dependent variable) (y-axis).
A small sample of the data is as follow:
Cost Production
200 4000
50 1000
350 3500
1000 1000
500 3500
100 500
800 2000
What I have done till now is: (1) Outlier detection. (2) Using, cost and production data, I have found unstandardized residuals. (3) Then, absolute of the residuals. (4) Using cost as x-axis (independent) and absolute residuals as y-axis (or dependent data), I have found unstandardized predicted values. (5) Then, I have found weights as reciprocal of the square of the predicted values.
Now I want to plot the data and fit a line to it using WLS. This can be very basic and simple thing to most of you. But I am not able to figure it out that what I need to do after step (5) and how to fit a line using WLS?
After reading over web, I have understood that in minitab, I need to run regression>>regression>>fit regression model and there, I need to provide x and y axis data and the estimated weights. And in storage tab, I need to check the 'fits'. Once regression model is done, I need to plot the scatterplot and there I should add a 'calculated line' with fits and the relevant x or y- axis.
Q1. Now, firstly, I would like to ask if I am doing the entire
process, upto estimating weights and fits, correctly?
Q2. Secondly, if I am fitting the line using WLS correctly? i.e. Do
fits need to be plotted in the graph to fit a line using WLS?
Q3. In the plot, should *'fits'* be assigned in the place of dependent
variable or independent variable?
Wheresoever, I am not doing it right, it shall be helpful if someone can tell me the relevant steps to follow in spss or minitab.
[For more details about the kind of graph/ plot that I need][1]
[1]: https://onlinecourses.science.psu.edu/stat501/node/397/
On the above URL, look at the 4th Figure i.e., scatterplot between cost vs num.responses, where black line shows OLS and red line shows WLS. I need such a scatterplot with two lines. For this, I need to construct or fit a line to my data using WLS.
Best Answer
Edit: I've re-written my post, and noticed that I made an error in computing the weights, where I used residuals instead of fitted values in the calculation. The error is now fixed.
Also note that I assume the poster is asking for the motions of fitting the WLS.
I am not familiar with Minitab, so I have instead recreated the process in the link that you have provided using Stata, including the example dataset from the linked website. I have included selected output where appropriate.
Start with data input and verify it.
Let's fit a simple OLS model and plot the model overlaid on a scatter plot of the data.
The OLS model results:
This model matches the one described in the link. Now let's look at the scatter plot with overlaid OLS model, and the residual vs predictor plot. Note that the "resid" option of predict computes the residuals. In the case of OLS, residuals are nothing more than the observed values (y_obs) minus the fitted values (y_hat), resid = y_obs - y_hat.
The plots are:
To prepare for WLS, start with computing the absolute residuals (those computed above). Then plot the absolute residuals vs the predictor.
Now lets use those absolute residual values to start computing weights for WLS. To get weights for the WLS, you fit the OLS regression of the absolute residuals against the predictor (abs_res ~ num_responses).
The fitted model of absolute residuals using num_responses as a sole predictor is:
You can verify the linear predictor (lp) manually by computed the predicted value from this model for the first two observations.
Finally, we can use the weights to fit a WLS model, and the plot the OLS and WLS models over the original data.
The WLS model is:
Note that the model and plot match what is reported in the linked page.