Learn R Programming

metagear (version 0.1)

random_r: Random generation of correlation coefficients.

Description

Generates random correlation coefficients (r or Pearson product-moment correlation coefficients) and their variances (Pearson 1895). Also provides Fisher z-transformed correlation coefficients (Fisher 1915).

Usage

random_r(K = 100, correlation = 0.5, N = 10, Fisher_Z = FALSE)

Arguments

K
Number of effect sizes to generate.
correlation
The mean population correlation coefficient (rho) to simulate. Must range between -1 to 1.
N
The number of samples used to estimate each correlation coefficient. When a non-negative integer, all r will be estimated using the same N. A vector of unequal N's can also be taken; if so, K will be ignored and the number of randomly generated r will
Fisher_Z
When TRUE, also returns the Fisher z-transformed correlation coefficients and their variances (Fisher 1915).

Value

  • A data table with columns of random effect sizes (r), their variances and sample sizes.

References

Pearson, K. 1895. Notes on regression and inheritance in the case of two parents. Proceedings of the Royal Society of London 58: 240-242. Fisher, R.A. 1915. Frequency distribution of the values of the correlation coefficient in samples of an indefinitely large population. Biometrika 10: 507-521.

Examples

Run this code
random_r(K = 5, correlation = 0.5, N = 50)

Run the code above in your browser using DataLab