Chapter Contents Previous Next
 The TRANSREG Procedure

## Detecting Nonlinear Relationships

The TRANSREG procedure can detect nonlinear relationships among variables. For example, suppose 400 observations are generated from the following function

t = [x/4] + sin(x)

and data are created as follows

where is random normal error.

The following statements find a cubic spline transformation of X with four knots. For information on using splines and knots, see Example 65.1.

The following statements produce Figure 65.3 through Figure 65.4:

   title 'Curve Fitting Example';

*---Create An Artificial Nonlinear Scatter Plot---;
data Curve;
Pi=3.14159265359;
Pi4=4*Pi;
Increment=Pi4/400;
do X=Increment to Pi4 by Increment;
T=X/4 + sin(X);
Y=T + normal(7);
output;
end;
run;

*---Request a Spline Transformation of X---;
proc transreg data=Curve dummy;
model identity(Y)=spline(X / nknots=4);
output predicted;
id T;
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;
title;
axis1 minor=none label=(angle=90 rotate=0);
axis2 minor=none;
plot T*X=2              / &opts name='tregin1';
plot Y*X=1              / &opts name='tregin2';
plot Y*X=1 T*X=2 PY*X=3 / &opts name='tregin3' overlay ;
symbol1 color=blue   v=star i=none;

symbol2 color=yellow v=none i=join line=1;
symbol3 color=red    v=none i=join line=2;
run; quit;

goptions display;
proc greplay nofs tc=sashelp.templt template=l2r2;
igout gseg;
treplay 1:tregin1 2:tregin3 3:tregin2;
run; quit;


PROC TRANSREG increases the squared multiple correlation from the original value of 0.19945 to 0.47062. The plot of T by X shows the original function, the plot of Y by X shows the error-perturbed data, and the third plot shows the data, the true function as a solid curve, and the regression function as the dashed curve. The regression function closely approximates the true function.

 Curve Fitting Example

 The TRANSREG Procedure

 TRANSREG MORALS Algorithm Iteration History for Identity(Y) IterationNumber AverageChange MaximumChange R-Square CriterionChange Note 0 0.74855 1.29047 0.19945 1 0.00000 0.00000 0.47062 0.27117 Converged

 Algorithm converged.

Figure 65.3: Curve Fitting Example Output

Figure 65.4: Plots for the Curve Fitting Example

 Chapter Contents Previous Next Top