RUN REGRESS (x, y, name, <tval>, <l1>, <l2>, <l3>);
The REGRESS module performs ordinary least squares regression. It is primarily used for demonstration purposes.
The inputs to the REGRESS subroutine are as follows:
is an numeric matrix, where m is the number of variables and n is the number of data points.
is an response vector.
is an matrix of variable names.
is an optional t-value.
are optional vectors that specify linear combinations of coefficients for hypothesis testing.
The design matrix is given by x, and y is the response vector. The name vector identifies each of the variables. If you specify a t-value, the module prints a table of observed and predicted values, residuals, hat diagonal, and confidence limits for the mean and predicted values. If you also specify linear combinations with l1, l2, and l3, the module performs the hypothesis test , where b is the vector of parameter estimates. An example follows:
/* U.S. Population for decades beginning 1790, in millions */ name = { "Intercept", "Decade", "Decade**2" }; x = { 1 1 1, 1 2 4, 1 3 9, 1 4 16, 1 5 25, 1 6 36, 1 7 49, 1 8 64 }; y = { 3.929, 5.308, 7.239, 9.638, 12.866, 17.069, 23.191, 31.443 }; /* 5 dof at 0.025 level to get 95% confidence interval */ tval = quantile("T", 1-0.025, 5); l1 = { 0 1 0 }; /* test hypothesis lb=0 for linear coef */ l2 = { 0 1 0, /* test hypothesis lb=0 for linear,quad */ 0 0 1 }; l3 = { 0 1 1 }; /* test hypothesis lb=0 for linear+quad */ run regress( x, y, name, tval, l1, l2, l3 );
Figure 26.2: Regression Analysis
y | yhat | resid | h | lowerm | upperm | lower | upper |
---|---|---|---|---|---|---|---|
3.929 | 4.499 | -0.57 | 0.7083 | 3.0017 | 5.9964 | 2.1737 | 6.8244 |
5.308 | 5.008 | 0.3 | 0.2798 | 4.067 | 5.949 | 2.9954 | 7.0207 |
7.239 | 6.5963 | 0.6427 | 0.2321 | 5.7391 | 7.4535 | 4.6214 | 8.5711 |
9.638 | 9.2638 | 0.3742 | 0.2798 | 8.3228 | 10.205 | 7.2511 | 11.276 |
12.866 | 13.011 | -0.145 | 0.2798 | 12.07 | 13.952 | 10.998 | 15.023 |
17.069 | 17.837 | -0.768 | 0.2321 | 16.979 | 18.694 | 15.862 | 19.812 |
23.191 | 23.742 | -0.551 | 0.2798 | 22.801 | 24.683 | 21.729 | 25.755 |
31.443 | 30.727 | 0.7164 | 0.7083 | 29.229 | 32.224 | 28.401 | 33.052 |