NMR Batch Correction Example Script
From Powers Wiki
PLS Fit Model
X = whole dataset (first & second);clsD = class info (dummy matrix). result = pls(X, clsD, @suv, [7,1], 1); mn = result.mean.X;sd = result.scale.X; Xscaled = (X-(repmat(mn,[size(X,1),1])))./(repmat(sd,[size(X,1),1]));%size(Xscaled) XPLSfit = result.T*result.P'; XscaledNew = Xscaled - XPLSfit; XNew = (XscaledNew.*(repmat(sd,[size(XscaledNew,1),1]))) + (repmat(mn,[size(XscaledNew,1),1]));
Mean of Mean Model
Xall = [Xtrain;Xtest]; refX = median(median(Xall)); mnXtrain = mean(mean(Xtrain)); newXtrain = Xtrain/repmat(mnXtrain, [size(Xtrain, 1), size(Xtrain, 2)]); newXtrain = newXtrain*repmat(refX, [size(Xtrain, 1), size(Xtrain, 2)]); mnXtest = mean(mean(Xtest)); newXtest = Xtest/repmat(mnXtest, [size(Xtest, 1), size(Xtest, 2)]); newXtest = newXtest*repmat(refX, [size(Xtest, 1), size(Xtest, 2)]);
Note: mean can be replaced with median in a median of median model.