computeScores: Compute Factor Scores

View source: R/utils.R

computeScoresR Documentation

Compute Factor Scores

Description

Compute factor scores on the result of factor analysis method, the method is one of "mle", "pca", and "pfa".

Usage

computeScores(out, x = data, covmat = covmat, cor = cor, scoresMethod = scoresMethod)

Arguments

out

The result of factorScorePca(), factorScorePfa(), or factanal(). It is a list.

x

A numeric matrix.

covmat

A list with components: cov, center, and n.obs.

cor

A logical value indicating whether the calculation should use the covariance matrix (cor = FALSE) or the correlation matrix (cor = TRUE).

scoresMethod

Type of scores to produce, if any. The default is "none", "regression" gives Thompson's scores, "Bartlett" gives Bartlett's weighted least-squares scores.

Value

The output is a list. Except for the components of out, it also has components:

scoringCoef

The scoring coefficients.

scores

The matrix of scores.

meanF

The sample mean of the scores.

corF

The sample correlation matrix of the scores.

eigenvalues

The eigenvalues of the running matrix.

covariance

The covariance matrix.

correlation

The correlation matrix.

usedMatrix

The used matrix (running matrix) to compute scoringCoef etc..

reducedCorrelation

NULL. The reduced correlation matrix, reducedCorrelation is calculated in factorScorePfa.R.

scoringCoef = F = meanF = corF = NULL if scoresMethod = "none".

Author(s)

Ying-Ying Zhang (Robert) robertzhangyying@qq.com

References

Zhang, Y. Y. (2013), An Object Oriented Solution for Robust Factor Analysis.

Examples

data("stock611")
stock604 = stock611[-c(92,2,337,338,379,539,79), ]
data = as.matrix(stock604[, 3:12])

factors = 2
cor = TRUE
scoresMethod = "regression" 

covx = rrcov::Cov(data)
covmat = list(cov = rrcov::getCov(covx), center = rrcov::getCenter(covx), n.obs = covx@n.obs)

out = stats::factanal(factors = factors, covmat = covmat)

out = computeScores(out, x = data, covmat = covmat, cor = cor, scoresMethod = scoresMethod)
out


robustfa documentation built on April 16, 2023, 5:18 p.m.