1 |
x |
|
y |
|
nboot |
|
MC |
|
SEED |
|
op.dis |
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 40 41 42 43 44 | ##---- 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, nboot = 300, MC = FALSE, SEED = TRUE, op.dis = TRUE)
{
if (SEED)
set.seed(2)
if (MC)
library(parallel)
est = mlrreg(x, y)$coef
pval = est
n = nrow(x)
JK = (ncol(x) + 1) * ncol(y)
vals = matrix(0, nrow = nboot, ncol = JK)
data <- matrix(sample(n, size = n * nboot, replace = TRUE),
nrow = nboot)
if (!MC)
for (ib in 1:nboot) {
vals[ib, ] = mlrreg(x[data[ib, ], ], y[data[ib, ],
])$coef
}
if (MC) {
data = listm(t(data))
vals = mclapply(data, mlrreg.est, x, y, mc.preschedule = TRUE)
vals = t(matl(vals))
}
pv = NULL
for (j in 1:JK) {
pv[j] = mean(vals[, j] > 0) + 0.5 * mean(vals[, j] ==
0)
pv[j] = 2 * min(c(pv[j], 1 - pv[j]))
}
ic = 0
il = 1
iu = ncol(x) + 1
for (iy in 1:ncol(y)) {
pval[, iy] = pv[il:iu]
il = il + ncol(x) + 1
iu = iu + ncol(x) + 1
}
list(estimates = est, p.values = pval)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.