#' Generate Jackknife Subsamples
#'
#' Generate jackknife subsamples. For data with \eqn{n} elements,
#' the jackknife generates \eqn{n} subsamples, each with one element
#' deleted. The generalized (delete-\eqn{p}, block) jackknife generates
#' subsamples by deleting `p` observations.
#'
#' @template param-n
#' @param size A scalar integer representing the number of elements to delete.
#' When `size = 1`, the subsets are generated by ordinary
#' (delete-one) jackknife. When `size > 1`, the subsets are generated by
#' the block (delete-\eqn{p}) jackknife.
#'
#' @references
#'
#' - Davison, A. C. & Hinkley, D. V. (1997)
#' *Bootstrap Methods and Their Applications*.
#' Cambridge University Press, Cambridge. ISBN 0-521-57391-2.
#' - Tukey, J. W. (1958). "Bias and confidence in not quite large samples".
#' *The Annals of Mathematical Statistics*.
#' [doi:10.1214/aoms/1177706647](https://dx.doi.org/10.1214/aoms/1177706647).
#' - Efron, B.; Stein, C. (May 1981). "The Jackknife Estimate of Variance".
#' *The Annals of Statistics*.
#' [doi:10.1214/aos/1176345462](https://dx.doi.org/10.1214/aos/1176345462).
#'
#' @export
jackknife <- function(n, size = 1L) {
idx <- seq_len(n)
f <- function(i) sample_idx(out_id = i, n = n)
if (size == 1) {
res <- map(idx, f)
} else {
res <- utils::combn(idx, size, FUN = f, simplify = FALSE)
}
res
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.