FSCorAna performs automatic outlier based on the forward search in correspondence analysis
Generate contingency table of size 50-by-5 with total sum of n_ij=2000.
I=20;
J=5;
n=5000;
% nrowt = column vector containing row marginal totals
nrowt=(n/I)*ones(I,1);
% ncolt = row vector containing column marginal totals
ncolt=(n/J)*ones(1,J);
out1=rcontFS(I,J,nrowt,ncolt);
N=out1.m144;
RAW=mcdCorAna(N,'plots',0);
ini=round(sum(sum(RAW.N))/4);
out=FSCorAna(RAW);
Generate contingency table of size 50-by-5 with total sum of n_ij=2000.
I=50;
J=5;
n=2000;
% nrowt = column vector containing row marginal totals
nrowt=(n/I)*ones(I,1);
% ncolt = row vector containing column marginal totals
ncolt=(n/J)*ones(1,J);
out1=rcontFS(I,J,nrowt,ncolt);
N=out1.m144;
out=FSCorAna(N,'plots',1);
load clothes.mat
% Now FSCorAna uses the pregenerated tables coming from mcdCorAna.
% Example of findEmpiricalEnvelope a struct
findEmp=struct;
% Generate nsimul contingency tables
findEmp.nsimul=1000;
% Under the null hypothesis of independence
findEmp.underH0=true;
% Store the nsimul robust distance sorted (for each row)
findEmp.StoreSim=true;
RAW=mcdCorAna(clothes,'plots',0,'findEmpiricalEnvelope',findEmp);
out=FSCorAna(RAW);
Total estimated time to complete MCD: 0.18 seconds Finding empirical bands Creating empirical confidence band for minimum (weighted) Mahalanobis distance Warning: interchange greater than 1 when m=1541 Number of units which entered=3 Warning: interchange greater than 1 when m=1543 Number of units which entered=3 Warning: interchange greater than 1 when m=1545 Number of units which entered=3 Warning: interchange greater than 1 when m=1547 Number of units which entered=3 Warning: interchange greater than 1 when m=1549 Number of units which entered=3 Warning: interchange greater than 1 when m=1260 Number of units which entered=3 Warning: interchange greater than 1 when m=1262 Number of units which entered=3 Warning: interchange greater than 1 when m=1264 Number of units which entered=3 Warning: interchange greater than 1 when m=1266 Number of units which entered=3 Warning: interchange greater than 1 when m=1268 Number of units which entered=3 Warning: interchange greater than 1 when m=1270 Number of units which entered=3 Warning: interchange greater than 1 when m=1272 Number of units which entered=3 Warning: interchange greater than 1 when m=1274 Number of units which entered=3 Warning: interchange greater than 1 when m=1292 Number of units which entered=3 Warning: interchange greater than 1 when m=1296 Number of units which entered=3 Warning: interchange greater than 1 when m=1160 Number of units which entered=3 Warning: interchange greater than 1 when m=1607 Number of units which entered=3 Warning: interchange greater than 1 when m=1841 Number of units which entered=3 Warning: interchange greater than 1 when m=1325 Number of units which entered=3 Warning: interchange greater than 1 when m=1331 Number of units which entered=3 Warning: interchange greater than 1 when m=1334 Number of units which entered=3 Warning: interchange greater than 1 when m=1337 Number of units which entered=3 Warning: interchange greater than 1 when m=1340 Number of units which entered=3 Warning: interchange greater than 1 when m=1343 Number of units which entered=3 Warning: interchange greater than 1 when m=1346 Number of units which entered=3 Warning: interchange greater than 1 when m=1349 Number of units which entered=3 Warning: interchange greater than 1 when m=1352 Number of units which entered=3 Warning: interchange greater than 1 when m=1355 Number of units which entered=3 Warning: interchange greater than 1 when m=1358 Number of units which entered=3 Warning: interchange greater than 1 when m=1361 Number of units which entered=3 Warning: interchange greater than 1 when m=1364 Number of units which entered=3 Warning: interchange greater than 1 when m=1367 Number of units which entered=3 Warning: interchange greater than 1 when m=1371 Number of units which entered=3 Warning: interchange greater than 1 when m=1375 Number of units which entered=3 Warning: interchange greater than 1 when m=1379 Number of units which entered=3 Warning: interchange greater than 1 when m=1107 Number of units which entered=3 Warning: interchange greater than 1 when m=1320 Number of units which entered=3 Warning: interchange greater than 1 when m=1322 Number of units which entered=3 Warning: interchange greater than 1 when m=1324 Number of units which entered=3 Warning: interchange greater than 1 when m=1326 Number of units which entered=3 Warning: interchange greater than 1 when m=1328 Number of units which entered=3 Warning: interchange greater than 1 when m=1330 Number of units which entered=3 Warning: interchange greater than 1 when m=1332 Number of units which entered=3 Warning: interchange greater than 1 when m=1334 Number of units which entered=3 Warning: interchange greater than 1 when m=1336 Number of units which entered=3 Warning: interchange greater than 1 when m=1338 Number of units which entered=3 Warning: interchange greater than 1 when m=1340 Number of units which entered=3 Warning: interchange greater than 1 when m=1342 Number of units which entered=3 Warning: interchange greater than 1 when m=1344 Number of units which entered=3 Warning: interchange greater than 1 when m=1346 Number of units which entered=3 Warning: interchange greater than 1 when m=1348 Number of units which entered=3 Warning: interchange greater than 1 when m=1350 Number of units which entered=3 Warning: interchange greater than 1 when m=1352 Number of units which entered=3 Warning: interchange greater than 1 when m=1354 Number of units which entered=3 Warning: interchange greater than 1 when m=1356 Number of units which entered=3 Warning: interchange greater than 1 when m=1358 Number of units which entered=3 Warning: interchange greater than 1 when m=1360 Number of units which entered=3 Warning: interchange greater than 1 when m=1362 Number of units which entered=3 Warning: interchange greater than 1 when m=1364 Number of units which entered=3 Warning: interchange greater than 1 when m=1366 Number of units which entered=3 Warning: interchange greater than 1 when m=1368 Number of units which entered=3 Warning: interchange greater than 1 when m=1370 Number of units which entered=3 Warning: interchange greater than 1 when m=1372 Number of units which entered=3 Warning: interchange greater than 1 when m=1374 Number of units which entered=3 Warning: interchange greater than 1 when m=1376 Number of units which entered=3 Warning: interchange greater than 1 when m=2233 Number of units which entered=3 Warning: interchange greater than 1 when m=2236 Number of units which entered=3 Warning: interchange greater than 1 when m=1590 Number of units which entered=3 Warning: interchange greater than 1 when m=1648 Number of units which entered=3 Warning: interchange greater than 1 when m=1651 Number of units which entered=3 Warning: interchange greater than 1 when m=1654 Number of units which entered=3 Warning: interchange greater than 1 when m=1657 Number of units which entered=3 Warning: interchange greater than 1 when m=1660 Number of units which entered=3 Warning: interchange greater than 1 when m=2101 Number of units which entered=3 Warning: interchange greater than 1 when m=1096 Number of units which entered=3 Warning: interchange greater than 1 when m=1350 Number of units which entered=3 Warning: interchange greater than 1 when m=1352 Number of units which entered=3 Warning: interchange greater than 1 when m=1354 Number of units which entered=3 Warning: interchange greater than 1 when m=1356 Number of units which entered=3 Warning: interchange greater than 1 when m=1358 Number of units which entered=3 Warning: interchange greater than 1 when m=1360 Number of units which entered=3 Warning: interchange greater than 1 when m=1362 Number of units which entered=3 Warning: interchange greater than 1 when m=1364 Number of units which entered=3 Warning: interchange greater than 1 when m=1255 Number of units which entered=3 Warning: interchange greater than 1 when m=1448 Number of units which entered=3 Warning: interchange greater than 1 when m=1450 Number of units which entered=3 Warning: interchange greater than 1 when m=1452 Number of units which entered=3 Warning: interchange greater than 1 when m=1454 Number of units which entered=3 Warning: interchange greater than 1 when m=1456 Number of units which entered=3 Warning: interchange greater than 1 when m=1458 Number of units which entered=3 Warning: interchange greater than 1 when m=1460 Number of units which entered=3 Warning: interchange greater than 1 when m=1462 Number of units which entered=3 Warning: interchange greater than 1 when m=1464 Number of units which entered=3 Warning: interchange greater than 1 when m=1466 Number of units which entered=3 Warning: interchange greater than 1 when m=1468 Number of units which entered=3 Warning: interchange greater than 1 when m=1306 Number of units which entered=4 Warning: interchange greater than 1 when m=1173 Number of units which entered=3 Warning: interchange greater than 1 when m=2537 Number of units which entered=3
N
— contingency table or structure.
Array or table of size I-by-J or structure.If N is a structure it contains the following fields:
Value | Description |
---|---|
N |
contingency table in array format of size I-by-J. |
Ntable |
this field is not compulsory where Ntable is a table or a timetable. If this field is present the label of the rows which are used are taken from RAW.Ntable.Properties.RowTimes (in presence of a timetable) RAW.Ntable.Properties.RowNames (in presence of a table). |
loc |
initial location estimate for the matrix of Profile rows of the contingency table (row vector or length J). |
weights |
I x 1 vector containing the proportion of the mass of each rows of matrix N in the computation of the MCD estimate of location. If N.weigths(2)=0.1 it means that row 2 of the contingency table contributes with 10 per cent of its mass. The initial subset is based on N.weights. |
NsimStore |
array of size I-by-J times nsimul containing in each column the nsimul simulated contingency tables. |
simulateUnderH0 |
boolean. If it is true the simulated contingency tables have been specified under H0. Note that input structure N can be conveniently created by function mcdCorAna. If N is not a struct it is possible to specify the rows of the contingency table forming initial subset with input option bsb. |
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
.
'bsb',[3 6 8 10 12 14]
, 'conflev',0.99
, 'init',50
, 'mmdEnv',[]
, 'plots',0
, 'msg',false
, 'resc',false
, 'label',{'UK' ... 'IT'}
, 'plots',0
, 'addRowNames',false
bsb
—Initial subset.vector of positive integers containing the indexes of the rows of the contingency table which have to be used to initialize the forward search.If bsb is empty and required input argument is a struct N.loc will be used.
If bsb is supplied and N is a struct N.loc is ignored.
The default value of bsb is empty, and if N is not a struct a random subset containing round(n/5) units will be used.
Example: 'bsb',[3 6 8 10 12 14]
Data Types: double
conflev
—simultaneous confidence interval to declare units as
outliers.scalar inside (0, 1).The default value of conflev is 0.99, that is a 99 per cent simultaneous confidence level.
Confidence level are based on simulated contingency tables. This input argument is ignored if optional input argument mmdEnv is not missing
Example: 'conflev',0.99
Data Types: numeric
init
—Point where to start monitoring required diagnostics.scalar.Note that if init is not specified it will be set equal to floor(n*0.6).
where the total number of units in the contingency table.
Example: 'init',50
Data Types: double
mmdEnv
—Matrix which contains the precalculated empirical envelopes of
minimum Mahalanobis distance.matrix | scalar missing value (default).If this optional input argument is not missing the empirical envelopes are taken from this optional argument and are not calculated. First column is subset size Second column is 1 per cent simultaneous empirical envelope. Third column is 50 per cent simultaneous empirical envelope. Fourth column is conflev per cent simultaneous empirical envelope which is used to detect the outliers. The default value of mmdStoreSim is a missing value, that is the envelopes are based on the N.NsimStore pregenerated contingency tables or if N.NsimStore is not present are generated assuming independence between rows and columns
Example: 'mmdEnv',[]
Data Types: double
StoreSim
—Store minimum Mahalanobis distance quantiles.boolean.Boolean which specifies whether to store or not as fields named mmdStore the simulated envelopes of the minimum Mahalanobis distance monitored along the search.
Example: 'plots',0
Data Types: double
msg
—It controls whether to display or not messages
about envelope creation on the screen.logical.If msg==1 (default) messages are displayed on the screen else no message is displayed on the screen.
Example: 'msg',false
Data Types: logical
resc
—Rescale or not the envelopes.boolean.It controls whether to rescale or not the envelopes of min MD when if in the initial part of the search is steadily above or below the 5 and 95 per cent confidence bands. The default value of resc is true.
Example: 'resc',false
Data Types: logical
label
—row labels.cell | vector of strings.Cell or vector of strings of length n containing the labels of the rows. If input is a table or a timetable the row labels are automatically taken from the row names.
Example: 'label',{'UK' ... 'IT'}
Data Types: cell or characters or vector of strings
plots
—It specify whether it is necessary to produce the plots of the
monitoring of minMD.scalar.If plots=1, a plot of the monitoring of minMD among the units not belonging to the subset is produced on the screen with 1 per cent, 50 per cent and 99 per cent confidence bands else (default), all plots are suppressed.
Example: 'plots',0
Data Types: double
addRowNames
—add or not names of the rows to the plot of min MD.boolean.If this option is equal to true (default) the first time a row is included in the subset is shown in the plot with the corresponding row label or row number.
Example: 'addRowNames',false
Data Types: logical
out
— description
StructureStructure which contains the following fields
Value | Description |
---|---|
outliers |
k x 1 vector containing the list of the units declared as outliers or empty value if the sample is homogeneous |
mmd |
n-init-by-5 matrix which contains the monitoring of minimum MD at each step of the forward search. 1st col = fwd search index (from init to n-1); 2nd col = minimum MD weighted by row mass; 3rd col = 1 per cent envelope; 4th col = 50 per cent envelope; 5th col = conflev per cent envelope; |
ine |
n-init-by-2 matrix which contains the monitoring of inertia at each step of the forward search. 1st col = fwd search index (from init to n); 2nd col = inertia; |
Un |
(n-init) x 11 Matrix which contains the unit(s) included in the subset at each step of the fwd search. REMARK: in every step the new subset is compared with the old subset. Un contains the unit(s) present in the new subset but not in the old one Un(1,2) for example contains the unit included in step init+1 Un(end,2) contains the units included in the final step of the search |
N |
Original contingency table, in array format. |
loc |
1 x v vector containing location of the data. |
md |
n x 1 vector containing the estimates of the robust Mahalanobis distances (in squared units) mutiplied by the row masses. This vector contains the distances of each observation from the location of the data, relative to the scatter matrix cov. |
thresh |
threshold for minMD with which outliers have been declared |
conflev |
simultaneous confidence level which has been used to declare the outliers. |
simulateUnderH0 |
boolean. If it is true the simulated contingency tables have been specified under H0. |
nsimul |
number of simulations which have been used to create the envelopes. This information is taken from size(N.NsimStore,2) |
Y |
array of size I-by-J containing row profiles. |
class |
'FSCorAna' |
Atkinson, A.C., Riani, M. and Cerioli, A. (2004), "Exploring multivariate data with the forward search", Springer Verlag, New York.
mcdCorAna
|
FSCorAnaeda
|
FSR