pb2gen: Compute a bootstrap confidence interval for the difference...

Description Usage Arguments Examples

View source: R/Rallfun-v24.R

Description

By default, MOM-estimators are compared.

Setting est=mean, for example, will result in a percentile bootstrap confidence interval for the difference between means. Setting est=onestep will compare M-estimators of location.

The default number of bootstrap samples is nboot=2000.

Usage

1
pb2gen(x, y, alpha = 0.05, nboot = 2000, est = onestep, SEED = TRUE, pr = TRUE, ...)

Arguments

x
y
alpha
nboot
est
SEED
pr
...

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
##---- 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 (x, y, alpha = 0.05, nboot = 2000, est = onestep, SEED = TRUE, 
    pr = TRUE, ...) 
{
    x <- x[!is.na(x)]
    y <- y[!is.na(y)]
    if (SEED) 
        set.seed(2)
    if (pr) 
        print("Taking bootstrap samples. Please wait.")
    datax <- matrix(sample(x, size = length(x) * nboot, replace = T), 
        nrow = nboot)
    datay <- matrix(sample(y, size = length(y) * nboot, replace = T), 
        nrow = nboot)
    bvecx <- apply(datax, 1, est, ...)
    bvecy <- apply(datay, 1, est, ...)
    bvec <- sort(bvecx - bvecy)
    low <- round((alpha/2) * nboot) + 1
    up <- nboot - low
    temp <- sum(bvec < 0)/nboot + sum(bvec == 0)/(2 * nboot)
    sig.level <- 2 * (min(temp, 1 - temp))
    se <- var(bvec)
    list(ci = c(bvec[low], bvec[up]), p.value = sig.level, sq.se = se)
  }

WRS documentation built on May 2, 2019, 5:49 p.m.