This function calculates CIs for a population correlation coefficient.
For Pearson correlation, "normal" CIs are available (by stats::cor.test()).
Also bootstrap CIs are supported (by default "bca", and the only option for rank correlations).
An object of class "cint" containing these components:
parameter: Parameter specification.
interval: CI for the parameter.
estimate: Parameter estimate.
probs: Lower and upper probabilities.
type: Type of interval.
info: Additional description.
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
Lower and upper probabilities, by default c(0.025, 0.975).
method
Type of correlation coefficient, one of "pearson" (default), "kendall",
or "spearman". For the latter two, only bootstrap CIs are supported.
The names can be abbreviated.
type
Type of CI. One of "normal" (the default) or "bootstrap"
(the only option for rank-correlations).
boot_type
Type of bootstrap CI ("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".
ci_cor(iris[1:2])
ci_cor(iris[1:2], type = "bootstrap", R = 999) # Use larger Rci_cor(iris[1:2], method = "spearman", type = "bootstrap", R = 999) # Use larger R