# Lecture 19

Instructions for creating prediction intervals using weighted regression from the Minitab Program: If you perform weighted regression and want to predict responses for new observations to obtain prediction intervals, you must calculate the prediction intervals manually using the following steps. Because of the way MSE is calculated in weighted regression, the prediction interval displayed in the output is incorrect. If you are only interested in obtaining the fits, standard error of the fits, or the confidence interval, you do not need to follow these steps; instead follow the steps in To predict responses for new observations.

Preparing the data

1. Create a column of 1s, the same length as the predictor and response columns.

2. Create a column for each predictor containing the new observations. The number of predictors columns for new observations must match the number of predictor columns in your original data.

3. Create a column of weights for the new observations.

4. Using Calc > Calculator, calculate the square roots of the weights for the new observations and store in a column called SqrtWeight.

5. Using Calc > Calculator, multiply each predictor column containing the new observations by the SqrtWeight column and store in a column.

Performing weighted regression

6. Choose Stat > Regression > Regression. In Response, enter the response column. In Predictors, enter the column of 1s as your first predictor. Then enter your original predictor columns.

7. Click Options. In Weights, enter the column of weights for your original data. Then uncheck Fit intercept.

8. In Prediction intervals for new observations, enter the SqrtWeight column you calculated in Step 4. Then enter the predictor columns you created in Step 5, following the same order in which you entered the predictors in Step 6.

9. Under Storage, check Prediction limits. Click OK in each dialog box.

Transforming prediction limits

10. Using Calc > Calculator, divide the columns of stored prediction limits by the column SqrtWeight (from step 3). This transformation provides the correct prediction limits. It is important to note that if you also displayed or stored the fits, standard error of the fits, or confidence limits during this procedure, you must also divide them by the square roots of the weights to obtain the correct results.

Commands for plotting the prediction bands we just formed:

```Plot 'PLIM1'*'experience' 'PLIM2'*'experience' 'salary'*'experience';
Symbol;
Type 0 0 6;
Color 1;
Size 1.0;
Connect;
Type 1 1 0;
Color 1;
Size 1;
Overlay.
```
Consider our (old) salary data from last time for weighted regression:
```experience      salary
7       26075
28      79370
23      65726
18      41983
19      62309
15      41154
24      53610
13      33697
2       22444
8       32562
20      43076
21      56000
18      58667
7       22210
2       20521
18      49727
11      33233
21      43628
4       16105
24      65644
20      63022
20      47780
15      38853
25      66537
25      67447
28      64785
26      61581
27      70678
20      51301
18      39346
1       24833
26      65929
20      41721
26      82641
28      99139
23      52624
17      50594
25      53272
26      65343
19      46216
16      54288
3       20844
12      32586
23      71235
20      36530
19      52745
27      67282
25      80931
12      32303
11      38371
```