corb: Compute a .95 confidence interval for a correlation

Description Usage Arguments Examples

View source: R/Rallfun-v24.R

Description

The default correlation is the percentage bend.

The function corfun is any function that returns a correlation coefficient in corfun$cor. The functions pbcor and wincor follow this convention.

When using Pearson's correlation, and when n<250, use lsfitci instead.

The default number of bootstrap samples is nboot=599

Usage

1
corb(x, y, corfun = pbcor, nboot = 599, SEED = TRUE, ...)

Arguments

x
y
corfun
nboot
SEED
...

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
##---- 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, corfun = pbcor, nboot = 599, SEED = T, ...) 
{
    est <- corfun(x, y, ...)$cor
    if (SEED) 
        set.seed(2)
    data <- matrix(sample(length(y), size = length(y) * nboot, 
        replace = T), nrow = nboot)
    bvec <- apply(data, 1, corbsub, x, y, corfun, ...)
    ihi <- floor(0.975 * nboot + 0.5)
    ilow <- floor(0.025 * nboot + 0.5)
    bsort <- sort(bvec)
    corci <- 1
    corci[1] <- bsort[ilow]
    corci[2] <- bsort[ihi]
    phat <- sum(bvec < 0)/nboot
    sig <- 2 * min(phat, 1 - phat)
    list(cor.ci = corci, p.value = sig, cor.est = est)
  }

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