ci_cor {confintr} | R Documentation |
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.
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,
...
)
x |
A numeric vector or a |
y |
A numeric vector (only used if |
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 |
R |
The number of bootstrap resamples. Only used for |
seed |
An integer random seed. Only used for |
... |
Further arguments passed to |
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).
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.
Efron, B. and Tibshirani R. J. (1994). An Introduction to the Bootstrap. Chapman & Hall/CRC.
Canty, A and Ripley B. (2019). boot: Bootstrap R (S-Plus) Functions.
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)