prec_cor: Sample size or precision for correlation coefficient

View source: R/correlation_measures.R

prec_corR Documentation

Sample size or precision for correlation coefficient

Description

prec_cor returns the sample size or the precision for the given pearson, spearman, or kendall correlation coefficient.

Usage

prec_cor(
  r,
  n = NULL,
  conf.width = NULL,
  conf.level = 0.95,
  method = c("pearson", "kendall", "spearman"),
  ...
)

Arguments

r

desired correlation coefficient.

n

sample size.

conf.width

precision (the full width of the confidence interval).

conf.level

confidence level.

method

Exactly one of pearson (default), kendall, or spearman. Methods can be abbreviated.

...

other options to uniroot (e.g. tol)

Details

Exactly one of the parameters n or conf.width must be passed as NULL, and that parameter is determined from the other.

Sample size or precision is calculated according to formula 2 in Bonett and Wright (2000). The use of pearson is only recommended, if n ≥ 25. The pearson correlation coefficient assumes bivariate normality. If the assumption of bivariate normality cannot be met, spearman or kendall should be considered.

n is rounded up to the next whole number using ceiling.

uniroot is used to solve n.

Value

Object of class "presize", a list of arguments (including the computed one) augmented with method and note elements.

References

Bonett DG, and Wright TA (2000) Sample size requirements for estimating Pearson, Kendall and Spearman correlations Psychometrika 65:23-28. doi: 10.1007/BF02294183

Examples

# calculate confidence interval width...
# Pearson correlation coefficient
prec_cor(r = 0.5, n = 100)
# Kendall rank correlation coefficient (tau)
prec_cor(r = 0.5, n = 100, method = "kendall")
# Spearman's rank correlation coefficient
prec_cor(r = 0.5, n = 100, method = "spearman")
# calculate N required for a given confidence interval width...
# Pearson correlation coefficient
prec_cor(r = 0.5, conf.width = .15)
# Kendall rank correlation coefficient (tau)
prec_cor(r = 0.5, conf.width = .15, method = "kendall")
# Spearman's rank correlation coefficient
prec_cor(r = 0.5, conf.width = .15, method = "spearman")

presize documentation built on March 7, 2023, 8:28 p.m.