Learn R Programming

Rdimtools (version 1.0.6)

do.fa: Exploratory Factor Analysis

Description

do.fa is an optimization-based implementation of a popular technique for Exploratory Data Analysis. It is closely related to principal component analysis.

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 {
## use iris data
data(iris)
set.seed(100)
subid = sample(1:150,50)
X     = as.matrix(iris[subid,1:4])
lab   = as.factor(iris[subid,5])

## try different preprocessing procedure
out1 <- do.fa(X,ndim=2)
out2 <- do.fa(X,ndim=2,preprocess="decorrelate")
out3 <- do.fa(X,ndim=2,preprocess="whiten")

## extract embeddings for each procedure
Y1 <- out1$Y; Y2 <- out2$Y; Y3 <- out3$Y

## visualize three different projections
opar <- par(no.readonly=TRUE)
par(mfrow=c(1,3))
plot(Y1, pch=19, col=lab, main="FA::centered")
plot(Y2, pch=19, col=lab, main="FA::decorrelated")
plot(Y3, pch=19, col=lab, main="FA::whitened")
par(opar)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab