The PLSMOD Procedure

Example 20.1 Choosing a PLS Model by Test Set Validation

This example demonstrates issues in spectrometric calibration. The data (Umetrics 1995) consist of spectrographic readings on 33 samples that contain known concentrations of two amino acids, tyrosine and tryptophan. The spectra are measured at 30 frequencies across the overall range of frequencies. For example, Output 20.1.1 shows the observed spectra for three samples: one with only tryptophan, one with only tyrosine, and one with a mixture of the two, all at a total concentration of 10 Superscript negative 6.

Output 20.1.1: Spectra for Three Samples of Tyrosine and Tryptophan

 Spectra for Three Samples of Tyrosine and Tryptophan


Of the 33 samples, 18 are used as a training set and 15 as a test set. The data originally appear in McAvoy et al. (1989).

These data were created in a lab, where the concentrations are fixed in order to provide a wide range of applicability for the model. This example uses a linear function of the logarithms of the spectra to predict the logarithms of tyrosine and tryptophan concentration and the logarithm of the total concentration. Actually, because zeros are possible in both the responses and the predictors, slightly different transformations are used. The following statements create a data table named ex1Data for these data. The data table also contains a variable Role that is used to assign samples to the training and testing roles.

data ex1Data;
   input obsnam $ Role : $5. tot tyr f1-f30 @@;
   try = tot - tyr;
   if (tyr) then tyr_log = log10(tyr); else tyr_log = -8;
   if (try) then try_log = log10(try); else try_log = -8;
   tot_log = log10(tot);
   datalines;
17mix35 TRAIN 0.00003 0
 -6.215 -5.809 -5.114 -3.963 -2.897 -2.269 -1.675 -1.235
 -0.900 -0.659 -0.497 -0.395 -0.335 -0.315 -0.333 -0.377
 -0.453 -0.549 -0.658 -0.797 -0.878 -0.954 -1.060 -1.266
 -1.520 -1.804 -2.044 -2.269 -2.496 -2.714
19mix35 TRAIN 0.00003 3E-7
 -5.516 -5.294 -4.823 -3.858 -2.827 -2.249 -1.683 -1.218
 -0.907 -0.658 -0.501 -0.400 -0.345 -0.323 -0.342 -0.387
 -0.461 -0.554 -0.665 -0.803 -0.887 -0.960 -1.072 -1.272
 -1.541 -1.814 -2.058 -2.289 -2.496 -2.712
21mix35 TRAIN 0.00003 7.5E-7
 -5.519 -5.294 -4.501 -3.863 -2.827 -2.280 -1.716 -1.262
 -0.939 -0.694 -0.536 -0.444 -0.384 -0.369 -0.377 -0.421
 -0.495 -0.596 -0.706 -0.824 -0.917 -0.988 -1.103 -1.294
 -1.565 -1.841 -2.084 -2.320 -2.521 -2.729
23mix35 TRAIN 0.00003 1.5E-6

   ... more lines ...   

 -5.138 -5.463 -5.461 -5.461 -5.461 -5.461
tyro2   TEST 0.0001 0.0001
 -1.081 -0.710 -0.470 -0.337 -0.327 -0.433 -0.602 -0.841
 -1.119 -1.423 -1.750 -2.121 -2.449 -2.818 -3.110 -3.467
 -3.781 -4.029 -4.241 -4.366 -4.501 -4.366 -4.501 -4.501
 -4.668 -4.668 -4.865 -4.865 -5.109 -5.111
;

data mycas.ex1Data;
   set ex1Data;
run;

The following statements fit a PLS model that has 10 factors:

proc plsmod data=mycas.ex1Data nfac=10;
   model tot_log tyr_log try_log = f1-f30;
run;

The "Model Information" table in Output 20.1.2 shows that no validation method is used. The "Number of Observations" table confirms that all 33 sample observations are used in the analysis.

Output 20.1.2: Model Information and Number of Observations

The PLSMOD Procedure

Model Information
Data SourceEX1DATA
Factor Extraction MethodPartial Least Squares
PLS AlgorithmNIPALS
Validation MethodNone

Number of Observations Read33
Number of Observations Used33


The table in Output 20.1.3 indicates that only four or five factors are required to explain almost all the variation in both the predictors and the responses.

Output 20.1.3: Amount of Variation Explained

Percentage Variation Accounted for by Partial Least Squares Factors
Number of
Extracted
Factors
Model EffectsResponse Variables
CurrentTotalCurrentTotal
177.6790377.6790347.8021747.80217
220.6271998.3062238.9682686.77043
31.0014399.307666.8926293.66305
40.2493099.556961.7722295.43528
50.1307799.687731.7176397.15290
60.0897099.777420.5861997.73909
70.0568499.834260.2907998.02988
80.0673099.901560.1385798.16845
90.0152199.916760.6821498.85059
100.0262799.943040.1438898.99447


In order to choose the optimal number of PLS factors, you can explore how well models that are based on data in training roles and have different numbers of factors fit the data in testing roles. To do so, you can use the PARTITION statement to assign observations to training and testing roles based on the values of the input variable named Role, as follows:

proc plsmod data=mycas.ex1Data nfac=10 cvtest(stat=press seed=12345);
   model tot_log tyr_log try_log = f1-f30;
   partition roleVar = Role(train='TRAIN' test='TEST');
run;

Output 20.1.4 shows the "Model Information" table and the "Number of Observations" table. The "Model Information" table indicates that test set validation is used, and it displays information about the options that are used in the model comparison test. The "Number of Observations" table confirms that there are 18 observations for the training role and 15 for the testing role.

Output 20.1.4: Model Information and Number of Observations with Test Set Validation

The PLSMOD Procedure

Model Information
Data SourceEX1DATA
Factor Extraction MethodPartial Least Squares
PLS AlgorithmNIPALS
Validation MethodTest Set Validation
Validation Testing CriterionProb PRESS > 0.1
Number of Random Permutations1000
Random Number Seed for Permutation12345

Number of Observations Read33
Number of Observations Used33
Number of Observations Used for Training18
Number of Observations Used for Testing15


Output 20.1.5 displays the results of the test set validation. They indicate that although five PLS factors produce the minimum predicted residual sum of squares, the residuals for four factors are insignificantly different from the residuals for five factors. Thus, the smaller model is preferred.

Output 20.1.5: Test Set Validation for the Number of PLS Factors

The PLSMOD Procedure

Test Set Validation for the
Number of Extracted Factors
Number of
Extracted
Factors
Root
Mean
PRESS
Prob >
PRESS
03.056797<.0001
12.630561<.0001
21.007060.0270
30.664603<.0001
40.5215780.2820
50.5000341.0000
60.5135610.4840
70.5014310.6470
81.055790.1860
91.4350850.1860
101.7203890.1510

Minimum Root Mean PRESS0.500034
Minimizing Number of Factors5
Smallest Number of Factors with p > 0.14

Percentage Variation Accounted for by Partial Least Squares Factors
Number of
Extracted
Factors
Model EffectsResponse Variables
CurrentTotalCurrentTotal
181.1654581.1654548.3385448.33854
216.8113197.9767632.5465480.88508
31.7639199.7406711.4438092.32888
40.1950799.935743.8363196.16519


Last updated: September 13, 2022