1 |
x |
|
y |
|
regfun |
|
cop |
|
KEEP |
|
MC |
|
STAND |
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 38 39 | ##---- 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 = tsreg, cop = 3, KEEP = TRUE, MC = FALSE,
STAND = TRUE)
{
library(MASS)
if (MC)
library(parallel)
x <- as.matrix(x)
y <- as.matrix(y)
px <- ncol(x)
py <- ncol(y)
m <- cbind(x, y)
m <- elimna(m)
if (KEEP)
ivec <- c(1:nrow(x))
if (!KEEP) {
if (!MC)
ivec <- outpro(m, plotit = FALSE, cop = cop, STAND = STAND)$keep
if (MC)
ivec <- outproMC(m, plotit = FALSE, cop = cop, STAND = STAND)$keep
}
np1 <- ncol(x) + 1
vec <- rep(1, nrow(m))
pxpy <- px + py
coef <- matrix(ncol = py, nrow = np1)
res <- matrix(ncol = py, nrow = nrow(m))
for (i in 1:py) {
pv <- px + i
coef[, i] <- regfun(m[ivec, 1:ncol(x)], m[ivec, pv])$coef
vec <- as.matrix(vec)
res[, i] <- m[, pv] - cbind(vec, m[, 1:ncol(x)]) %*%
coef[, i]
}
list(coef = coef, residuals = res)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.