Skip to content

Commit

Permalink
add source for user manual
Browse files Browse the repository at this point in the history
  • Loading branch information
dlegland committed Jun 23, 2022
1 parent 5694596 commit b0aad32
Show file tree
Hide file tree
Showing 44 changed files with 7,997 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/matStats-manual/images/iris_boxplot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/matStats-manual/images/iris_histogram_n30.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/matStats-manual/images/iris_scatterGroup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/matStats-manual/images/iris_scatterPlot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/matStats-manual/images/iris_showTable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/matStats-manual/images/iris_violinPlot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/matStats-manual/images/pca/cities-pca.ev.png
Binary file added doc/matStats-manual/images/plot/plotDemo_01.png
Binary file added doc/matStats-manual/images/plot/plotDemo_02.png
Binary file added doc/matStats-manual/images/plot/plotDemo_03.png
Binary file added doc/matStats-manual/images/plot/plotDemo_04.png
7,698 changes: 7,698 additions & 0 deletions doc/matStats-manual/matStats-manual.lyx

Large diffs are not rendered by default.

41 changes: 41 additions & 0 deletions doc/matStats-manual/matlab/anova-iris/anovaIris.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
%ANOVAIRIS Performs sample Anova on Iris data set
%
% output = anovaIris(input)
%
% Example
% anovaIris
%
% See also
%

% ------
% Author: David Legland
% e-mail: [email protected]
% Created: 2017-07-19, using Matlab 9.1.0.441655 (R2016b)
% Copyright 2017 INRA - Cepia Software Platform.

% Analysis of variance on Fisher's iris
iris = Table.read('fisherIris');
anovaPL = Anova(iris('PetalLength'), iris('Species'));

%% display fitted coefficients
coefficients(anovaPL, 'Species')
% ans =
% PetalLength
% Setosa 1.462
% Versicolor 4.26
% Virginica 5.552


%% Display residuals

plotResiduals(anovaPL);
print(gcf, 'anova-irisPL-resids.png', '-dpng');

%% Display residual by factor level

figure; set(gca, 'fontsize', 14);
plot(iris('Species'), residuals(anovaPL), 'bs');
hold on;
plot([.5 3.5], [0 0], 'k-');
print(gcf, 'anova-irisPL-residsBySpecies.png', '-dpng');
24 changes: 24 additions & 0 deletions doc/matStats-manual/matlab/nmf/nmf_iris.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
%NMF_IRIS One-line description here, please.
%
% output = nmf_iris(input)
%
% Example
% nmf_iris
%
% See also
%

% ------
% Author: David Legland
% e-mail: [email protected]
% INRAE - BIA Research Unit - BIBS Platform (Nantes)
% Created: 2020-12-22, using Matlab 9.8.0.1323502 (R2020a)
% Copyright 2020 INRAE.

