metan (version 1.2.1)

corr_ci: Confidence interval for correlation coefficient

Description

Computes the half-width confidence interval for correlation coefficient using the nonparametric method proposed by Olivoto et al. (2018).

Usage

corr_ci(.data = NA, ..., r = NULL, n = NULL, by = NULL, verbose = TRUE)

Arguments

.data

A dataset containing variables only or a symmetric correlation matrix.

...

Variables to compute the confidence interval. If not informed, all the numeric variables from .data are used.

r

If data is not available, provide the value for correlation coefficient.

n

The sample size if data is a correlation matrix or if r is informed.

by

One variable (factor) to split the data into subsets. The function is then applied to each subset and returns a list where each element contains the results for one level of the variable in by. To split the data by more than one factor variable, use the function split_factors to pass subsetted data to .data.

verbose

If verbose = TRUE then some results are shown in the console.

Value

A tibble containing the values of the correlation, confidence interval, upper and lower limits for all combination of variables.

Details

The half-width confidence interval is computed according to the following equation: $$CI_w = 0.45304^r \times 2.25152 \times n^{-0.50089}$$

where \(n\) is the sample size and r is the correlation coefficient.

References

Olivoto, T., A.D.C. Lucio, V.Q. Souza, M. Nardino, M.I. Diel, B.G. Sari, D.. K. Krysczun, D. Meira, and C. Meier. 2018. Confidence interval width for Pearson's correlation coefficient: a Gaussian-independent estimator based on sample size and strength of association. Agron. J. 110:1-8. 10.2134/agronj2016.04.0196

Examples

Run this code
# NOT RUN {
library(metan)

CI1 <- corr_ci(data_ge2)

# By each level of the factor 'ENV'
CI2 <- corr_ci(data_ge2, CD, TKW, NKE, by = ENV)

# }

Run the code above in your browser using DataLab