# NMath User's Guide

48.5 PLS Algorithms (.NET, C#, CSharp, VB, Visual Basic, F#)

NMath Stats provides classes PLS1NipalsAlgorithm and PLS2NipalsAlgorithm which implement the Nonlinear Iterative PArtial Least Squares (NIPALS) algorithm for PLS1 and PLS2 respectively, and class PLS2SimplsAlgorithm which implements the Straightforward IMplementation of PLS (SIMPLS) algorithm for PLS2.

The algorithm to use may be specified in the constructor for a PLS1 or PLS2 object, or set through the Calculator property:

Code Example – C# partial least squares (PLS)

```var calculator = new PLS2SimplsAlgorithm();
```
```pls.Calculator = calculator;
```

Code Example – VB partial least squares (PLS)

```Dim Calculator As New PLS2SimplsAlgorithm()
```
```PLS.Calculator = Calculator
```

NOTE—Note that setting the calculator through the property forces a recalculation if data is present.

The SIMPLS algorithm for PLS2 uses the Iterative Power Method for computing dominant eigenvectors. This algorithm produces a candidate eigenvector during each iteration which is normalized with respect to the l-infinity norm. When the two-norm of the difference between the current eigenvector, ei, and the eigenvector computed on the previous iteration, ei-1, is less than a specified tolerance, the algorithm stops. The maximum number of iteration to perform as well as the tolerance may be specified on the algorithm object.

If your PLS2 with SIMPLS calculation fails because the power method failed to converge, you may want to adjust these values.(If the calculation failure is due to non-convergence of the power method, this will be indicated in the Message property of the PLS2 object.

Top

Top