# ci_cor: Confidence Interval for Correlation Coefficients In confintr: Confidence Intervals

 ci_cor R Documentation

## Confidence Interval for Correlation Coefficients

### Description

This function calculates confidence intervals for a population correlation coefficient. For Pearson correlation, "normal" confidence intervals are available (by `stats::cor.test`). Also bootstrap confidence intervals are supported and are the only option for rank correlations.

### Usage

```ci_cor(
x,
y = NULL,
probs = c(0.025, 0.975),
method = c("pearson", "kendall", "spearman"),
type = c("normal", "bootstrap"),
boot_type = c("bca", "perc", "norm", "basic"),
R = 9999,
seed = NULL,
...
)
```

### Arguments

 `x` A numeric vector or a `matrix/data.frame` with exactly two numeric columns. `y` A numeric vector (only used if `x` is a vector). `probs` Error probabilites. The default c(0.025, 0.975) gives a symmetric 95% confidence interval. `method` Type of correlation coefficient, one of "pearson" (default), "kendall", or "spearman". For the latter two, only bootstrap confidence intervals are supported. The names can be abbreviated. `type` Type of confidence interval. One of "normal" (the default) or "bootstrap" (the only option for rank-correlations). `boot_type` Type of bootstrap confidence interval ("bca", "perc", "norm", "basic"). Only used for `type = "bootstrap"`. `R` The number of bootstrap resamples. Only used for `type = "bootstrap"`. `seed` An integer random seed. Only used for `type = "bootstrap"`. `...` Further arguments passed to `boot::boot`.

### Details

Bootstrap confidence intervals are calculated by the package "boot", see references. The default bootstrap type is "bca" (bias-corrected accelerated) as it enjoys the property of being second order accurate as well as transformation respecting (see Efron, p. 188).

### Value

A list with class `cint` containing these components:

• `parameter`: The parameter in question.

• `interval`: The confidence interval for the parameter.

• `estimate`: The estimate for the parameter.

• `probs`: A vector of error probabilities.

• `type`: The type of the interval.

• `info`: An additional description text for the interval.

### References

1. Efron, B. and Tibshirani R. J. (1994). An Introduction to the Bootstrap. Chapman & Hall/CRC.

2. Canty, A and Ripley B. (2019). boot: Bootstrap R (S-Plus) Functions.

### Examples

```ci_cor(iris[1:2])
ci_cor(iris[1:2], type = "bootstrap", R = 999, seed = 1)
ci_cor(iris[1:2], method = "spearman", type = "bootstrap", R = 999, seed = 1)
ci_cor(iris[1:2], method = "k", type = "bootstrap", R = 999, seed = 1)
```

confintr documentation built on Sept. 29, 2022, 5:13 p.m.