-
Notifications
You must be signed in to change notification settings - Fork 0
/
mvrpls.m
65 lines (57 loc) · 1.91 KB
/
mvrpls.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
function [b,p,w,t,u,inner,Xres,yres] = mvrpls(X,y,p0,t0,inner0,maxlv,mem)
%MVRPLS -- Recursive Partial Least Squares regression
%
% Usage:
% [b,p,w,t,u,inner,Xres,yres] = mvrpls(X,y,p0,t0,inner0,maxlv,mem)
%
% Inputs:
% X calibration data X matrix
% y calibration data y vector
% maxlv number of latent variables to calculate (optional)
% p0 X loadings
% t0 X scores
% inner0 vector containing the inner (X/y scores) relationships
% maxlv max number of latent variables to calculate
% mem forgetting factor (optional, default = 1)
%
% Outputs:
% b regression coefficients
% p X loadings
% w loading weights
% t X scores
% u y scores
% inner vector containing the inner (X/y scores) relationships
% Xres X residuals
% yres y residuals
%
% Description:
% Recursive Partial Least Squares regression, reference:
% K. Helland, Ph.D. Thesis, 1993. See also 'mvrplsc' and
% 'mvrplsc'.
%
% Copying:
% MVARTOOLS, Copyright (C) 1999-2001 Rune Mathisen <[email protected]>
% MVARTOOLS comes with ABSOLUTELY NO WARRANTY; for details type
% `mvwarranty'. This is free software, and you are welcome to
% redistribute it under certain conditions; type `mvcopying' for
% details. For more information on MVARTOOLS, type 'mvreadme'.
% $Id: mvrpls.m,v 1.3 2001/12/05 14:57:39 rune Exp $
[my,ny] = size(y);
if ny > 1,
error('This function only works with one y!')
end
if (~exist('mem')==1),
mem = 1;
end
% Create representation of data based on loadings and new X and y
L = diag(sqrt(diag(t0'*t0)));
R = p0*L;
S = inner0*L;
% Create new calibration set
Xnew = [mem*R';X];
ynew = [mem*S';y];
% Calibration
warning off % we don't want all those warnings about centering
[b,p,q,w,t,u,inner,Xres,yres] = mvplsnipals(Xnew,ynew,maxlv);
warning on % turn the warnings back on again
% end of file