R/Boot.R

Defines functions Boot

Boot <- function(rf, R){

    cat("(3) Do bootstrapping ... ")

    G <- rf$Gij
    Gset <- data.frame(no = as.numeric(row.names(rf)), G = G)
    Gset_list <- split(Gset, Gset$no)

    boot <- function(l){
        sample <- c(l$G, sample(x = G[G != l$G], R-1, replace = T))
        sample[is.na(sample)] <- -100
        sorted <- sort(sample, decreasing = T)
        cr <- which(sorted == sample[1])/R
        return(mean(cr))
    }

    pval <- do.call("c", lapply(Gset_list, boot))

    result <- cbind(rf, pval)

    cat("Done ! \n")

    return(result)
}

Try the spnaf package in your browser

Any scripts or data that you put into this service are public.

spnaf documentation built on June 22, 2024, 9:29 a.m.