IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
data_draw_pca_pareto.m
Go to the documentation of this file.
1 %>@ingroup datasettools
2 %>@file
3 %>@brief PCA pareto chart (number of PCs)x(% variance explained)
4 
5 %> @param data Dataset
6 %> @param no_pcs Number of "Principal Components"
7 function data_draw_pca_pareto(data, no_pcs)
8 
9 % data = data_eliminate_var0(data, 1e-10);
10 
11 X = data.X;
12 
13 var_total = sum(var(X));
14 
15 
16 f = fcon_pca();
17 f.flag_rotate_factors = 0;
18 f.no_factors = no_pcs;
19 
20 f = f.boot();
21 f = f.train(data);
22 data_pca = f.use(data);
23 
24 
25 vars = var(data_pca.X)/var_total*100;
26 figure;
27 plot(1:no_pcs, integrate(vars), 'k', 'LineWidth', 2);
28 hold on;
29 bar(1:no_pcs, vars);
30 set(gca, 'XLim', [0, no_pcs+1]);
31 set(gca, 'XTick', 1:no_pcs);
32 title('PCA pareto chart');
33 xlabel('PC');
34 ylabel('% variance explained');
35 format_frank();
36 % Copyright 2010 Julio Trevisan, Plamen P. Angelov & Francis L. Martin.
37 % e-mailing author: juliotrevisan@gmail.com
38 %
39 % This program is free software: you can redistribute it and/or modify
40 % it under the terms of the GNU General Public License as published by
41 % the Free Software Foundation, either version 3 of the License, or
42 % (at your option) any later version.
43 %
44 % This program is distributed in the hope that it will be useful,
45 % but WITHOUT ANY WARRANTY; without even the implied warranty of
46 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
47 % GNU General Public License for more details.
48 %
49 % A copy of the GNU General Public License is shipped along with this
50 % program (filename: "COPYING"). For an online version of the license,
51 % see <http://www.gnu.org/licenses/>.
Principal Component Analysis.
Definition: fcon_pca.m:4
function data_draw_pca_pareto(in data, in no_pcs)
function data_eliminate_var0(in ds, in threshold)
function format_frank(in F, in scale, in handles)
Analysis Session (AS) base class.
Definition: as.m:6
function integrate(in X)