iris = Table.read('fisherIris');
[W, H] = nmf(iris(:,1:4), 2);
% use Matlab 'biplot' function to represent the results
biplot(H.Data', 'Scores', W.Data, 'varLabels', H.ColNames);
axis equal; axis([0 1.2 0 1.0]);

print(gcf, 'nmf_iris_biplot.png', '-dpng');
27 changes: 27 additions & 0 deletions doc/matStats-manual/matlab/pca-cities/pcaCities.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
%PCACITIES One-line description here, please.
%
% output = pcaCities(input)
%
% Example
% pcaCities
%
% See also
%

% ------
% Author: David Legland
% e-mail: [email protected]
% Created: 2017-06-16, using Matlab 9.1.0.441655 (R2016b)
% Copyright 2017 INRA - Cepia Software Platform.

% load data
load cities.mat

% format to a data table
colNames = strtrim(cellstr(categories))';
rowNames = strtrim(cellstr(names));
cities = Table(ratings, colNames, rowNames);

resPca = Pca(cities, 'scale', true, 'display', 'off');


16 changes: 16 additions & 0 deletions doc/matStats-manual/matlab/pca-iris/pcaIris.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
%PCAIRIS One-line description here, please.
%
% output = pcaIris(input)
%
% Example
% pcaIris
%
% See also
%

% ------
% Author: David Legland
% e-mail: [email protected]
% Created: 2017-06-16, using Matlab 9.1.0.441655 (R2016b)
% Copyright 2017 INRA - Cepia Software Platform.

56 changes: 56 additions & 0 deletions doc/matStats-manual/matlab/plots_basic/plotDemo.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
% Demonstration of plotting features of the MatStats library.
%
% output = plotDemo(input)
%
% Example
% plotDemo
%
% See also
%

% ------
% Author: David Legland
% e-mail: [email protected]
% INRAE - BIA Research Unit - BIBS Platform (Nantes)
% Created: 2020-07-01, using Matlab 9.8.0.1323502 (R2020a)
% Copyright 2020 INRAE.


%% Generate demo Table
% Generate a data table containing three columns, corresponding to a dummy
% parametrisation variable, and the result of two functions, here sine and
% cosine functions.

% parametrisation (as vertical vector)
t = linspace(0, 2*pi, 100)';

% concatenate as a numerical array
data = [t cos(t) sin(t)];

% create the Data Table encapsulating the data. Also specifies the name to
% populate the 'title' of the figures
tab = Table(data, {'t', 'Cos(t)', 'Sin(t)'}, 'Name', 'Sine and Cosine');


%% Line Plot

figure; set(gca, 'FontSize', 14);
linePlot(tab(:,1), tab(:, 2:3));


%% Bar Plot

figure; set(gca, 'FontSize', 14);
barPlot(tab(:,1), tab(:, 2:3));


%% Stair Steps Plot

figure; set(gca, 'FontSize', 14);
stairStepsPlot(tab(:,1), tab(:, 2:3));


%% Line Plot

figure; set(gca, 'FontSize', 14);
stemPlot(tab(:,1), tab(:, 2:3));
20 changes: 20 additions & 0 deletions doc/matStats-manual/matlab/plots_iris/demoPairPlot_iris.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
%DEMOPAIRPLOT_IRIS One-line description here, please.
%
% output = demoPairPlot_iris(input)
%
% Example
% demoPairPlot_iris
%
% See also
%

% ------
% Author: David Legland
% e-mail: [email protected]
% INRAE - BIA Research Unit - BIBS Platform (Nantes)
% Created: 2020-12-22, using Matlab 9.8.0.1323502 (R2020a)
% Copyright 2020 INRAE.

iris = Table.read('fisherIris');
figure; pairPlot(iris(:,1:4), iris(:,5));
print(gcf, 'iris_pairPlot_bySpecies.png', '-dpng');
23 changes: 23 additions & 0 deletions doc/matStats-manual/matlab/plots_iris/iris_histogram.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
%IRIS_HISTOGRAM One-line description here, please.
%
% output = iris_histogram(input)
%
% Example
% iris_histogram
%
% See also
%

% ------
% Author: David Legland
% e-mail: [email protected]
% INRAE - BIA Research Unit - BIBS Platform (Nantes)
% Created: 2020-12-22, using Matlab 9.8.0.1323502 (R2020a)
% Copyright 2020 INRAE.

iris = Table.read('fisherIris');

figure;
histogram(iris('PetalLength'), 30);

print(gcf, 'iris_histogram_n30.png', '-dpng');
92 changes: 92 additions & 0 deletions doc/matStats-manual/matlab/plots_iris/makeIrisFigures.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
%% Generate figures for the Table class manual
%
% Usage:
% demoTable
%
% started 2017-05-31

%% Read and display data

% Read data from a csv file (several options can be specified)
tab = Table.read('fisherIris.txt');

% display a part of the table on the console
disp(tab(1:5, :));

% Or display summary of the data, like in R
summary(tab);

% display the table in a frame
show(tab);

%% Histograms

% histogram of petal length. Columns can be indexed by their name.
figure;
histogram(tab('PetalLength'), 30);
print(gcf, 'iris_petalLength_hist.png', '-dpng');


% plot values of petal length
figure;
plot(tab('PetalLength'), 'bs');
print(gcf, 'iris_plotPetalLength_sq.png', '-dpng');

% plot petal width against petal length
figure;
plot(tab('PetalLength'), tab('PetalWidth'), 'b*');
print(gcf, 'iris_petalWidth_petalLength_star.png', '-dpng');


%% Box and violin plots

% box plot of the quantitative variables
figure;
boxplot(tab(:,1:4));
print(gcf, 'iris_boxPlot.png', '-dpng');

figure;
violinPlot(tab(:,1:4));
print(gcf, 'iris_violinPlot.png', '-dpng');


%% Management of groups

% scatter plot using groups
figure;
scatterGroup(tab('PetalLength'), tab('PetalWidth'), tab('Species'), ...
'Envelope', 'InertiaEllipse', ...
'LegendLocation', 'NorthWest');

% Compute the mean of each group
meanByGroup = aggregate(tab(:,1:4), tab('Species'), @mean);
disp(meanByGroup);

% display as bar plot
figure;
bar(meanByGroup');
print(gcf, 'iris_meanByGroup_bar.png', '-dpng');


%% Principal Component Analysis

% Apply Principal Component Analysis on the quantitative variables
irisPca = Pca(tab(:, 1:4), 'display', 'off');

% The result is a Pca object, containing Table object for scores, loadings
% and eigen values
disp(irisPca);

% Score plot can be displayed with automatic labeling of axes
figure;
scorePlot(irisPca, 1, 2);

% Loadings can also be displayed with automatic labeling
figure;
loadingPlot(irisPca, 1, 2);

% To display scores with group labelling, simply call the plot method on
% the score object stored in Pca result
figure;
scatterGroup(irisPca.Scores(:, 1), irisPca.Scores(:, 2), tab('Species'), ...
'LegendLocation', 'NorthWest');

0 comments on commit b0aad32

Please sign in to comment.