1 |
x |
|
y |
|
regfun |
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, y, regfun = bmreg)
{
x <- as.matrix(x)
xmat <- matrix(0, nrow(x), ncol(x))
mval <- floor(length(y)/2)
mr <- length(y) - mval
xmatl <- matrix(0, mval, ncol(x))
xmatr <- matrix(0, mr, ncol(x))
hmat <- matrix(NA, ncol(x), ncol(x))
isub <- c(1:length(y))
ksub <- c(1:ncol(x)) + 1
for (k in 1:ncol(x)) {
xord <- order(x[, k])
yord <- y[xord]
yl <- yord[isub <= mval]
yr <- yord[isub > mval]
for (j in 1:ncol(x)) {
xmat[, j] <- x[xord, j]
xmatl[, j] <- xmat[isub <= mval, j]
xmatr[, j] <- xmat[isub > mval, j]
}
coefl <- regfun(xmatl, yl)$coef
coefr <- regfun(xmatr, yr)$coef
hmat[k, ] <- coefr[ksub[ksub >= 2]]/coefl[ksub[ksub >=
2]]
}
hmat
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.