mmdplot plots the trajectory of minimum Mahalanobis distance (mmd)
Example of mmdplot.brushedUnits
=mmdplot(out
)
Example of the use of function mmd with personalized envelopes.brushedUnits
=mmdplot(out
,
Name, Value
)
[
Interactive_example
mmdplot with option dataooltip.brushedUnits
,
BrushedUnits
]
=mmdplot(___)
Steps common to all the examples
Y=load('head.txt'); [fre]=unibiv(Y); %create an initial subset with the 4 observations, which fell the smallest %number of times outside the robust bivariate ellipses, and with the %lowest Mahalanobis Distance. fre=sortrows(fre,[3 4]); m0=20; bs=fre(1:m0,1); [out]=FSMeda(Y,bs); mmdplot(out)
ans = []
Y=load('head.txt'); [fre]=unibiv(Y); fre=sortrows(fre,[3 4]); m0=20; bs=fre(1:m0,1); [out]=FSMeda(Y,bs); mmdplot(out,'quant',[0.99;0.9999]);
%Example of the use of function mmdplot with datatooltip passed as %scalar (that is using default options for datacursor (i.e. %DisplayStyle =window) Y=load('head.txt'); [fre]=unibiv(Y); fre=sortrows(fre,[3 4]); m0=20; bs=fre(1:m0,1); [out]=FSMeda(Y,bs); mmdplot(out,'datatooltip',1);
%Example of the use of function mmdplot with datatooltip passed as %structure Y=load('head.txt'); [fre]=unibiv(Y); fre=sortrows(fre,[3 4]); m0=20; bs=fre(1:m0,1); [out]=FSMeda(Y,bs); clear tooltip tooltip.SnapToDataVertex='on' tooltip.DisplayStyle='datatip' mmdplot(out,'datatooltip',tooltip);
In this case the resuperimposed envelope is based on n-2 observations
Y=load('head.txt'); [fre]=unibiv(Y); fre=sortrows(fre,[3 4]); m0=20; bs=fre(1:m0,1); [out]=FSMeda(Y,bs); mmdplot(out,'envm',size(Y,1)-2);
Y=load('head.txt'); [fre]=unibiv(Y); fre=sortrows(fre,[3 4]); m0=20; bs=fre(1:m0,1); [out]=FSMeda(Y,bs); mmdplot(out,'databrush',1);
% Example where databrush is a structure Y=load('head.txt'); [fre]=unibiv(Y); fre=sortrows(fre,[3 4]); m0=20; bs=fre(1:m0,1); [out]=FSMeda(Y,bs); databrush=struct databrush.selectionmode='Lasso' mmdplot(out,'databrush',databrush)
Y=load('head.txt'); [fre]=unibiv(Y); fre=sortrows(fre,[3 4]); m0=20; bs=fre(1:m0,1); [out]=FSMeda(Y,bs); databrush=struct databrush.selectionmode='Brush' databrush.Label='on'; mmdplot(out,'databrush',databrush)
Every time a brushing action is performed previous highlights are removed.
Y=load('head.txt'); [fre]=unibiv(Y); fre=sortrows(fre,[3 4]); m0=20; bs=fre(1:m0,1); [out]=FSMeda(Y,bs); databrush=struct databrush.persist='off' databrush.Label='on'; databrush.RemoveLabels='off'; mmdplot(out,'databrush',databrush)
Every time a brushing action is performed current highlights are added to previous highlights
Y=load('head.txt'); [fre]=unibiv(Y); fre=sortrows(fre,[3 4]); m0=20; bs=fre(1:m0,1); [out]=FSMeda(Y,bs); databrush=struct databrush.persist='on'; databrush.selectionmode='Rect' % outV is the vector of all selected units during brushing % outM is a matrix, each column contains the groups of selected units % at each brushing action [outV, outM]=mmdplot(out,'databrush',databrush)
out
— Structure containing monitoring of mmd.
Structure.Structure containing the following fields.
Value | Description |
---|---|
mmd |
a matrix containing the monitoring of minimum Mahalanobis distance in each step of the forward search. The first column of mdr must contain the fwd search index This matrix can be created using function FSMeda (compulsory argument). If this matrix has three columns in the third colum there is the monitoring of the (m+1)-th Mahalanobis distance |
Un |
matrix containing the order of entry of each unit (necessary if datatooltip is true or databrush is not empty) |
Y |
the original n x v data matrix (necessary only if option databrush is not empty) |
Data Types: single|double
Specify optional comma-separated pairs of Name,Value
arguments.
Name
is the argument name and Value
is the corresponding value. Name
must appear
inside single quotes (' '
).
You can specify several name and value pair arguments in any order as
Name1,Value1,...,NameN,ValueN
.
'quant',[0.01 0.99]
, 'mplus1',1
, 'envm',n
, 'xlimx',[20 100]
, 'ylimy',[2 6]
, 'lwdenv',2
, 'tag','mymmd'
, 'datatooltip',1
, 'label',{'Smith','Johnson','Robert','Stallone'}
, 'databrush',1
, 'FontSize',14
, 'SizeAxesNum',14
, 'nameY',{'Age','Income','Married','Profession'}
, 'lwd',3
, 'namey','Plot title'
, 'labx','Subset size m'
, 'laby','mmd'
, 'scaled',0
quant
—quantiles for which envelopes have
to be computed.vector.1 x k vector containing quantiles for which envelopes have to be computed. The default is to produce 1%, 50% and 99% envelopes.
Example: 'quant',[0.01 0.99]
Data Types: double
mplus1
—add (m+1) order statistic curve.scalar.If mplus1=1 it is also possible to plot the curve associated with (m+1)th order statistic.
The default is mplus1=0
Example: 'mplus1',1
Data Types: double
envm
—sample size to use.scalar.Scalar which specifies the size of the sample which is used to superimpose the envelope. The default is to add an envelope based on all the observations (size n envelope).
Example: 'envm',n
Data Types: double
xlimx
—min and max for x axis.vector.vector with two elements controlling minimum and maximum on the x axis.
Default value is mmd(1,1)-3 and mmd(end,1)*1.3
Example: 'xlimx',[20 100]
Data Types: double
ylimy
—min and max for x axis.vector.Vector with two elements controlling minimum and maximum on the y axis.
Default value is min(mmd(:,2)) and max(mmd(:,2));
Example: 'ylimy',[2 6]
Data Types: double
lwdenv
—Line width.scalar.Scalar which controls the width of the lines associated with the envelopes.
Default is lwdenv=1
Example: 'lwdenv',2
Data Types: double
tag
—plot handle.string.String which identifies the handle of the plot which is about to be created. The default is to use tag 'pl_mmd'. Notice that if the program finds a plot which has a tag equal to the one specified by the user, then the output of the new plot overwrites the existing one in the same window else a new window is created.
Example: 'tag','mymmd'
Data Types: char
datatooltip
—interactive clicking.empty value (default) | structure.If datatooltip is not empty the user can use the mouse in order to have information about the unit seected, the step in which the unit enters the search and the associated label. If datatooltip is a structure, it is possible to control the aspect of the data cursor (see function datacursormode for more details or the examples below). The default options of the structure are DisplayStyle='Window' and SnapToDataVertex='on'.
Example: 'datatooltip',1
Data Types: empty value, numeric or structure
label
—rwo labels.cell.Cell containing the labels of the units (optional argument used when datatooltip=1. If this field is not present labels row1, ..., rown will be automatically created and included in the pop up datatooltip window).
Example: 'label',{'Smith','Johnson','Robert','Stallone'}
Data Types: cell
databrush
—interactive mouse brushing.empty value (default), scalar | structure.DATABRUSH IS AN EMPTY VALUE .
If databrush is an empty value (default), no brushing is done. The activation of this option (databrush is a scalar or a structure) enables the user to select a set of trajectories in the current plot and to see them highlighted in the spm (notice that if the spm does not exist it is automatically created).
In addition, brushed units can be highlighted in the monitoring MD plot Note that the window style of the other figures is set equal to that which contains the monitoring residual plot. In other words, if the monitoring residual plot is docked all the other figures will be docked too.
DATABRUSH IS A SCALAR.
If databrush is a scalar the default selection tool is a rectangular brush and it is possible to brush only once (that is persist='').
DATABRUSH IS A STRUCTURE.
If databrush is a structure, it is possible to use all optional arguments of function selectdataFS and the following optional argument: persist. Persist is an empty value or a scalar containing the strings 'on' or 'off' If persist = 'on' or 'off' brusing can be done as many time as the user requires. If persist='on' then the unit(s) currently brushed are added to those previously brushed. If persist='off' every time a new brush is performed units previously brushed are removed. The default value of persist is '' that is brushing is allowed only once. If persist is 'on' it is possible, every time a new brushing is done, to use a different color for the brushed units labeladd. If this option is '1', we label the units of the last selected group with the unit row index in matrices X and y. The default value is labeladd='', i.e. no label is added.
Remark: if databrush is a struct, it is possible to specify all optional arguments of function selectdataFS inside the curly brackets of option databrush.
Example: 'databrush',1
Data Types: single | double | struct
FontSize
—Size of axes labels.scalar.Scalar which controls the fontsize of the labels of the axes.
Default value is 12.
Example: 'FontSize',14
Data Types: single | double
SizeAxesNum
—Size of axes numbers.scalar which controls the fontsize of the numbers of the axes.Default value is 10.
Example: 'SizeAxesNum',14
Data Types: single | double
nameY
—Regressors names.cell array of strings.Cell array of strings of length v containing the labels of the varibales of the original data matrix. If it is empty (default) the sequence Y1, ..., Yp will be created automatically.
Example: 'nameY',{'Age','Income','Married','Profession'}
Data Types: cell
lwd
—Curves line width.scalar.Scalar which controls linewidth of the curve which contains the monitoring of minimum Mahalanobis distance.
Default line width=2
Example: 'lwd',3
Data Types: single | double
titl
—main title.character.A label for the title (default: '')
Example: 'namey','Plot title'
Data Types: char
labx
—x axis title.character.A label for the x-axis (default: 'Subset size m').
Example: 'labx','Subset size m'
Data Types: char
laby
—y axis title.character.A label for the y-axis (default: 'Minimum Mahalnobis distance').
Example: 'laby','mmd'
Data Types: char
scaled
—scaled or unscaled envelopes.boolean.(Use reference envelopes scaled or unscaled).
If scaled=1 the envelopes are produced for scaled Mahalanobis distances (no consistency factor is applied) else the traditional consistency factor is applied Default is to use unscaled envelopes.
Example: 'scaled',0
Data Types: char
brushedUnits
—List of the
units which are inside subset in the trajectories which
have been brushed using option databrush.
brushed units.
Vector. VectorIf option databrush has not been used brushedUnits will be an empty value.
BrushedUnits
—brushed units.
MatrixMatrix of size r-by-numBrushingActions which contains in column j the brushed units after jth brushing.
If during jth brushing action the number of brushed units is $s<r$ the last $r-s$ units of column j are set to 0.
Atkinson, A.C., Riani, M. and Cerioli, A. (2004), "Exploring multivariate data with the forward search", Springer Verlag, New York.