clear all
close all


 disp('Multivariate Data: Body Fat Example')
 lw = 3; 
 set(0, 'DefaultAxesFontSize', 12);
 fs = 15;
 msize = 10;


load('C:\STAT\Descriptive\Descriptivedat\fat.dat')
 % load('fat.dat')
casen = fat(:,1);
broz = fat(:,2);
siri = fat(:,3); 
densi = fat(:,4); 
age = fat(:,5);
weight = fat(:,6);   
height = fat(:,7);   
adiposi = fat(:,8); 
ffwei = fat(:,9);   
neck = fat(:,10); 
chest = fat(:,11);
abdomen  = fat(:,12);   
hip = fat(:,13); 
thigh = fat(:,14);
knee = fat(:,15);   
ankle = fat(:,16);
biceps = fat(:,17);
forearm = fat(:,18);     
wrist = fat(:,19);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
X = [broz densi weight adiposi biceps];
varNames = {'broz'; 'densi'; 'weight'; 'adiposi'; 'biceps'};

% covariances and correlations
covariance_matrix = cov(X)
correlation_matrix = corr(X)
correlation_spearman = corr(X,'type','Spearman')
correlation_kendall = corr(X,'type','Kendall')

figure(1)
agegr = age > 65;
gplotmatrix(X,[],agegr,['b','r'],['x','o'],[],'off');
text([.08 .24 .43 .66 .83], repmat(-.1,1,5), varNames, 'FontSize',10);
text(repmat(-.12,1,5), [.86 .62 .41 .25 .02], varNames, 'FontSize',10,...
  'Rotation',90);
%print -depsc 'C:\Courses\bmestatu\fat1.eps'
%%
figure(2)
older = ismember(age,[55:max(age)]);
parallelcoords(X, 'group', older, ...   %age>55, ...
           'standardize','on', 'labels',varNames);
set(gcf,'color','white');
%print -depsc 'C:\Courses\bmestatu\fat2.eps'
%%
figure(3)
parallelcoords(X, 'group', age>55, ...
     'standardize','on', 'labels',varNames,'quantile',0.25);
set(gcf,'color','white');
%print -depsc 'C:\Courses\bmestatu\fat3.eps'
%%
figure(4)
andrewsplot(X, 'group', age>55, 'standardize','on')
set(gcf,'color','white');

%%
%print -depsc 'C:\Courses\bmestatu\fat4.eps'
figure(5)
ind = find(age>67);
strind = num2str(ind);
h = glyphplot(X(ind,:), 'glyph','star', 'varLabels',varNames,...
'obslabels', strind);
set(h(:,3),'FontSize',8); set(gcf,'color','white');
%%
%print -depsc 'C:\Courses\bmestatu\fat5.eps'
figure(6)
ind = find(height > 74.5);
strind = num2str(ind);
h = glyphplot(X(ind,:), 'glyph','face', 'varLabels',varNames,...
'obslabels', strind);
set(h(:,3),'FontSize',10);  set(gcf,'color','white');
%print -depsc 'C:\Courses\bmestatu\fat6.eps'