# twocor: Confidence intervals for two-sided tests on correlation... In WRS2: A Collection of Robust Statistical Methods

## Description

The `twopcor` function tests whether the difference between two Pearson correlations is 0. The `twocor` function performs the same test on a robust correlation coefficient (percentage bend correlation or Winsorized correlation).

## Usage

 ```1 2``` ```twopcor(x1, y1, x2, y2, nboot = 599, ...) twocor(x1, y1, x2, y2, corfun = "pbcor", nboot = 599, tr = 0.2, beta = 0.2, ...) ```

## Arguments

 `x1` a numeric vector. `y1` a numeric vector. `x2` a numeric vector. `y2` a numeric vector. `nboot` number of bootstrap samples. `corfun` Either `"pbcor"` for percentage based correlation or `"wincor"` for Winsorized correlation. `tr` amount of Winsorization. `beta` bending constant. `...` currently ignored.

## Details

It is tested whether the first correlation coefficient (based on `x1` and `y1`) equals to the second correlation coefficient (based on `x2` and `y2`). Both approaches return percentile bootstrap CIs.

## Value

`twopcor` and `twocor` return an object of class `"twocor"` containing:

 `r1` robust correlation coefficient `r2` value of the test statistic `ci` confidence interval `p.value` p-value `call` function call

## References

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

`pbcor`, `wincor`

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11``` ```ct1 <- subset(hangover, subset = (group == "control" & time == 1))\$symptoms ct2 <- subset(hangover, subset = (group == "control" & time == 2))\$symptoms at1 <- subset(hangover, subset = (group == "alcoholic" & time == 1))\$symptoms at2 <- subset(hangover, subset = (group == "alcoholic" & time == 2))\$symptoms set.seed(111) twopcor(ct1, ct2, at1, at2) set.seed(123) twocor(ct1, ct2, at1, at2, corfun = "pbcor", beta = 0.15) set.seed(224) twocor(ct1, ct2, at1, at2, corfun = "wincor", tr = 0.15, nboot = 50) ```

### Example output

```Call:
twopcor(x1 = ct1, y1 = ct2, x2 = at1, y2 = at2)

First correlation coefficient: 0.3708
Second correlation coefficient: 0.7124
Confidence interval (difference): -0.7222 0.8055

Call:
twocor(x1 = ct1, y1 = ct2, x2 = at1, y2 = at2, corfun = "pbcor",
beta = 0.15)

First correlation coefficient: 0.5886
Second correlation coefficient: 0.5628
Confidence interval (difference): -0.6855 0.8516
p-value: 0.94206

Call:
twocor(x1 = ct1, y1 = ct2, x2 = at1, y2 = at2, corfun = "wincor",
nboot = 50, tr = 0.15)

First correlation coefficient: 0.6316
Second correlation coefficient: 0.4083
Confidence interval (difference): -0.5797 0.8904
p-value: 0.86957

Warning messages:
1: In cor(xvec, yvec) : the standard deviation is zero
2: In cor(xvec, yvec) : the standard deviation is zero
3: In cor(xvec, yvec) : the standard deviation is zero
4: In cor(xvec, yvec) : the standard deviation is zero
```

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