1 |
x |
|
p |
|
grp |
|
q |
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 | ##---- 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, p = length(x), grp = c(1:p), q = 0.5)
{
if (is.matrix(x))
x <- listm(x)
if (!is.list(x))
stop("The data are not stored in a matrix or list mode.")
p <- length(grp)
pm1 <- p - 1
for (i in 1:pm1) {
ip <- i + 1
if (length(x[[grp[ip]]]) != length(x[[grp[i]]]))
stop("The number of observations in each group must be equal")
}
n <- length(x[[grp[1]]])
covest <- matrix(0, p, p)
for (j in 1:p) {
for (k in 1:p) {
if (j == k)
covest[j, j] <- cov2med(x[[grp[j]]], q = q)
if (j < k) {
covest[j, k] <- cov2med(x[[grp[j]]], x[[grp[k]]],
q = q)
covest[k, j] <- covest[j, k]
}
}
}
covest
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.