pbcor: Percentage Bend Correlation (bivariate)

Description Usage Arguments See Also Examples

View source: R/Rallfun-v24.R

Description

Compute the percentage bend correlation between x and y.

Usage

1
pbcor(x, y, beta = 0.2)

Arguments

x
y
beta

beta is the bending constant for omega sub N.

See Also

pball, corb

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
29
30
##---- 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, beta = 0.2) 
{
    if (length(x) != length(y)) 
        stop("The vectors do not have equal lengths")
    if (sum(is.na(c(x, y))) != 0) {
        m1 <- matrix(c(x, y), length(x), 2)
        m1 <- elimna(m1)
        x <- m1[, 1]
        y <- m1[, 2]
    }
    temp <- sort(abs(x - median(x)))
    omhatx <- temp[floor((1 - beta) * length(x))]
    temp <- sort(abs(y - median(y)))
    omhaty <- temp[floor((1 - beta) * length(y))]
    a <- (x - pbos(x, beta))/omhatx
    b <- (y - pbos(y, beta))/omhaty
    a <- ifelse(a <= -1, -1, a)
    a <- ifelse(a >= 1, 1, a)
    b <- ifelse(b <= -1, -1, b)
    b <- ifelse(b >= 1, 1, b)
    pbcor <- sum(a * b)/sqrt(sum(a^2) * sum(b^2))
    test <- pbcor * sqrt((length(x) - 2)/(1 - pbcor^2))
    sig <- 2 * (1 - pt(abs(test), length(x) - 2))
    list(cor = pbcor, test = test, siglevel = sig)
  }

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