Solving Standard Least-Squares Problems
This section illustrates how to solve some ordinary
least-squares problems and generalizations of those problems
by formulating them as transformation regression problems.
One problem involves finding linear and
nonlinear regression functions in a scatter plot.
The next problem involves simultaneously fitting
two lines or curves through a scatter plot.
The last problem involves finding the overall fit of a multi-way
main-effects and interactions analysis-of-variance model.
Nonlinear Regression Functions
This example uses PROC TRANSREG in simple
regression to find the optimal regression
line, a nonlinear but monotone regression function,
and a nonlinear nonmonotone regression function.
A regression line can be found by specifying
proc transreg;
model identity(y) = identity(x);
output predicted;
run;
A monotone regression function (in this case, a monotonically
decreasing regression function, since the correlation
coefficient is negative) can be found by requesting an MSPLINE
transformation of the independent variable, as follows.
proc transreg;
model identity(y) = mspline(x / nknots=9);
output predicted;
run;
The monotonicity restriction can be relaxed by requesting a
SPLINE transformation of the independent variable, as shown below.
proc transreg;
model identity(y) = spline(x / nknots=9);
output predicted;
run;
In this example, it is not useful to plot the transformation
TX, since TX is just an intermediate result used in
finding a regression function through the original X and Y
scatter plot.
The following statements provide a specific example of using
the TRANSREG procedure for fitting nonlinear regression functions.
These statements produce Figure 65.15 through
Figure 65.18.
title 'Linear and Nonlinear Regression Functions';
*---Generate an Artificial Nonlinear Scatter Plot---;
*---SAS/IML Software is Required for this Example---;
proc iml;
N = 500;
X = (1:N)`;
X = X/(N/200);
Y = -((X/50)-1.5)##2 + sin(X/8) + sqrt(X)/5 + 2*log(X) + cos(X);
X = X - X[:,];
X = -X / sqrt(X[##,]/(n-1));
Y = Y - Y[:,];
Y = Y / sqrt(Y[##,]/(n-1));
all = Y || X;
create outset from all;
append from all;
quit;
data A;
set outset(rename=(col1=Y col2=X));
if Y<-2 then Y=-2 + ranuni(7654321)/2;
X1=X; X2=X; X3=X; X4=X;
run;
*---Predicted Values for the Linear Regression Line---;
proc transreg data=A;
title2 'A Linear Regression Line';
model identity(Y)=identity(X);
output out=A pprefix=L;
id X1-X4;
run;
*---Predicted Values for the Monotone Regression Function---;
proc transreg data=A;
title2 'A Monotone Regression Function';
model identity(Y)=mspline(X / nknots=9);
output out=A pprefix=M;
id X1-X4 LY;
run;
*---Predicted Values for the Nonmonotone Regression Function---;
proc transreg data=A;
title2 'A Nonmonotone Regression Function';
model identity(Y)=spline(X / nknots=9);
output out=A predicted;
id X1-X4 LY MY;
run;
*---Plot the Results---;
goptions goutmode=replace nodisplay;
%let opts = haxis=axis2 vaxis=axis1 frame cframe=ligr;
* Depending on your goptions, these plot options may work better:
* %let opts = haxis=axis2 vaxis=axis1 frame;
proc gplot data=A;
title;
axis1 minor=none label=(angle=90 rotate=0)
order=(-2 to 2 by 2);
axis2 minor=none order=(-2 to 2 by 2);
plot Y*X1=1 / &opts name='tregnl1';
plot Y*X2=1 LY*X2=2 / overlay &opts name='tregnl2';
plot Y*X3=1 MY*X3=2 / overlay &opts name='tregnl3';
plot Y*X4=1 PY*X4=2 / overlay &opts name='tregnl4';
symbol1 color=blue v=star i=none;
symbol2 color=yellow v=none i=join;
label X1 = 'Nonlinear Scatter Plot'
X2 = 'Linear Regression, r**2 = 0.14580'
X3 = 'Monotone Function, r**2 = 0.60576'
X4 = 'Nonlinear Function, r**2 = 0.89634';
run; quit;
goptions display;
proc greplay nofs tc=sashelp.templt template=l2r2;
igout gseg;
treplay 1:tregnl1 2:tregnl3 3:tregnl2 4:tregnl4;
run; quit;
Linear and Nonlinear Regression Functions |
A Linear Regression Line |
TRANSREG Univariate Algorithm Iteration History for Identity(Y) |
Iteration Number |
Average Change |
Maximum Change |
R-Square |
Criterion Change |
Note |
1 |
0.00000 |
0.00000 |
0.14580 |
|
Converged |
|
Figure 65.15: A Linear Regression Line
Linear and Nonlinear Regression Functions |
A Monotone Regression Function |
TRANSREG MORALS Algorithm Iteration History for Identity(Y) |
Iteration Number |
Average Change |
Maximum Change |
R-Square |
Criterion Change |
Note |
1 |
0.62131 |
1.34209 |
0.14580 |
|
|
2 |
0.00000 |
0.00000 |
0.60576 |
0.45995 |
Converged |
|
Figure 65.16: A Monotone Regression Function
Linear and Nonlinear Regression Functions |
A Nonmonotone Regression Function |
TRANSREG MORALS Algorithm Iteration History for Identity(Y) |
Iteration Number |
Average Change |
Maximum Change |
R-Square |
Criterion Change |
Note |
1 |
0.83948 |
2.78984 |
0.14580 |
|
|
2 |
0.00000 |
0.00000 |
0.89634 |
0.75054 |
Converged |
|
Figure 65.17: A Nonmonotone Regression Function
Figure 65.18: Linear, Monotone, and Nonmonotone Regression Functions
The squared correlation is only 0.15 for the
linear regression, showing that a simple linear
regression model is not appropriate for these data.
By relaxing the constraints placed on the regression line,
the proportion of variance accounted for increases from
0.15 (linear) to 0.61 (monotone) to 0.90 (nonmonotone).
Relaxing the linearity constraint allows the
regression function to bend and more closely
follow the right portion of the scatter plot.
Relaxing the monotonicity constraint allows
the regression function to follow the periodic
portion of the left side of the plot more closely.
The nonlinear MSPLINE transformation is a
quadratic spline with knots at the deciles.
The nonlinear nonmonotonic SPLINE transformation
is a cubic spline with knots at the deciles.
Different knots and different degrees
would produce slightly different results.
The two nonlinear regression functions could be closely
approximated by simpler piecewise linear regression functions.
The monotone function could be approximated by a
two-piece line with a single knot at the elbow.
The nonmonotone function could be approximated by
a six-piece function with knots at the five elbows.
With this type of problem (one dependent variable with no missing
values that is not transformed and one independent variable
that is nonlinearly transformed), PROC TRANSREG always iterates
exactly twice (although only one iteration is necessary).
The first iteration reports the R2 for the linear
regression line and finds the optimal transformation of X.
Since the data change in the first iteration, a second
iteration is performed, which reports the R2 for the
final nonlinear regression function, and zero data change.
The predicted values, which are a linear function of the optimal
transformation of X, contain the y-coordinates
for the nonlinear regression function.
The variance of the predicted values divided by the variance of
Y is the R2 for the fit of the nonlinear regression function.
When X is monotonically transformed, the transformation
of X is always monotonically increasing, but the
predicted values increase if the correlation
is positive and decrease for negative correlations.
Simultaneously Fitting Two Regression Functions
One application of ordinary multiple regression is fitting
two or more regression lines through a single scatter plot.
With PROC TRANSREG, this application can easily
be generalized to fit separate or parallel curves.
To illustrate, consider a data set with two groups.
The data set has a continuous independent variable X, a
continuous dependent variable Y, and a group membership variable
G that has the value 1 for one group and 2 for the other group.
The following code shows how PROC TRANSREG can be
used to fit two lines, curves,
and monotone curves simultaneously through a scatter plot.
You can use this code with an appropriate
number-list for the KNOTS= t-option.
proc transreg data=A dummy;
title 'Parallel Lines, Separate Intercepts';
model identity(Y)=class(G) identity(X);
output predicted;
run;
proc transreg data=A;
title 'Parallel Monotone Curves, Separate Intercepts';
model identity(Y)=class(G) mspline(X / knots=-1.5 to 2.5 by 0.5);
output predicted;
run;
proc transreg data=A dummy;
title 'Parallel Curves, Separate Intercepts';
model identity(Y)=class(G) spline(X / knots=-1.5 to 2.5 by 0.5);
output predicted;
run;
proc transreg data=A;
title 'Separate Slopes, Same Intercept';
model identity(Y)=class(G / zero=none) * identity(X);
output predicted;
run;
proc transreg data=A;
title 'Separate Monotone Curves, Same Intercept';
model identity(Y) = class(G / zero=none) *
mspline(X / knots=-1.5 to 2.5 by 0.5);
output predicted;
run;
proc transreg data=A dummy;
title 'Separate Curves, Same Intercept';
model identity(Y) = class(G / zero=none) *
spline(X / knots=-1.5 to 2.5 by 0.5);
output predicted;
run;
proc transreg data=A;
title 'Separate Slopes, Separate Intercepts';
model identity(Y) = class(G / zero=none) | identity(X);
output predicted;
run;
proc transreg data=A;
title 'Separate Monotone Curves, Separate Intercepts';
model identity(Y) = class(G / zero=none) |
mspline(X / knots=-1.5 to 2.5 by 0.5);
output predicted;
run;
proc transreg data=A dummy;
title 'Separate Curves, Separate Intercepts';
model identity(Y) = class(G / zero=none) |
spline(X / knots=-1.5 to 2.5 by 0.5);
output predicted;
run;
Since the variables X1 and X2 both have a large
partition of zeros, the KNOTS= t-option is specified instead of
the NKNOTS= t-option. The following
example generates an artificial data set with two curves. In the
interest of space, only the preceding separate curves, separate intercepts example
is run.
title 'Separate Curves, Separate Intercepts';
data A;
do X = -2 to 3 by 0.025;
G = 1;
Y = 8*(X*X + 2*cos(X*6)) + 15*normal(7654321);
output;
G = 2;
Y = 4*(-X*X + 4*sin(X*4)) - 40 + 15*normal(7654321);
output;
end;
run;
proc transreg data=A dummy;
model identity(Y) = class(G / zero=none) |
spline(X / knots=-1.5 to 2.5 by 0.5);
output predicted;
run;
proc gplot;
axis1 minor=none;
axis2 minor=none label=(angle=90 rotate=0);
symbol1 color=blue v=star i=none;
symbol2 color=yellow v=dot i=none;
plot Y*X=1 PY*X=2 /overlay frame cframe=ligr haxis=axis1
vaxis=axis2 HREF=0 vref=0;
run; quit;
The previous statements produce Figure 65.19 through
Figure 65.20.
Separate Curves, Separate Intercepts |
TRANSREG MORALS Algorithm Iteration History for Identity(Y) |
Iteration Number |
Average Change |
Maximum Change |
R-Square |
Criterion Change |
Note |
0 |
0.42724 |
4.48710 |
0.71020 |
|
|
1 |
0.00000 |
0.00000 |
0.86604 |
0.15584 |
Converged |
|
Figure 65.19: Fitting Models: Separate Curves, Separate Intercepts
Figure 65.20: Plot for the Separate Curves, Separate Intercepts Example
Unbalanced ANOVA without Dummy Variables
This example illustrates that an analysis of variance model can be
formulated as a simple regression model with optimal scoring. The
purpose of the example is to explain one aspect of how PROC TRANSREG works,
not to propose an alternative way of performing an analysis of variance.
Finding the overall fit of a large, unbalanced analysis
of variance model can be handled as an optimal scoring
problem without creating large, sparse design matrices.
For example, consider an unbalanced full main-effects
and interactions ANOVA model with six factors.
Assume that a SAS data set is created with factor level
indicator variables C1 through C6 and dependent
variable Y.
If each factor level consists of nonblank single characters, you
can create a cell indicator in a DATA step with the statement
x=compress(c1||c2||c3||c4||c5||c6);
The following statements optimally score
X (using the OPSCORE transformation) and do not transform Y.
The final R2 reported
is the R2 for the full analysis of variance model.
proc transreg;
model identity(y)=opscore(x);
output;
run;
The R2 displayed by the preceding statements is
the same as the R2 that would be reported
by both of the following PROC GLM runs.
proc glm;
class x;
model y=x;
run;
proc glm;
class c1-c6;
model y=c1|c2|c3|c4|c5|c6;
run;
PROC TRANSREG optimally scores the classes of X, within the space of a
single variable with values linearly related to the cell means, so the
full ANOVA problem is reduced to a simple regression problem with
an optimal independent variable. PROC TRANSREG requires only one iteration
to find the optimal scoring of X but, by default, performs a second
iteration, which reports no data changes.
Hypothesis Tests for Simple Univariate Models
If the dependent variable has one parameter (IDENTITY, LINEAR with no
missing values, and so on) and if there are no monotonicity constraints,
PROC TRANSREG fits univariate models, which can also be fit with a DATA
step and PROC REG. This is illustrated with an artificial data set.
data htex;
do i = 0.5 to 10 by 0.5;
x1 = log(i);
x2 = sqrt(i) + sin(i);
x3 = 0.05 * i * i + cos(i);
y = x1 - x2 + x3 + 3 * normal(7);
x1 = x1 + normal(7);
x2 = x2 + normal(7);
x3 = x3 + normal(7);
output;
end;
run;
Both PROC TRANSREG and PROC REG are run to fit the same polynomial
regression model. The ANOVA and regression tables from PROC TRANSREG
are displayed in Figure 65.21. The ANOVA and regression tables from PROC
REG are displayed in Figure 65.22. The SHORT a-option is specified to suppress
the iteration history.
proc transreg data=htex ss2 short;
title 'Fit a Polynomial Regression Model with PROC TRANSREG';
model identity(y) = spline(x1);
run;
Fit a Polynomial Regression Model with PROC TRANSREG |
Identity(y) |
Algorithm converged. |
The TRANSREG Procedure Hypothesis Tests for Identity(y) |
Univariate ANOVA Table Based on the Usual Degrees of Freedom |
Source |
DF |
Sum of Squares |
Mean Square |
F Value |
Pr > F |
Model |
3 |
5.8365 |
1.94550 |
0.14 |
0.9329 |
Error |
16 |
218.3073 |
13.64421 |
|
|
Corrected Total |
19 |
224.1438 |
|
|
|
Root MSE |
3.69381 |
R-Square |
0.0260 |
Dependent Mean |
0.85490 |
Adj R-Sq |
-0.1566 |
Coeff Var |
432.07258 |
|
|
Univariate Regression Table Based on the Usual Degrees of Freedom |
Variable |
DF |
Coefficient |
Type II Sum of Squares |
Mean Square |
F Value |
Pr > F |
Intercept |
1 |
1.4612767 |
18.8971 |
18.8971 |
1.38 |
0.2565 |
Spline(x1) |
3 |
-0.3924013 |
5.8365 |
1.9455 |
0.14 |
0.9329 |
|
Figure 65.21: ANOVA and Regression Output from PROC TRANSREG
data htex2;
set htex;
x1_1 = x1;
x1_2 = x1 * x1;
x1_3 = x1 * x1 * x1;
run;
proc reg;
title 'Fit a Polynomial Regression Model with PROC REG';
model y = x1_1 - x1_3;
run;
Fit a Polynomial Regression Model with PROC REG |
The REG Procedure |
Model: MODEL1 |
Dependent Variable: y |
Analysis of Variance |
Source |
DF |
Sum of Squares |
Mean Square |
F Value |
Pr > F |
Model |
3 |
5.83651 |
1.94550 |
0.14 |
0.9329 |
Error |
16 |
218.30729 |
13.64421 |
|
|
Corrected Total |
19 |
224.14380 |
|
|
|
Root MSE |
3.69381 |
R-Square |
0.0260 |
Dependent Mean |
0.85490 |
Adj R-Sq |
-0.1566 |
Coeff Var |
432.07258 |
|
|
Parameter Estimates |
Variable |
DF |
Parameter Estimate |
Standard Error |
t Value |
Pr > |t| |
Intercept |
1 |
1.22083 |
1.47163 |
0.83 |
0.4190 |
x1_1 |
1 |
0.79743 |
1.75129 |
0.46 |
0.6550 |
x1_2 |
1 |
-0.49381 |
1.50449 |
-0.33 |
0.7470 |
x1_3 |
1 |
0.04422 |
0.32956 |
0.13 |
0.8949 |
|
Figure 65.22: ANOVA and Regression Output from PROC REG
The PROC TRANSREG regression table differs in several important ways
from the parameter estimate table produced by PROC REG. The REG
procedure displays standard
errors and ts. PROC TRANSREG displays Type II sums of squares, mean
squares, and Fs. The difference is because the numerator degrees of freedom
are not always 1, so t-tests are not uniformly appropriate. When
the degrees of freedom for variable xj is 1, the following
relationships hold between the standard errors and the
Type II sums of squares (SSj):
and
PROC TRANSREG does not provide tests of the individual terms that go
into the transformation. (However it could if BSPLINE or PSPLINE had
been specified instead of SPLINE.) The test of SPLINE(X1) is the same as the
test of the overall model. The intercepts are different due to the
different numbers of variables and their standardizations.
In the next example, both X1 and X2 are transformed in the first PROC
TRANSREG step, and PROC TRANSREG is used instead of a DATA step to
create the polynomials for PROC REG. Both PROC TRANSREG and PROC REG
fit the same polynomial regression model. The output from PROC TRANSREG
is in Figure 65.23.
The output from PROC REG is in Figure 65.24.
proc transreg data=htex ss2 dummy;
title 'Two-Variable Polynomial Regression';
model identity(y) = spline(x1 x2);
run;
proc transreg noprint data=htex maxiter=0;
/* Use PROC TRANSREG to prepare input to PROC REG */
model identity(y) = pspline(x1 x2);
output out=htex2;
run;
proc reg;
model y = x1_1-x1_3 x2_1-x2_3;
test x1_1, x1_2, x1_3;
test x2_1, x2_2, x2_3;
run;
Two-Variable Polynomial Regression |
TRANSREG MORALS Algorithm Iteration History for Identity(y) |
Iteration Number |
Average Change |
Maximum Change |
R-Square |
Criterion Change |
Note |
0 |
0.69502 |
4.73421 |
0.08252 |
|
|
1 |
0.00000 |
0.00000 |
0.17287 |
0.09035 |
Converged |
Hypothesis Test Iterations Excluding Spline(x1) |
TRANSREG MORALS Algorithm Iteration History for Identity(y) |
Iteration Number |
Average Change |
Maximum Change |
R-Square |
Criterion Change |
Note |
0 |
0.03575 |
0.32390 |
0.15097 |
|
|
1 |
0.00000 |
0.00000 |
0.15249 |
0.00152 |
Converged |
Hypothesis Test Iterations Excluding Spline(x2) |
TRANSREG MORALS Algorithm Iteration History for Identity(y) |
Iteration Number |
Average Change |
Maximum Change |
R-Square |
Criterion Change |
Note |
0 |
0.45381 |
1.43736 |
0.00717 |
|
|
1 |
0.00000 |
0.00000 |
0.02604 |
0.01886 |
Converged |
|
Figure 65.23: Two-Variable Polynomial Regression Output from PROC TRANSREG
Two-Variable Polynomial Regression |
The TRANSREG Procedure Hypothesis Tests for Identity(y) |
Univariate ANOVA Table Based on the Usual Degrees of Freedom |
Source |
DF |
Sum of Squares |
Mean Square |
F Value |
Pr > F |
Model |
6 |
38.7478 |
6.45796 |
0.45 |
0.8306 |
Error |
13 |
185.3960 |
14.26123 |
|
|
Corrected Total |
19 |
224.1438 |
|
|
|
Root MSE |
3.77640 |
R-Square |
0.1729 |
Dependent Mean |
0.85490 |
Adj R-Sq |
-0.2089 |
Coeff Var |
441.73431 |
|
|
Univariate Regression Table Based on the Usual Degrees of Freedom |
Variable |
DF |
Coefficient |
Type II Sum of Squares |
Mean Square |
F Value |
Pr > F |
Intercept |
1 |
3.5437125 |
35.2282 |
35.2282 |
2.47 |
0.1400 |
Spline(x1) |
3 |
0.3644562 |
4.5682 |
1.5227 |
0.11 |
0.9546 |
Spline(x2) |
3 |
-1.3551738 |
32.9112 |
10.9704 |
0.77 |
0.5315 |
|
Two-Variable Polynomial Regression |
The REG Procedure |
Model: MODEL1 |
Dependent Variable: y |
Analysis of Variance |
Source |
DF |
Sum of Squares |
Mean Square |
F Value |
Pr > F |
Model |
6 |
38.74775 |
6.45796 |
0.45 |
0.8306 |
Error |
13 |
185.39605 |
14.26123 |
|
|
Corrected Total |
19 |
224.14380 |
|
|
|
Root MSE |
3.77640 |
R-Square |
0.1729 |
Dependent Mean |
0.85490 |
Adj R-Sq |
-0.2089 |
Coeff Var |
441.73431 |
|
|
Parameter Estimates |
Variable |
Label |
DF |
Parameter Estimate |
Standard Error |
t Value |
Pr > |t| |
Intercept |
Intercept |
1 |
10.77824 |
7.55244 |
1.43 |
0.1771 |
x1_1 |
x1 1 |
1 |
0.40112 |
1.81024 |
0.22 |
0.8281 |
x1_2 |
x1 2 |
1 |
0.25652 |
1.66023 |
0.15 |
0.8796 |
x1_3 |
x1 3 |
1 |
-0.11639 |
0.36775 |
-0.32 |
0.7567 |
x2_1 |
x2 1 |
1 |
-14.07054 |
12.50521 |
-1.13 |
0.2809 |
x2_2 |
x2 2 |
1 |
5.95610 |
5.97952 |
1.00 |
0.3374 |
x2_3 |
x2 3 |
1 |
-0.80608 |
0.87291 |
-0.92 |
0.3726 |
|
Figure 65.24: Two-Variable Polynomial Regression Output from PROC REG
Two-Variable Polynomial Regression |
The REG Procedure |
Model: MODEL1 |
Test 1 Results for Dependent Variable y |
Source |
DF |
Mean Square |
F Value |
Pr > F |
Numerator |
3 |
1.52272 |
0.11 |
0.9546 |
Denominator |
13 |
14.26123 |
|
|
Two-Variable Polynomial Regression |
The REG Procedure |
Model: MODEL1 |
Test 2 Results for Dependent Variable y |
Source |
DF |
Mean Square |
F Value |
Pr > F |
Numerator |
3 |
10.97042 |
0.77 |
0.5315 |
Denominator |
13 |
14.26123 |
|
|
|
There are three iteration histories: one for the overall model and two
for the two independent variables. The first PROC TRANSREG
iteration history shows the R2 of 0.17287 for the fit of the
overall model. The second is for
model identity(y) = spline(x2);
which excludes
SPLINE(X1). The third is for
model identity(y) = spline(x1);
which excludes SPLINE(X2). The difference between the first and second
R2 times the total sum of squares is the model sum of squares
for SPLINE(X1)
-
(0.17287 - 0.15249) ×224.143800 = 4.568165
The difference between the first and third R2 times the total
sum of squares is the model sum of squares for SPLINE(X2)
-
(0.17287 - 0.02604) ×224.143800 = 32.911247
The TEST statement in PROC REG tests the null hypothesis that the vector
of parameters for X1_1 X1_2 X1_3 is zero. This is
the same test as the SPLINE(X1) test used by PROC TRANSREG.
Similarly, the PROC REG
test that the vector of parameters for X2_1 X2_2
X2_3 is zero is the same as the PROC TRANSREG SPLINE(X2) test. So for
models with no monotonicity constraints and no dependent variable
transformations, PROC TRANSREG
provides little more than a different packaging of standard
least-squares methodology.
Hypothesis Tests with Monotonicity Constraints
Now consider a model with monotonicity constraints. This model has no
counterpart in PROC REG.
proc transreg data=htex ss2 short;
title 'Monotone Splines';
model identity(y) = mspline(x1-x3 / nknots=3);
run;
The SHORT a-option is specified to suppress the iteration histories. Two ANOVA
tables are displayed -one using
liberal degrees of freedom and one using
conservative degrees of freedom. All sums of squares and the
R2s are the same for both tables. What differs are the degrees
of freedom and statistics that are computed using degrees of freedom.
The liberal test has 8 model degrees of freedom and 11 error degrees
of freedom, whereas the conservative test has 15 model degrees of
freedom and only 4 error degrees of freedom. The
"true" p-value is between 0.8462 and 0.9997, so clearly
you would fail to reject the null hypothesis. Unfortunately, results
are not always this clear. See Figure 65.25.
Identity(y) |
Algorithm converged. |
The TRANSREG Procedure Hypothesis Tests for Identity(y) |
Univariate ANOVA Table Based on Liberal Degrees of Freedom |
Source |
DF |
Sum of Squares |
Mean Square |
F Value |
Liberal p |
Model |
8 |
58.0534 |
7.25667 |
0.48 |
>= 0.8462 |
Error |
11 |
166.0904 |
15.09913 |
|
|
Corrected Total |
19 |
224.1438 |
|
|
|
Root MSE |
3.88576 |
R-Square |
0.2590 |
Dependent Mean |
0.85490 |
Adj R-Sq |
-0.2799 |
Coeff Var |
454.52581 |
|
|
Univariate ANOVA Table Based on Conservative Degrees of Freedom |
Source |
DF |
Sum of Squares |
Mean Square |
F Value |
Conservative p |
Model |
15 |
58.0534 |
3.87022 |
0.09 |
<= 0.9997 |
Error |
4 |
166.0904 |
41.52261 |
|
|
Corrected Total |
19 |
224.1438 |
|
|
|
Root MSE |
6.44380 |
R-Square |
0.2590 |
Dependent Mean |
0.85490 |
Adj R-Sq |
-2.5197 |
Coeff Var |
753.74578 |
|
|
|
Figure 65.25: Monotone Spline Transformations
The TRANSREG Procedure Hypothesis Tests for Identity(y) |
Univariate Regression Table Based on Liberal Degrees of Freedom |
Variable |
DF |
Coefficient |
Type II Sum of Squares |
Mean Square |
F Value |
Liberal p |
Intercept |
1 |
4.8687676 |
54.7372 |
54.7372 |
3.63 |
>= 0.0834 |
Mspline(x1) |
2 |
-0.6886834 |
12.1943 |
6.0972 |
0.40 |
>= 0.6773 |
Mspline(x2) |
3 |
-1.8237319 |
46.3155 |
15.4385 |
1.02 |
>= 0.4199 |
Mspline(x3) |
3 |
0.8646155 |
24.6840 |
8.2280 |
0.54 |
>= 0.6616 |
Univariate Regression Table Based on Conservative Degrees of Freedom |
Variable |
DF |
Coefficient |
Type II Sum of Squares |
Mean Square |
F Value |
Conservative p |
Intercept |
1 |
4.8687676 |
54.7372 |
54.7372 |
1.32 |
<= 0.3149 |
Mspline(x1) |
5 |
-0.6886834 |
12.1943 |
2.4389 |
0.06 |
<= 0.9959 |
Mspline(x2) |
5 |
-1.8237319 |
46.3155 |
9.2631 |
0.22 |
<= 0.9344 |
Mspline(x3) |
5 |
0.8646155 |
24.6840 |
4.9368 |
0.12 |
<= 0.9809 |
|
Hypothesis Tests with Dependent Variable Transformations
PROC TRANSREG can also provide approximate tests of hypotheses when the
dependent variable is transformed, but the output is more complicated.
When a dependent variable has more than one degree of freedom, the
problem becomes multivariate. Hypothesis tests are performed in the
context of a multivariate linear model with the number of dependent
variables equal to the number of scoring parameters for the dependent
variable transformation. The transformation regression model with a
dependent variable transformation differs from the usual multivariate
linear model in two important ways. First, the usual assumption of
multivariate normality is always violated. This fact is simply ignored.
This is one reason that all hypothesis tests in the presence of a
dependent variable transformation should be considered approximate at
best. Multivariate normality is assumed even though it is known that
the assumption is violated.
The second difference concerns the usual multivariate test statistics:
Pillai's Trace, Wilks' Lambda, Hotelling-Lawley Trace, and Roy's
Greatest Root. The first three statistics are defined in terms of all
the squared canonical correlations. Here, there is only one linear
combination (the transformation) and, hence, only one squared canonical
correlation of interest, which is equal to the R2. It may seem
that Roy's Greatest Root, which uses only the largest squared canonical
correlation, is the only statistic of interest. Unfortunately, Roy's
Greatest Root is very liberal and provides only a lower bound on the
p-value. Approximate upper bounds are provided by adjusting the
other three statistics for the one linear combination case. The Wilks'
Lambda, Pillai's Trace, and Hotelling-Lawley Trace statistics are a
conservative adjustment of the usual statistics.
These statistics are normally defined in terms of the squared canonical
correlations, which are the eigenvalues of the matrix
H (H+E)-1, where H is the hypothesis
sum-of-squares matrix and E is the error sum-of-squares matrix.
Here the R2 is used for the first eigenvalue, and all other
eigenvalues are set to 0 since only one linear combination is used.
Degrees of freedom are computed assuming that all linear combinations
contribute to the Lambda and Trace statistics, so the F tests for
those statistics are conservative. The p-values for the liberal
and conservative statistics provide approximate lower and upper bounds
on p. In practice, the adjusted Pillai's Trace is very
conservative -perhaps too conservative to be useful.
Wilks' Lambda is less conservative, and the Hotelling-Lawley Trace seems
to be the least conservative. The conservative statistics and the
liberal Roy's Greatest Root provide a bound on the true p-value.
Unfortunately, they sometimes report a bound of 0.0001 and 1.0000.
Here is an example with a dependent variable transformation.
proc transreg data=htex ss2 dummy short;
title 'Transform Dependent and Independent Variables';
model spline(y) = spline(x1-x3);
run;
The univariate results match Roy's Greatest Root results.
Clearly, the proper action is to fail to reject the null
hypothesis. However, as stated previously, results are not
always this clear. See Figure 65.26.
Transform Dependent and Independent Variables |
Spline(y) |
Algorithm converged. |
The TRANSREG Procedure Hypothesis Tests for Spline(y) |
Univariate ANOVA Table Based on the Usual Degrees of Freedom |
Source |
DF |
Sum of Squares |
Mean Square |
F Value |
Liberal p |
Model |
9 |
110.8822 |
12.32025 |
1.09 |
>= 0.4452 |
Error |
10 |
113.2616 |
11.32616 |
|
|
Corrected Total |
19 |
224.1438 |
|
|
|
The above statistics are not adjusted for the fact that the dependent variable was transformed and so are generally liberal. |
Root MSE |
3.36544 |
R-Square |
0.4947 |
Dependent Mean |
0.85490 |
Adj R-Sq |
0.0399 |
Coeff Var |
393.66234 |
|
|
Adjusted Multivariate ANOVA Table Based on the Usual Degrees of Freedom |
Dependent Variable Scoring Parameters=3 S=3 M=2.5 N=3 |
Statistic |
Value |
F Value |
Num DF |
Den DF |
p |
Wilks' Lambda |
0.505308 |
0.23 |
27 |
24.006 |
<= 0.9998 |
Pillai's Trace |
0.494692 |
0.22 |
27 |
30 |
<= 0.9999 |
Hotelling-Lawley Trace |
0.978992 |
0.26 |
27 |
11.589 |
<= 0.9980 |
Roy's Greatest Root |
0.978992 |
1.09 |
9 |
10 |
>= 0.4452 |
The Wilks' Lambda, Pillai's Trace, and Hotelling-Lawley Trace statistics are a conservative adjustment of the normal statistics. Roy's Greatest Root is liberal. These statistics are normally defined in terms of the squared canonical correlations which are the eigenvalues of the matrix H*inv(H+E). Here the R-Square is used for the first eigenvalue and all other eigenvalues are set to zero since only one linear combination is used. Degrees of freedom are computed assuming all linear combinations contribute to the Lambda and Trace statistics, so the F tests for those statistics are conservative. The p values for the liberal and conservative statistics provide approximate lower and upper bounds on p. A liberal test statistic with conservative degrees of freedom and a conservative test statistic with liberal degrees of freedom yield at best an approximate p value, which is indicated by a "~" before the p value. |
|
Figure 65.26: Transform Dependent and Independent Variables
Transform Dependent and Independent Variables |
The TRANSREG Procedure Hypothesis Tests for Spline(y) |
Univariate Regression Table Based on the Usual Degrees of Freedom |
Variable |
DF |
Coefficient |
Type II Sum of Squares |
Mean Square |
F Value |
Liberal p |
Intercept |
1 |
6.9089087 |
117.452 |
117.452 |
10.37 |
>= 0.0092 |
Spline(x1) |
3 |
-1.0832321 |
32.493 |
10.831 |
0.96 |
>= 0.4504 |
Spline(x2) |
3 |
-2.1539191 |
45.251 |
15.084 |
1.33 |
>= 0.3184 |
Spline(x3) |
3 |
0.4779207 |
10.139 |
3.380 |
0.30 |
>= 0.8259 |
The above statistics are not adjusted for the fact that the dependent variable was transformed and so are generally liberal. |
Adjusted Multivariate Regression Table Based on the Usual Degrees of Freedom |
Variable |
Coefficient |
Statistic |
Value |
F Value |
Num DF |
Den DF |
p |
Intercept |
6.9089087 |
Wilks' Lambda |
0.49092 |
2.77 |
3 |
8 |
0.1112 |
|
|
Pillai's Trace |
0.50908 |
2.77 |
3 |
8 |
0.1112 |
|
|
Hotelling-Lawley Trace |
1.036993 |
2.77 |
3 |
8 |
0.1112 |
|
|
Roy's Greatest Root |
1.036993 |
2.77 |
3 |
8 |
0.1112 |
Spline(x1) |
-1.0832321 |
Wilks' Lambda |
0.777072 |
0.24 |
9 |
19.621 |
<= 0.9840 |
|
|
Pillai's Trace |
0.222928 |
0.27 |
9 |
30 |
<= 0.9787 |
|
|
Hotelling-Lawley Trace |
0.286883 |
0.24 |
9 |
9.8113 |
<= 0.9784 |
|
|
Roy's Greatest Root |
0.286883 |
0.96 |
3 |
10 |
>= 0.4504 |
Spline(x2) |
-2.1539191 |
Wilks' Lambda |
0.714529 |
0.32 |
9 |
19.621 |
<= 0.9572 |
|
|
Pillai's Trace |
0.285471 |
0.35 |
9 |
30 |
<= 0.9494 |
|
|
Hotelling-Lawley Trace |
0.399524 |
0.33 |
9 |
9.8113 |
<= 0.9424 |
|
|
Roy's Greatest Root |
0.399524 |
1.33 |
3 |
10 |
>= 0.3184 |
Spline(x3) |
0.4779207 |
Wilks' Lambda |
0.917838 |
0.08 |
9 |
19.621 |
<= 0.9998 |
|
|
Pillai's Trace |
0.082162 |
0.09 |
9 |
30 |
<= 0.9996 |
|
|
Hotelling-Lawley Trace |
0.089517 |
0.07 |
9 |
9.8113 |
<= 0.9997 |
|
|
Roy's Greatest Root |
0.089517 |
0.30 |
3 |
10 |
>= 0.8259 |
These statistics are adjusted in the same way as the multivariate statistics above. |
|
Hypothesis Tests with One-Way ANOVA
One-way ANOVA models are fit with either an explicit or implicit
intercept. In implicit intercept models, the ANOVA
table of PROC TRANSREG is
the correct table for a model with an intercept, and the regression
table is the correct table for a model that does not have a separate
explicit intercept. The PROC TRANSREG implicit intercept ANOVA table
matches the PROC REG table when the NOINT a-option is not specified, and the PROC
TRANSREG implicit intercept regression table matches the PROC REG table
when the NOINT a-option is specified. The following code illustrates this relationship.
See Figure 65.27 through Figure 65.28 for the results.
data oneway;
input y x $;
datalines;
0 a
1 a
2 a
7 b
8 b
9 b
3 c
4 c
5 c
;
proc transreg ss2 data=oneway short;
title 'Implicit Intercept Model';
model identity(y) = class(x / zero=none);
output out=oneway2;
run;
proc reg data=oneway2;
model y = xa xb xc; /* Implicit Intercept ANOVA */
model y = xa xb xc / noint; /* Implicit Intercept Regression */
run;
Identity(y) |
Algorithm converged. |
The TRANSREG Procedure Hypothesis Tests for Identity(y) |
Univariate ANOVA Table Based on the Usual Degrees of Freedom |
Source |
DF |
Sum of Squares |
Mean Square |
F Value |
Pr > F |
Model |
2 |
74.00000 |
37.00000 |
37.00 |
0.0004 |
Error |
6 |
6.00000 |
1.00000 |
|
|
Corrected Total |
8 |
80.00000 |
|
|
|
Root MSE |
1.00000 |
R-Square |
0.9250 |
Dependent Mean |
4.33333 |
Adj R-Sq |
0.9000 |
Coeff Var |
23.07692 |
|
|
Univariate Regression Table Based on the Usual Degrees of Freedom |
Variable |
DF |
Coefficient |
Type II Sum of Squares |
Mean Square |
F Value |
Pr > F |
Label |
Class.xa |
1 |
1.00000000 |
3.000 |
3.000 |
3.00 |
0.1340 |
x a |
Class.xb |
1 |
8.00000000 |
192.000 |
192.000 |
192.00 |
<.0001 |
x b |
Class.xc |
1 |
4.00000000 |
48.000 |
48.000 |
48.00 |
0.0004 |
x c |
|
Figure 65.27: Implicit Intercept Model (TRANSREG Procedure)
The REG Procedure |
Model: MODEL1 |
Dependent Variable: y |
Analysis of Variance |
Source |
DF |
Sum of Squares |
Mean Square |
F Value |
Pr > F |
Model |
2 |
74.00000 |
37.00000 |
37.00 |
0.0004 |
Error |
6 |
6.00000 |
1.00000 |
|
|
Corrected Total |
8 |
80.00000 |
|
|
|
Root MSE |
1.00000 |
R-Square |
0.9250 |
Dependent Mean |
4.33333 |
Adj R-Sq |
0.9000 |
Coeff Var |
23.07692 |
|
|
NOTE: |
Model is not full rank. Least-squares solutions for the parameters are not unique. Some statistics will be misleading. A reported DF of 0 or B means that the estimate is biased. |
|
NOTE: |
The following parameters have been set to 0, since the variables are a linear combination of other variables as shown. |
|
Parameter Estimates |
Variable |
Label |
DF |
Parameter Estimate |
Standard Error |
t Value |
Pr > |t| |
Intercept |
Intercept |
B |
4.00000 |
0.57735 |
6.93 |
0.0004 |
xa |
x a |
B |
-3.00000 |
0.81650 |
-3.67 |
0.0104 |
xb |
x b |
B |
4.00000 |
0.81650 |
4.90 |
0.0027 |
xc |
x c |
0 |
0 |
. |
. |
. |
|
Figure 65.28: Implicit Intercept Model (REG Procedure)
The REG Procedure |
Model: MODEL2 |
Dependent Variable: y |
NOTE: |
No intercept in model. R-Square is redefined. |
|
Analysis of Variance |
Source |
DF |
Sum of Squares |
Mean Square |
F Value |
Pr > F |
Model |
3 |
243.00000 |
81.00000 |
81.00 |
<.0001 |
Error |
6 |
6.00000 |
1.00000 |
|
|
Uncorrected Total |
9 |
249.00000 |
|
|
|
Root MSE |
1.00000 |
R-Square |
0.9759 |
Dependent Mean |
4.33333 |
Adj R-Sq |
0.9639 |
Coeff Var |
23.07692 |
|
|
Parameter Estimates |
Variable |
Label |
DF |
Parameter Estimate |
Standard Error |
t Value |
Pr > |t| |
xa |
x a |
1 |
1.00000 |
0.57735 |
1.73 |
0.1340 |
xb |
x b |
1 |
8.00000 |
0.57735 |
13.86 |
<.0001 |
xc |
x c |
1 |
4.00000 |
0.57735 |
6.93 |
0.0004 |
|
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.