Learn R Programming

Rdimtools (version 0.3.2)

do.fa: Exploratory Factor Analysis

Description

do.fa is an optimization-based implementation of a popular technique, Exploratory Factor Analysis. This link explains similarities and intrinsic differences between a closely-related method of Principal Component Analysis (PCA).

Usage

do.fa(X, ndim = 2, preprocess = c("center", "scale", "cscale",
  "decorrelate", "whiten"), maxiter = 1000, tolerance = 1e-06)

Arguments

X

an \((n\times p)\) matrix or data frame whose rows are observations and columns represent independent variables.

ndim

an integer-valued number of loading variables, or target dimension.

preprocess

an additional option for preprocessing the data. Default is "center". See also aux.preprocess for more details.

maxiter

maximum number of iterations for updating.

tolerance

stopping criterion in a Frobenius norm.

Value

a named list containing

Y

an \((n\times ndim)\) matrix whose rows are embedded observations.

trfinfo

a list containing information for out-of-sample prediction.

projection

a \((p\times ndim)\) whose columns are basis for projection.

loadings

a \((p\times ndim)\) matrix whose rows are extracted loading factors.

noise

a length-\(p\) vector of estimated noise.

References

spearman_general_1904Rdimtools

Examples

Run this code
# NOT RUN {
## generate data
X = aux.gensamples(n=496)

## 1. use centered data
output1 <- do.fa(X,ndim=2)

## 2. use decorrelated data
output2 <- do.fa(X,ndim=2,preprocess="decorrelate")

## 3. use whitened data
output3 <- do.fa(X,ndim=2,preprocess="whiten")

## Visualize three different projections
par(mfrow=c(1,3))
plot(output1$Y[,1],output1$Y[,2],main="centered")
plot(output2$Y[,1],output2$Y[,2],main="decorrelated")
plot(output3$Y[,1],output3$Y[,2],main="whitened")

# }

Run the code above in your browser using DataLab