📄 simpls1.m
字号:
function b = simpls1(x,y,maxlv)
%SIMPLS1 minimum implementation of simpls for PLS1
% Inputs are the matrix of predictor variables (x), vector
% of predicted variables (y) and maximum number of latent
% variables to calculate (lv). The output is a matrix of
% regression vectors (b) where each row corresponds to the
% regression vector for the PLS model with corresponding number
% of LVs.
%
% Note: This function is primarily used for fast cross-validation
% since none of the PLS model parameters (weights, loadings,
% etc.) are calculated. The SIMPLS algorithm developed by
% Sijmen de Jong is used.
%
% The I/O format is: b = simpls1(x,y,maxlv);
% Copyright
% Eigenvector Technologies
% Barry M. Wise
% May 1994
[m,n] = size(x);
s = x'*y;
rmat = zeros(n,maxlv);
tmat = zeros(m,maxlv);
vmat = zeros(n,maxlv);
qmat = zeros(1,maxlv);
for i = 1:maxlv
r = s;
t = x*r;
normt = sqrt(t'*t);
t = t/normt;
r = r/normt;
p = x'*t;
q = y'*t;
u = y*q;
v = p;
if i > 1
v = v - vmat*(vmat'*p);
u = u - tmat*(tmat'*u);
end
v = v/sqrt(v'*v);
s = s - v*(v'*s);
rmat(:,i) = r;
tmat(:,i) = t;
qmat(:,i) = q;
vmat(:,i) = v;
end
b = cumsum((rmat*diag(qmat))');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -