forked from viggin/yan-prtools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
regress_pls_tr.m
27 lines (22 loc) · 880 Bytes
/
regress_pls_tr.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function [model] = regress_pls_tr(X,Y,param)
%Wrapper of patial least square regression in matlab.
% Popular in chemometrics. Suitable when variables are largely correlated.
%
% X : each row is a sample.
% Y : a column vector.
% PARAM: struct of parameters. The beginning part of this code (before
% defParam) explains each parameter, and also sets the default parameters.
% You can change parameter p to x by setting PARAM.p = x. For parameters
% that are not set, default values will be used.
% Return:
% MODEL: a struct containing coefficients.
%
% Ke YAN, 2016, Tsinghua Univ. http://yanke23.com, [email protected]
numComp = 5; % number of PLS components
defParam
[XL,yl,XS,YS,beta,PCTVAR] = plsregress(X,Y,numComp);
% plot(1:10,cumsum(100*PCTVAR(2,:)),'-bo');
% xlabel('Number of PLS components');
% ylabel('Percent Variance Explained in y');
model.beta = beta;
end