Skip to contents

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".

References

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

Author

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

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
#> 
#> Call:
#> stats::factanal(factors = factors, covmat = covmat)
#> 
#> Uniquenesses:
#>    x1    x2    x3    x4    x5    x6    x7    x8    x9   x10 
#> 0.425 0.248 0.286 0.278 0.092 0.755 0.329 0.201 0.129 0.267 
#> 
#> Loadings:
#>     Factor1 Factor2
#> x1   0.756         
#> x2   0.834   0.236 
#> x3   0.672   0.513 
#> x4   0.656   0.540 
#> x5   0.110   0.947 
#> x6           0.484 
#> x7           0.819 
#> x8           0.893 
#> x9   0.933         
#> x10  0.853         
#> 
#>                Factor1 Factor2
#> SS loadings      3.773   3.216
#> Proportion Var   0.377   0.322
#> Cumulative Var   0.377   0.699
#> 
#> Test of the hypothesis that 2 factors are sufficient.
#> The chi square statistic is 2396.2 on 26 degrees of freedom.
#> The p-value is 0