1 | covsim2(n = 100, p = 2, steps = 5, gam = 0.4, runs = 20)
|
n |
|
p |
|
steps |
|
gam |
|
runs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | ##---- 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 (n = 100, p = 2, steps = 5, gam = 0.4, runs = 20)
{
A <- sqrt(diag(1:p))
mbact <- 0
for (i in 1:runs) {
x <- matrix(rnorm(n * p), ncol = p, nrow = n)
val <- floor(gam * n)
tem <- 10 + 0 * 1:p
x[1:val, ] <- x[1:val, ] + tem
x <- x %*% A
out <- covmba(x, csteps = steps)
center <- out$center
cov <- out$cov
rd2 <- mahalanobis(x, center, cov)
if (min(rd2[1:val]) > max(rd2[(val + 1):n]))
mbact <- mbact + 1
}
list(mbact = mbact)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.