1 | scale_resamp(p.num, p.idx, log.p.wei, p.mat, p.layer, p.layer.sor.I, p.dapts, ss.size, resamp.method, ess.thresh, p.pass.arr = NULL, p.cyc.arr = NULL)
|
p.num |
|
p.idx |
|
log.p.wei |
|
p.mat |
|
p.layer |
|
p.layer.sor.I |
|
p.dapts |
|
ss.size |
|
resamp.method |
|
ess.thresh |
|
p.pass.arr |
|
p.cyc.arr |
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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | ##---- 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 (p.num, p.idx, log.p.wei, p.mat, p.layer, p.layer.sor.I,
p.dapts, ss.size, resamp.method, ess.thresh, p.pass.arr = NULL,
p.cyc.arr = NULL)
{
wei.control <- part.ess(log.p.wei, p.num)
if (wei.control$ess <= ess.thresh) {
r.idx <- resamp.method(wei.control$p.wei)$p.idx
p.idx <- p.idx[r.idx]
p.mat <- p.mat[, r.idx, drop = FALSE]
p.dapts[] <- sample(dsz, 3 * p.num * ss.size, replace = TRUE)
if (is.null(p.pass.arr) == FALSE) {
p.pass.arr <- p.pass.arr[, , r.idx]
dimnames(p.pass.arr)[[3]] <- sprintf("part.%i", 1:p.num)
}
if (is.null(p.cyc.arr) == FALSE) {
p.cyc.arr <- p.cyc.arr[, , r.idx]
dimnames(p.cyc.arr)[[3]] <- sprintf("part.%i", 1:p.num)
}
if (p.layer.sor.I == 0) {
p.layer <- mat.sort.r(p.layer, p.num, "c.idx")
}
p.layer <- p.layer[, r.idx, drop = FALSE]
p.layer["c.idx", ] <- 1:p.num
p.layer["t", ] <- p.layer["deg.s", ] + rexp(p.num, rate = p.layer["Delta",
])
if (is.null(p.pass.arr) == FALSE) {
p.layer["next.ev", ] <- (sign(p.layer["tau.bar",
] - p.layer["t", ]) + 1)/2
p.layer["next.ev", ] <- p.layer["next.ev", ] * p.layer["t",
] + (1 - p.layer["next.ev", ]) * p.layer["tau.bar",
]
}
if (p.layer.sor.I == 0) {
if (is.null(p.pass.arr) == FALSE) {
p.layer <- mat.sort.r(p.layer, p.num, "next.ev")
}
else {
p.layer <- mat.sort.r(p.layer, p.num, "t")
}
}
log.p.wei[] <- log(1/p.num)
resamp.I <- 1
}
else {
r.idx <- 1:p.num
log.p.wei <- wei.control$log.p.wei
resamp.I <- 0
}
list(p.idx = p.idx, r.idx = r.idx, log.p.wei = log.p.wei,
p.mat = p.mat, p.layer = p.layer, p.dapts = p.dapts,
resamp.I = resamp.I, ess = wei.control$ess, p.pass.arr = p.pass.arr,
p.cyc.arr = p.cyc.arr)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.