PLS_Toolbox Documentation: replace< registerspec rescale >

replace

Purpose

Replace variables based on principal component analysis (PCA) or partial least squares (PLS) regression models.

Synopsis

 

rm = replace(model,vars)

[rm,repdata] = replace(model,vars,data)

repdata = replace(model,data)

Description

REPLACE replaces variables from data matrices with values most consistent with the given PCA or PLS model. Input model can be a set of loading column vectors (e.g., loads returned by the pca routine, or model.loads{2} if the output is a model structure), the PCA residual generating matrix (I-loads*loadsī), or the PLS residuals generating matrix coeff returned by the plsrsgn routine. Input vars is a row vector containing the indices of the variables (columns) to be replaced. The output is the replacement matrix rm. Multiplication of a data matrix xnew by rm will replace variables with values most consistent with the given PCA or PLS model.

Alternate method: If the inputs include a PLS or PCA model model and data data, the data is searched for non-finite values (NaN, Inf) and these are replaced. In this mode, the only output is the infilled data repdata.

Examples

A PCA model was created on a data matrix xold giving a model structure model. The loadings, a set of loadings column vectors, were extracted to a variable loads using loads = model.loads{2};. It was found that the sensor measuring variable 9 has gone "bad" and we would like to replace it in the new data matrix xnew. A replacement matrix rm is first created using replace.

rm = replace(loads,9);

The new data matrix with variable 9 replaced rxnew is then calculated by multiplying xnew by rm.

rxnew = xnew*rm;

See Also

pca, plsrsgcv, plsrsgn


< registerspec rescale >