pbcor: Robust correlation coefficients.

Description Usage Arguments Details Value References See Also Examples

View source: R/pbcor.R

Description

The pbcor function computes the percentage bend correlation coefficient, wincor the Winsorized correlation, pball the percentage bend correlation matrix, winall the Winsorized correlation matrix.

Usage

1
2
3
4
pbcor(x, y = NULL, beta = 0.2, ci = FALSE, nboot = 500, alpha = 0.05, ...)
pball(x, beta = 0.2, ...)
wincor(x, y = NULL, tr = 0.2, ci = FALSE, nboot = 500, alpha = 0.05, ...)
winall(x, tr = 0.2, ...)

Arguments

x

a numeric vector, a matrix or a data frame.

y

a second numeric vector (for correlation functions).

beta

bending constant.

tr

amount of Winsorization.

ci

whether boostrap CI should be computed or not.

nboot

number of bootstrap samples for CI computation.

alpha

alpha level for CI computation.

...

currently ignored.

Details

It tested is whether the correlation coefficient equals 0 (null hypothesis) or not. Missing values are deleted pairwise. The tests are sensitive to heteroscedasticity. The test statistic H in pball tests the hypothesis that all correlations are equal to zero.

Value

pbcor and wincor return an object of class "pbcor" containing:

cor

robust correlation coefficient

test

value of the test statistic

p.value

p-value

n

number of effective observations

cor_ci

bootstrap confidence interval

call

function call

pball and winall return an object of class "pball" containing:

pbcorm

robust correlation matrix

p.values

p-values

H

H-statistic

H.p.value

p-value H-statistic

cov

variance-covariance matrix

References

Wilcox, R. (2012). Introduction to Robust Estimation and Hypothesis Testing (3rd ed.). Elsevier.

See Also

twocor

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
x1 <- subset(hangover, subset = (group == "control" & time == 1))$symptoms
x2 <- subset(hangover, subset = (group == "control" & time == 2))$symptoms

pbcor(x1, x2)
pbcor(x1, x2, beta = 0.1, ci = TRUE)

wincor(x1, x2)
wincor(x1, x2, tr = 0.1, ci = TRUE)

require(reshape)
hanglong <- subset(hangover, subset = group == "control")
hangwide <- cast(hanglong, id ~ time, value = "symptoms")[,-1]

pball(hangwide)
winall(hangwide)

Example output

Call:
pbcor(x = x1, y = x2)

Robust correlation coefficient: 0.6005
Test statistic: 3.1861
p-value: 0.00512 
Call:
pbcor(x = x1, y = x2, beta = 0.1, ci = TRUE)

Robust correlation coefficient: 0.5028
Test statistic: 2.4678
p-value: 0.02385 

Bootstrap CI: [0.1205; 0.8231]

Call:
wincor(x = x1, y = x2)

Robust correlation coefficient: 0.6363
Test statistic: 3.4993
p-value: 0.00573 
Call:
wincor(x = x1, y = x2, tr = 0.1, ci = TRUE)

Robust correlation coefficient: 0.5134
Test statistic: 2.5384
p-value: 0.02365 

Bootstrap CI: [0.0714; 0.8652]

Loading required package: reshape
Call:
pball(x = hangwide)

Robust correlation matrix:
       1      2      3
1 1.0000 0.6005 0.7072
2 0.6005 1.0000 0.6388
3 0.7072 0.6388 1.0000

p-values:
        1       2       3
1      NA 0.00512 0.00049
2 0.00512      NA 0.00243
3 0.00049 0.00243      NA


Test statistic H: 3.258192e+182, p-value = 0

Call:
winall(x = hangwide)

Robust correlation matrix:
       1      2      3
1 1.0000 0.6363 0.7049
2 0.6363 1.0000 0.6185
3 0.7049 0.6185 1.0000

p-values:
        1       2       3
1      NA 0.00573 0.00178
2 0.00573      NA 0.00750
3 0.00178 0.00750      NA

WRS2 documentation built on July 20, 2021, 9:06 a.m.

Related to pbcor in WRS2...