1 | CompRobustDist(data, r, out, classic)
|
data |
|
r |
|
out |
|
classic |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (data, r, out, classic)
{
n <- nrow(data)
p <- ncol(data)
out$sd <- sqrt(mahalanobis(out$T, center = rep(0, length = ncol(out$T)),
cov = diag(x = out$L, nrow = length(out$L))))
out$cutoff$sd <- sqrt(qchisq(0.975, out$k))
XRc <- data - matrix(data = rep(out$M, times = n), nrow = n,
ncol = p, byrow = T)
Xtilde <- out$T %*% t(out$P)
Rdiff <- XRc - Xtilde
out$od <- vector(mode = "numeric", length = n)
if (is.list(dimnames(out$T))) {
names(out$od) <- dimnames(out$T)[[1]]
}
out$od <- apply(Rdiff, 1, vecnorm)
if (out$k != r) {
ms <- unimcd(out$od^(2/3), quan = out$h)
out$cutoff$od <- sqrt(qnorm(0.975, ms$tmcd, ms$smcd)^3)
out$flag <- (out$od <= rep(x = out$cutoff$od, times = length(out$od))) &
(out$sd <= rep(x = out$cutoff$sd, times = length(out$sd)))
}
else {
out$cutoff$od <- 0
out$flag <- out$sd <= rep(x = out$cutoff$sd, times = length(out$sd))
}
if (classic == 0) {
out$classic <- 0
}
out$class <- "ROBPCA"
return(out)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.