simpleBootstrap: Simple Bootstrap Function

Description Usage Arguments Value Examples

View source: R/utility_functions.R

Description

A function for computing a test statistic over multiple replicates of a set of data. Replicates are created by sampling from the original data with replacement.

Usage

1
simpleBootstrap(x, T_x = mean, nRep = 1000, ...)

Arguments

x

a numeric vector, or a long-form matrix or data frame.

T_x

a function to compute a desired test statistic (default is the mean).

nRep

the number or replicates to sample.

...

additional parameters for the test statistic function.

Value

Returns a list containing the test statistics for each replicate, along with the test statistic for the original set of data.

Examples

1
2
3
4
5
6
7
8
9
# Vector
x = rnorm( 100 )
bootstrap = simpleBootstrap( x, T_x = median )
quantile( bootstrap$replicates, c( .16, .84 ) )

# Matrix
x = cbind( rlnorm( 100, -2, .5 ), rbeta( 100, 4, 1 ) )
bootstrap = simpleBootstrap( x, T_x = colMeans )
apply( bootstrap$replicates, 1, quantile, prob = c( .16, .84 ) )

rettopnivek/utilityf documentation built on June 17, 2018, 12:57 p.m.