The PLS Procedure

Example 89.4 Partial Least Squares Spline Smoothing

(View the complete code for this example.)

The EFFECT statement makes it easy to construct a wide variety of linear models. In particular, you can use the spline effect to add smoothing terms to a model. A particular benefit of using spline effects in PROC PLS is that, when operating on spline basis functions, the partial least squares algorithm effectively chooses the amount of smoothing automatically, especially if you combine it with cross validation for the selecting the number of factors. This example employs the EFFECT statement to demonstrate partial least squares spline smoothing of agricultural data.

Weibe (1935) presents data from a study of uniformity of wheat yields over a certain rectangular plot of land. The following statements read these wheat yield measurements, indexed by row and column distances, into the SAS data set Wheat:

data Wheat;
   keep Row Column Yield;
   input Yield @@;
   iRow = int((_N_-1)/12);
   iCol = mod( _N_-1 ,12);
   Column = iCol*15 + 1; /* Column distance, in feet */
   Row    = iRow* 1 + 1; /* Row    distance, in feet */
   Row = 125 - Row + 1;  /* Invert rows              */
   datalines;
 715 595 580 580 615 610 540 515 557 665 560 612
 770 710 655 675 700 690 565 585 550 574 511 618
 760 715 690 690 655 725 665 640 665 705 644 705
 665 615 685 555 585 630 550 520 553 616 573 570
 755 730 670 580 545 620 580 525 495 565 599 612
 745 670 585 560 550 710 590 545 538 587 600 664
 645 690 550 520 450 630 535 505 530 536 611 578
 585 495 455 470 445 555 500 450 420 461 531 559

   ... more lines ...   

 570 585 635 765 550 675 765 620 608 705 677 660
 505 500 580 655 470 565 570 555 537 585 589 619
 465 430 510 680 460 600 670 615 620 594 616 784
;

The following statements use the PLS procedure to smooth these wheat yields using two spline effects, one for rows and another for columns, in addition to their crossproduct. Each spline effect has, by default, seven basis columns; thus their crossproduct has columns, for a total of 63 parameters in the full linear model. However, the predictive PLS model does not actually need to have 63 degrees of freedom. Rather, the degree of smoothing is controlled by the number of PLS factors, which in this case is chosen automatically by random subset validation with the CV=RANDOM option.

ods graphics on;

proc pls data=Wheat cv=random(seed=1) cvtest(seed=12345)
         plot(only)=contourfit(obs=gradient);
   effect splCol = spline(Column);
   effect splRow = spline(Row   );
   model Yield = splCol|splRow;
run;

These statements produce the output shown in Output 89.4.1 through Output 89.4.4.

Output 89.4.1: Default Spline Basis: Model and Data Information

The PLS Procedure

Data SetWORK.WHEAT
Factor Extraction MethodPartial Least Squares
PLS AlgorithmNIPALS
Number of Response Variables1
Number of Predictor Parameters63
Missing Value HandlingExclude
Maximum Number of Factors15
Validation Method10-fold Random Subset Validation
Random Subset Seed1
Validation Testing CriterionProb T**2 > 0.1
Number of Random Permutations1000
Random Permutation Seed12345

Number of Observations Read1500
Number of Observations Used1500


Output 89.4.2: Default Spline Basis: Random Subset Validated PRESS Statistics for Number of Factors

Random Subset Validation for the
Number of Extracted Factors
Number of
Extracted
Factors
Root Mean PRESST**2Prob > T**2
01.066355251.8793<.0001
10.826177123.8161<.0001
20.74587761.6035<.0001
30.72518144.99644<.0001
40.70146423.20199<.0001
50.6871648.3697110.0030
60.6839178.7758470.0010
70.6779692.9070190.0830
80.6764232.1908710.1340
90.6769663.1912840.0600
100.6750261.3346380.2390
110.6739060.5564550.4470
120.6736531.2572920.2790
130.67266901.0000
140.6735962.3860140.1190
150.6728280.029620.8820

Minimum root mean PRESS0.6727
Minimizing number of factors13
Smallest number of factors with p > 0.18


Output 89.4.3: Default Spline Basis: PLS Variation Summary for Split-Sample Validated Model

