## An Example with bad condition number and "border case" outliers
if(FALSE) {## Not yet ok, because of bug in adjOutl
dim(longley)
set.seed(1) ## result is random %% and there's a bug - FIXME! -- try set.seed(3)
ao1 <- adjOutlyingness(longley)
## which are not outlying ?
table(ao1$nonOut) ## all of them
stopifnot(all(ao1$nonOut))
}
## An Example with outliers :
dim(hbk)
set.seed(1)
ao.hbk <- adjOutlyingness(hbk)
str(ao.hbk)
hist(ao.hbk $adjout)## really two groups
table(ao.hbk$nonOut)## 14 outliers, 61 non-outliers:
## outliers are :
which(! ao.hbk$nonOut) # 1 .. 14 --- but not for all random seeds!
## here, they are the same as found by (much faster) MCD:
cc <- covMcd(hbk)
stopifnot(all(cc$mcd.wt == ao.hbk$nonOut))
## This is revealing (about 1--2 cases, where outliers are *not* == 1:14
## but needs almost 1 [sec] per call:
if(interactive()) {
for(i in 1:30) {
print(system.time(ao.hbk <- adjOutlyingness(hbk)))
if(!identical(iout <- which(!ao.hbk$nonOut), 1:14)) {
cat("Outliers:
"); print(iout)
}
}
}
Run the code above in your browser using DataLab