1 | covdgk(x, csteps = 10)
|
x |
|
csteps |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | ##---- 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 (x, csteps = 10)
{
p <- dim(x)[2]
covs <- var(x)
mns <- apply(x, 2, mean)
for (i in 1:csteps) {
md2 <- mahalanobis(x, mns, covs)
medd2 <- median(md2)
mns <- apply(x[md2 <= medd2, ], 2, mean)
covs <- var(x[md2 <= medd2, ])
}
rd2 <- mahalanobis(x, mns, covs)
const <- median(rd2)/(qchisq(0.5, p))
covs <- const * covs
list(center = mns, cov = covs)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.