Percent Variation Accounted for by Partial
Least Squares Factors
Number of
Extracted
Factors
Model EffectsDependent Variables
CurrentTotalCurrentTotal
111.526911.526940.247140.2471
27.231418.758310.490850.7379
36.914725.67302.652353.3902
43.843329.51632.880656.2708
56.479535.99581.319757.5905
67.620143.61591.170058.7605
77.321450.93730.718659.4790
84.836355.77360.454859.9339


Output 89.4.4: Default Spline Basis: Smoothed Yield

Default Spline Basis: Smoothed Yield


The cross validation results in Output 89.4.2 point to a model with eight PLS factors; this is the smallest model whose predicted residual sum of squares (PRESS) is insignificantly different from the model with the absolute minimum PRESS. The variation summary in Output 89.4.3 shows that this model accounts for about 60% of the variation in the Yield values. The OBS=GRADIENT suboption for the PLOT=CONTOURFIT option specifies that the observations in the resulting plot, Output 89.4.4, be colored according to the same scheme as the surface of predicted yield. This coloration enables you to easily tell which observations are above the surface of predicted yield and which are below.

The surface of predicted yield is somewhat smoother than what Weibe (1935) settled on originally, with a predominance of simple, elliptically shaped contours. You can easily specify a potentially more granular model by increasing the number of knots in the spline bases. Even though the more granular model increases the number of predictor parameters, cross validation can still protect you from overfitting the data. The following statements are the same as those shown before, except that the spline effects now have twice as many basis functions:

ods graphics on;

proc pls data=Wheat cv=random(seed=1) cvtest(seed=12345)
         plot(only)=contourfit(obs=gradient);
   effect splCol = spline(Column / knotmethod=equal(14));
   effect splRow = spline(Row    / knotmethod=equal(14));
   model Yield = splCol|splRow;
run;

The resulting output is shown in Output 89.4.5 through Output 89.4.8.

Output 89.4.5: More Granular Spline Basis: Model and Data Information

The PLS Procedure

Data SetWORK.WHEAT
Factor Extraction MethodPartial Least Squares
PLS AlgorithmNIPALS
Number of Response Variables1
Number of Predictor Parameters360
Missing Value HandlingExclude
Maximum Number of Factors15
Validation Method10-fold Random Subset Validation
Random Subset Seed1
Validation Testing CriterionProb T**2 > 0.1
Number of Random Permutations1000
Random Permutation Seed12345

Number of Observations Read1500
Number of Observations Used1500


Output 89.4.6: More Granular Spline Basis: Random Subset Validated PRESS Statistics for Number of Factors

Random Subset Validation for the
Number of Extracted Factors
Number of
Extracted
Factors
Root Mean PRESST**2Prob > T**2
01.066355247.9268<.0001
10.65265820.68858<.0001
20.6150870.0748220.7740
30.61412801.0000
40.6152680.1976780.6490
50.6180011.3720380.2340
60.6229495.0355040.0180
70.6264827.2967970.0080
80.63331613.66045<.0001
90.63523916.16922<.0001
100.63693818.02295<.0001
110.63649416.9881<.0001
120.6368216.83341<.0001
130.63771916.74157<.0001
140.63762715.79342<.0001
150.63843116.12327<.0001

Minimum root mean PRESS0.6141
Minimizing number of factors3
Smallest number of factors with p > 0.12


Output 89.4.7: More Granular Spline Basis: PLS Variation Summary for Split-Sample Validated Model

Percent Variation Accounted for by Partial
Least Squares Factors
Number of
Extracted
Factors
Model EffectsDependent Variables
CurrentTotalCurrentTotal
11.79671.796764.779264.7792
21.37193.16876.316371.0955


Output 89.4.8: More Granular Spline Basis: Smoothed Yield

More Granular Spline Basis: Smoothed Yield


Output 89.4.5 shows that the model now has 360 parameters, many more than before. In Output 89.4.6 you can see that with more granular spline effects, fewer PLS factors are required—only two, in fact. However, Output 89.4.7 shows that this model now accounts for over 70% of the variation in the Yield values, and the contours of predicted values in Output 89.4.8 are less inclined to be simple elliptical shapes.