-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathplspress.m
More file actions
85 lines (78 loc) · 2.72 KB
/
Copy pathplspress.m
File metadata and controls
85 lines (78 loc) · 2.72 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
function plspress(Model,interval)
% plspress plots PRESS as a function of the number of PLS components
%
% Input:
% Model (the output from ipls.m or plsmodel.m)
% interval is optional for selecting PRESS for one interval or global model (use 0)
%
% Copyright, Chemometrics Group - KVL, Copenhagen, Denmark
% Lars Nørgaard, July 2004
%
% plspress(Model,interval);
if nargin==0
disp(' ')
disp(' plspress(Model,interval);')
disp(' or')
disp(' plspress(Model);')
disp(' ')
return
end
if ~ismember(Model.type,{'PLS','iPLS','PLSprediction'})
disp(' ')
disp('This function only works with output from ipls.m, plsmodel.m or plspredict.m')
disp(' ')
return
end
switch Model.type
case 'iPLS'
if nargin == 2
if interval==0
interval=Model.intervals+1;
figtitle = sprintf('PRESS versus PLS components for global model');
else
figtitle = sprintf('PRESS versus PLS components for model on interval %g',interval);
end
bar(0:Model.no_of_lv,Model.PLSmodel{interval}.Press)
axis('tight')
actualaxis=axis;
axis([actualaxis(1) actualaxis(2) 0 actualaxis(4)*1.1]) % *1.1 to give some space in the plot
title(figtitle)
xlabel('Number of PLS components')
ylabel('PRESS')
elseif nargin == 1
for i=1:(Model.intervals+1)
Press(i,:) = Model.PLSmodel{i}.Press;
end
plot(0:Model.no_of_lv,Press(1:Model.intervals,:)')
actualaxis=axis;
axis([actualaxis(1) actualaxis(2) 0 actualaxis(4)])
figtitle = sprintf('PRESS versus PLS components for all interval models, -o- is PRESS for the full spectrum model');
title(figtitle)
xlabel('Number of PLS components')
ylabel('PRESS')
hold on
plot(0:Model.no_of_lv,Press(Model.intervals+1,:),'og')
plot(0:Model.no_of_lv,Press(Model.intervals+1,:),'-g')
hold off
end
case 'PLS'
Press(1,:) = Model.PLSmodel{1}.Press;
bar(0:Model.no_of_lv,Press(1:Model.intervals,:)')
axis('tight')
actualaxis=axis;
axis([actualaxis(1) actualaxis(2) 0 actualaxis(4)])
figtitle = sprintf(['PRESS versus PLS components for model on interval(s): ' int2str(Model.selected_intervals)]);
title(figtitle)
xlabel('Number of PLS components')
ylabel('PRESS')
case 'PLSprediction'
Press(1,:) = Model.Press;
bar(0:Model.no_of_lv,Press(1:Model.CalModel.intervals,:)')
axis('tight')
actualaxis=axis;
axis([actualaxis(1) actualaxis(2) 0 actualaxis(4)])
figtitle = sprintf(['PRESS versus PLS components for model on interval(s): ' int2str(Model.CalModel.selected_intervals)]);
title(figtitle)
xlabel('Number of PLS components')
ylabel('PRESS')
end