two.boot: Two sample bootstrap of differences between univariate...

View source: R/simpleboot.R

two.bootR Documentation

Two sample bootstrap of differences between univariate statistics.

Description

two.boot is used to bootstrap the difference between various univariate statistics. An example is the difference of means. Bootstrapping is done by independently resampling from sample1 and sample2.

Usage

two.boot(sample1, sample2, FUN, R, student = FALSE, M, weights = NULL, ...)

Arguments

sample1

First sample; a vector of numbers.

sample2

Second sample; a vector of numbers.

FUN

The statistic which is applied to each sample. This can be a quoted string or a function name.

R

Number of bootstrap replicates.

student

Should we do a studentized bootstrap? This requires a double bootstrap so it might take longer.

M

If student is set to TRUE, then M is the number of internal bootstrap replications to do.

weights

Resampling weights; a list with two components. The first component of the list is a vector of weights for sample1 and the second component of the list is a vector of weights for sample2.

...

Other (named) arguments that should be passed to FUN.

Details

The differences are always taken as FUN(sample1) - FUN(sample2). If you want the difference to be reversed you need to reverse the order of the arguments sample1 and sample2.

Value

An object of class "simpleboot", which is almost identical to the regular "boot" object. For example, the boot.ci function can be used on this object.

Author(s)

Roger D. Peng

Examples

library(boot)
set.seed(50)
x <- rnorm(100, 1)  ## Mean 1 normals
y <- rnorm(100, 0)  ## Mean 0 normals
b <- two.boot(x, y, median, R = 100)
hist(b)  ## Histogram of the bootstrap replicates
b <- two.boot(x, y, quantile, R = 100, probs = .75)

simpleboot documentation built on Sept. 11, 2024, 6:21 p.m.