bootstrip:

Usage Arguments Examples

Usage

1
bootstrip(mat, mod, fn, iterations = 100, p_samples = 0.5, mc.cores = 12)

Arguments

mat
mod
fn
iterations
p_samples
mc.cores

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
##---- 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 (mat, mod, fn, iterations = 100, p_samples = 0.5, mc.cores = 12) 
{
    stopifnot(nrow(mod) == ncol(mat))
    ta = mclapply(1:iterations, function(core_i) {
        idx = sample.int(ncol(mat), p_samples * ncol(mat), replace = TRUE)
        msub = mat[, idx, drop = TRUE]
        fit = lmFit(msub, mod[idx, , drop = TRUE])
        fn(fit)
    }, mc.cores = mc.cores)
    beta = matrix(NA, nrow(mat), ncol = iterations)
    for (i in 1:iterations) {
        beta[, i] = ta[[i]]
    }
    colnames(beta) = paste0("sample_", 1:iterations)
    rownames(beta) = rownames(mat)
    beta
  }

brentp/bootstrip documentation built on May 13, 2019, 5:11 a.m.