⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 conpred.m

📁 偏最小二乘算法在MATLAB中的实现
💻 M
字号:
function m = conpred(b,w,p,q,lv)
%CONPRED Converts PLS models to regression vectors
%  The inputs are the inner-relation coefficients (b),
%  the x-block weights (w), the x-block loadings (p), the
%  y-block loadings (q) and the number of latent variables
%  to consider (lv). The output is a matrix (m) of the 
%  contribution of each latent variable to the final 
%  regression vector.
%  The I/O format is m = conpred(b,w,p,q,lv);
%
%  CONPRED works with either single or multiple variable y-block 
%  PLS models. If there is only 1 y-block variable each row of 
%  the output matrix corresponds to the contribution from each lv to
%  the y-block prediction.  If there are N y-block variables
%  each block of N rows corresponds to the contribution from
%  each lv to the prediction. See CONPRED1 for obtaining
%  final models.

% Copyright
% Barry M. Wise
% 1993
% Modified May 1994
[mq,nq] = size(q);
[mw,nw] = size(w);
if nw ~= lv
  if lv > nw
    s = sprintf('Original model has a maximum of %g LVs',nw);
    disp('  '), disp(s)
	s = sprintf('Calculating vectors for %g LVs only',nw);
	disp(s), disp('  ')
	lv = nw;
  else
    w = w(:,1:lv);
	q = q(:,1:lv);
	p = p(:,1:lv);
	b = b(:,1:lv);
  end
end
m = zeros(mq*lv,mw);
if mq == 1
  m = (w*inv(p'*w)*diag(b))';
else
  mp = (w*inv(p'*w)*diag(b))';
  for i = 1:lv
    mpp = mp(i,:);
    m((i-1)*mq+1:i*mq,:) = diag(q(:,i))*mpp(ones(mq,1),:);
  end
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -