Learn R Programming

nFactors (version 2.3.1)

eigenComputes: Computes Eigenvalues According to the Data Type

Description

The eigenComputes function computes eigenvalues from the identified data type. The function is used internally in many fonctions of the nFactors package to be able to apply these to a vector of eigenvalues, a matrix of correlations or covariance or a data frame.

Usage

eigenComputes(x, cor=TRUE, model="components", ...)

Arguments

x
numeric: a vector of eigenvalues, a matrix of correlations or of covariances or a data.frame of data
cor
logical: if TRUE computes eigenvalues from a correlation matrix, else from a covariance matrix
model
character: "components" or "factors"
...
variable: additionnal parameters to give to the cor or cov functions

Value

  • valuenumeric: return a vector of eigenvalues

Examples

Run this code
# .......................................................
# Different data types
# Vector of eigenvalues
  data(dFactors)
  x1 <- dFactors$Cliff1$eigenvalues
  eigenComputes(x1)
  
# Data from a data.frame
  x2 <- data.frame(matrix(20*rnorm(100), ncol=5))
  eigenComputes(x2, cor=TRUE,  use="everything")
  eigenComputes(x2, cor=FALSE, use="everything")
  eigenComputes(x2, cor=TRUE,  use="everything", method="spearman")
  eigenComputes(x2, cor=TRUE,  use="everything", method="kendall")

# From a covariance matrix
  x3 <- cov(x2)
  eigenComputes(x3, cor=TRUE,  use="everything")
  eigenComputes(x3, cor=FALSE, use="everything")

# From a correlation matrix
  x4 <- cor(x2)
  eigenComputes(x4, use="everything")
# .......................................................

Run the code above in your browser using DataLab