eigenFrom: Identify the Data Type to Obtain the Eigenvalues

View source: R/eigenFrom.r

eigenFromR Documentation

Identify the Data Type to Obtain the Eigenvalues

Description

The eigenFrom function identifies the data type from which to obtain the eigenvalues. The function is used internally in many functions 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

eigenFrom(x)

Arguments

x

numeric: a vector of eigenvalues, a matrix of correlations or of covariances or a data.frame of data

Value

character: return the data type to obtain the eigenvalues: "eigenvalues", "correlation" or "data"

Author(s)

Gilles Raiche
Centre sur les Applications des Modeles de Reponses aux Items (CAMRI)
Universite du Quebec a Montreal
raiche.gilles@uqam.ca

David Magis
Departement de mathematiques
Universite de Liege
David.Magis@ulg.ac.be

Examples

# .......................................................
# Different data types
# Examples of adequate data sources
# Vector of eigenvalues
data(dFactors)
x1 <- dFactors$Cliff1$eigenvalues
eigenFrom(x1)

# Data from a data.frame
x2 <- data.frame(matrix(20*rnorm(100), ncol=5))
eigenFrom(x2)

# From a covariance matrix
x3 <- cov(x2)
eigenFrom(x3)

# From a correlation matrix
x4 <- cor(x2)
eigenFrom(x4)

# Examples of inadequate data sources: not run because of errors generated
# x0 <- c(2,1)             # Error: not enough eigenvalues
# eigenFrom(x0)
# x2 <- matrix(x1, ncol=5) # Error: non a symetric covariance matrix
# eigenFrom(x2)
# eigenFrom(x3[,(1:2)])    # Error: not enough variables
# x6 <- table(x5)          # Error: not a valid data class
# eigenFrom(x6)
# .......................................................

nFactors documentation built on Oct. 10, 2022, 5:07 p.m.

Related to eigenFrom in nFactors...