# Nlstd

### Purpose

Create or apply non-linear instrument transfer models.

Important: NLSTD is an experimental algorithm that is currently only available in PLS_Toolbox as of version 8.5.

### Synopsis

- modl = nlstd(xSlave, xMaster, win);
- modl = nlstd(xSlave, xMaster, win, opt);
- modl = nlstd(xSlave, xMaster, win, pts, opt); % for lwr
- pred = nlstd(xSlave, modl, win, opt);
- valid = nlstd(xSlave, xMaster, modl, win, opt);

### Description

NLSTD is an experimental method which uses one of several algorithms available in PLS_Toolbox to return a model and transformed data. The three available algorithms to use are ANN, LWR, and SVM, note however that due to the huge memory requirements of using SVM, its use is limited only to relatively small datasets (otherwise the change of encountering an "out of memory" error is highly likely).

### Inputs

- xSlave: (2-way matrix of class “double” or “dataset”), data collected from the ‘slave instrument’
- xMaster: (2-way matrix of class “double” or “dataset”), data collected from the ‘master instrument’
- modl: A NLSTD (ANN/LWR/SVM) model.
- win: window size used in the (piecewise) standardization, must be an odd number.
- pts: (LWR only) Like window but with respect to the samples instead of measurements.

### Outputs

- model: A model structure containing the NLSTD model.
- pred: predictions, a matrix containing the transformed xSlave data.
- valid: validations, like predictions matrix but it is created using both test samples from both the ‘slave’ and ‘master’ instruments.

Note: The output variable will depend on the input arguments. If xSlave and xMaster datasets are used a model will be the output. If a NLSTD model is used as one of the input arguments, the output will be a matrix containing the predicted values.

### Options

- name: the name of the structure (‘options’)
- display: [ {‘off’} | ’on’ ]
- plots: [ ‘none’ | {‘final’} ]
- waitbar: [ ‘off’ | {‘auto’} | ‘on’ ]
- algorithm: [ {‘ann’} | ’svm’ | ’lwr’ ] governs the algorithm to be used.
- useopts: [ ] user may input a complete/partial options structure of the selected algorithm.
- edges: [ {‘const’} | ’zeros’ | ’linterp’ | ’pinterp’ ]
- ncomp: 1 (LWR Only) sets the number of components to be used in the model.

### Examples

Initialize the options structure, it’s good practice to initialize the options structure for the desired algorithm, make adjustments there and then assign it to the useopts field in the NLSTD options structure:

- annopt = nlstd(‘options’);
- uopt = ann(‘options’);
- uopt.nhid1 = 10;
- uopt.nhid2 = 0;
- uopt.display = ’off’;
- annopt.useopts = uopt;
- win = 7;

Build a calibration model:

- annstd_model = nlstd(inst1(1:6,:), inst2(1:6,:), win, annopt);

Get model predictions:

- annstd_pred = nlstd(inst1(7:15,:), inst2(7:15,:),win, annopt);

To use the LWR algorithm, and get predictions:

- lwropt = nlstd(‘options’);
- uopt = lwr(‘options’);
- uopt.display = ’off’;
- annopt.useopts = uopt;
- win = 7;
- pts = 5;

- lwrstd_model = nlstd(inst1(1:6,:), inst2(1:6,:), win,pts, lwropt);

- lwrstd_pred = nlstd(inst1(7:15,:), inst2(7:15,:),win, lwropt);

### See Also

alignpeaks, alignspectra, baseline, caltransfer, deresolv, distslct, mscorr, reducennsamples, registerspec, stdfir, stdize, stdsslct, stdgen