Lwrpred
From Eigenvector Documentation Wiki
Contents |
Purpose
Predictions based on locally weighted regression models.
Synopsis
- [ypred,extrap,ssqresiduals,tsqs] = lwrpred(xnew,xold,yold,lvs,npts,options)
- [model] = lwrpred(xold,yold,lvs,npts,options)
- [ypred,extrap,ssqresiduals,tsqs] = lwrpred(xnew,model,options)
Description
LWRPRED makes new sample predictions ypred for a new matrix of independent variables xnew based on an existing data set of independent variables xold, and a vector of dependent variables yold. Predictions are made using a locally weighted regression model defined by the number principal components used to model the independent variables lvs and the number of points defined as local npts. Optional input options described below.
Note: If scaling is done prior to calling lwrpred, be sure to use the same scaling on new and old samples i.e. xnew must be scaled the same as xold!
Inputs
- xold = X-block (calibration block) class "double" or "dataset"
- yold = Y-block (calibration block) class "double" or "dataset"
- xnew = X-block (test block) class "double" or "dataset"
- ncomp = the number of latent variables to be calculated (positive integer scalar)
- npts = the number of points to use in local regression (positive integer scalar)
- model = previously generated lwrpred model
Outputs
- model = a standard model structure model (see Standard Model Structure)
- ypred a vector of sample predictions for the new data, xnew.
- extrap a vector equal in length to number of samples in xnew, is non-zero when the given sample was predicted by extrapolating outside of the range of y-values which were used in the model. The value represents the distance (in y-units) extrapolated outside of the modeled samples. For example, a value of -0.3 indicates that the given sample was predicted by extrapolating 0.3 y-units below the lowest modeled sample in yold.
- ssqresiduals cell array, first element contains vector of residuals (Q).
- tsqs cell array, first element contains vector of Tsquared statistic.
Options
options = a structure array with the following fields:
- display: [ 'off' | {'on'} ] governs level of display.
- waitbar : [ 'off' |{'auto'}| 'on' ] governs use of waitbar during analysis. 'auto' shows waitbar if delay will likely be longer than a reasonable waiting period.
- alpha: [ 0-1 ] Weighting of y-distances in selection of local points. 0 = do not consider y-distances {default}, 1 = consider ONLY y-distances. With any positive alpha, the algorithm will tend to select samples which are close in both the PC space but which also have similar y-values. This is accomplished by repeating the prediction multiple times. In the first iteration, the selection of samples is done only on the PC space. Subsequent iterations take into account the comparison between predicted y-value of the new sample and the measured y-values of the calibration samples.
- iter: [ {5} ] Iterations in determining local points. Used only when alpha > 0 (i.e. when using y-distance scaling).
- preprocessing: { 2 2 } Two element cell array defining preprocessing to use on data. First element of cell defines x-block preprocessing, second element defines y-block preprocessing. Options are:
- 0 = no scaling or centering
- 1 = mean center only
- 2 = autoscale (default)
- For example: {1 2} performs mean centering on x-block and autoscaling on y-block.
- algorithm: [ {'globalpcr'} | 'pcr' | 'pls' ] Method of regression after samples are selected. 'globalpcr' performs PCR based on the PCs calculated from the entire calibration data set but a regression vector calculated from only the selected samples. 'pcr' and 'pls' calculate a local PCR or PLS model based only on the selected samples.
- reglvs: [ ] Used only when algorithm is 'pcr' or 'pls', this is the number of latent variables/principal components to use in the regression model, if different from the number used to select calibration samples. [] (Empty) implies LWRPRED should use the same number of latent variables in the regression as were used to select samples. NOTE: This option is NOT used when algorithm is 'globalpcr'.
- structureoutput: [ true |{false}] Determines whether output is a model structure (if true), or [ypred,extrap, ssqresiduals,tsqs] (if false). This is only relevant for cases where a model is passed in as argument.
- waitbartrigger: [15] Threshold for estimated time remaining above which a waitbar will be shown when in "auto" waitbar mode.