Learn R Programming

fungible (version 2.4.4)

corDensity: Generate the marginal density of a correlation from a uniformly sampled R matrix.

Description

Generate the marginal density of a correlation from a uniformly sampled R matrix.

Usage

corDensity(NVar)

Value

corDensity returns the following objects:

  • r (numeric) A sequence of numbers from -1, to 1 in .001 increments.

  • rDensity (numeric) The density of r.

Arguments

NVar

(integer) The order of the correlation matrix.

Author

Niels G. Waller

References

Hürlimann, W. (2012). Positive semi-definite correlation matrices: Recursive algorithmic generation and volume measure. Pure Mathematical Science, 1(3), 137--149.

Joe, H. (2006). Generating random correlation matrices based on partial correlations. Journal of Multivariate Analysis, 97(10), 2177--2189.

Examples

Run this code

  out <- corDensity(NVar = 5)
  
  plot(out$r, out$rDensity, 
       typ = "l",
       xlab = "r",
       ylab = "Density of r",
       main = "")

Run the code above in your browser using DataLab