Previous Page | Next Page

Tutorial: A Module for Linear Regression

Orthogonal Regression

In the previous section, you ran a module that computes parameter estimates and statistics for a linear regression model. All of the matrices used in the Regress module are global variables because the Regress module does not have any arguments. Consequently, you can use those matrices in additional calculations.

Suppose you want to correlate the parameter estimates. To do this, you can calculate the covariance of the estimates, then scale the covariance into a correlation matrix with values of 1 on the diagonal. You can perform these operations by using the following statements:

reset print;                  /* turns on auto printing   */
covb = xpxi*mse;              /* covariance of estimates */
s = 1/sqrt(vecdiag(covb));    /* standard errors */
corrb = diag(s)*covb*diag(s); /* correlation of estimates */

The RESET PRINT statement causes the IML procedure to print the result of each assignment statement, as shown in Figure 4.6. The covariance matrix of the estimates is contained in the covb matrix. The vector s contains the standard errors of the parameter estimates and is used to compute the correlation matrix of the estimates (corrb). These statistics are shown in Figure 4.6.

Figure 4.6 Covariance and Correlation Matrices for Estimates
covb 3 rows 3 cols (numeric)

14.72 -10.56 1.6
-10.56 8.5485714 -1.371429
1.6 -1.371429 0.2285714

s 3 rows 1 col (numeric)

0.260643
0.3420214
2.0916501

corrb 3 rows 3 cols (numeric)

1 -0.941376 0.8722784
-0.941376 1 -0.981105
0.8722784 -0.981105 1

You can also use the Regress module to carry out an orthogonalized regression version of the previous polynomial regression. In general, the columns of are not orthogonal. You can use the ORPOL function to generate orthogonal polynomials for the regression. Using them provides greater computing accuracy and reduced computing times. When you use orthogonal polynomial regression, you can expect the statistics of fit to be the same and expect the estimates to be more stable and uncorrelated.

To perform an orthogonal regression on the data, you must first create a vector that contains the values of the independent variable , which is the second column of the design matrix . Then, use the ORPOL function to generate orthogonal second degree polynomials. You can perform these operations by using the following statements:

x1 = x[,2];                   /* data = second column of X */
x = orpol(x1, 2);             /* generates orthogonal polynomials */
reset noprint;                /* turns off auto printing   */
run Regress;                  /* runs Regress module */

reset print;                  /* turns on auto printing   */
covb = xpxi*mse;
s = 1 / sqrt(vecdiag(covb));
corrb = diag(s)*covb*diag(s);
reset noprint;

Figure 4.7 Covariance and Correlation Matrices for Estimates
x1 5 rows 1 col (numeric)

1
2
3
4
5

x 5 rows 3 cols (numeric)

0.4472136 -0.632456 0.5345225
0.4472136 -0.316228 -0.267261
0.4472136 1.755E-17 -0.534522
0.4472136 0.3162278 -0.267261
0.4472136 0.6324555 0.5345225

Regression Results

sse dfe mse rsquare
6.4 2 3.2 0.9923518

Parameter Estimates

beta stdb t prob
33.093806 1.7888544 18.5 0.0029091
27.828043 1.7888544 15.556349 0.0041068
7.4833148 1.7888544 4.1833001 0.0526691

y yhat resid
1 1.2 -0.2
5 4 1
9 10.8 -1.8
23 21.6 1.4
36 36.4 -0.4

covb 3 rows 3 cols (numeric)

3.2 0 0
0 3.2 0
0 0 3.2

s 3 rows 1 col (numeric)

0.559017
0.559017
0.559017

corrb 3 rows 3 cols (numeric)

1 0 0
0 1 0
0 0 1

For these data, the off-diagonal values of the corrb matrix are displayed as zeros. For some analyses you might find that certain matrix elements are very close to zero but not exactly zero because of the computations of floating-point arithmetic. You can use the RESET FUZZ option to control whether small values are printed as zeros.

Previous Page | Next Page | Top of Page