1 |
x |
|
y |
|
regfun |
|
nboot |
|
SEED |
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 | ##---- 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 = mlrreg, nboot = 100, SEED = TRUE)
{
if (SEED)
set.seed(2)
estall = regfun(x, y)$coef
est = as.vector(estall[-1, ])
n = nrow(x)
JK = ncol(x) * ncol(y)
vals = matrix(0, nrow = nboot, ncol = JK)
for (i in 1:nboot) {
bsam = sample(n, replace = TRUE)
vals[i, ] = as.vector(regfun(x[bsam, ], y[bsam, ])$coef[-1,
])
}
Sv = cov(vals)
est = as.matrix(est)
k = 1/JK
test <- k * crossprod(est, solve(Sv, est))[1, ]
v1 = JK - 1
v2 = n - JK
pval = 1 - pf(test, v1, v2)
list(test.stat = test, p.value = pval, est = estall)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.