factor.analysis: Factor Analysis by Principal Axis Factoring

View source: R/factor.analysis.R

factor.analysisR Documentation

Factor Analysis by Principal Axis Factoring

Description

This function performs factor analysis using the Principal Axis Factoring (PAF) method. The process involves extracting factors from an initial correlation matrix and iteratively refining the factor estimates until convergence is achieved.

Usage

factor.analysis(
  data,
  nfact = 1,
  iter.max = 1000,
  criterion = 0.001,
  cor.type = "pearson",
  use = "pairwise.complete.obs"
)

Arguments

data

A data.frame or matrix of response If the matrix is square, it is assumed to be a correlation matrix. Otherwise, correlations (with pairwise deletion) will be computed.

nfact

The number of factors to extract. (default = 1)

iter.max

The maximum number of iterations for the factor extraction process. Default is 1000.

criterion

The convergence criterion for the iterative process. The extraction process will stop when the change in communalities is less than this value. Default is 0.001

cor.type

A character string indicating which correlation coefficient (or covariance) is to be computed. One of "pearson" (default), "kendall", or "spearman". @seealso cor.

use

An optional character string giving a method for computing covariances in the presence of missing values. This must be one of the strings "everything", "all.obs", "complete.obs", "na.or.complete", or "pairwise.complete.obs" (default). @seealso cor.

Details

The Principal Axis Factoring (PAF) method involves the following steps:

Step 1. **Basic Principle**: The core principle of factor analysis using Principal Axis Factoring (PAF) is expressed as:

\mathbf{R} = \mathbf{\Lambda} \mathbf{\Lambda}^T + \mathbf{\Phi}

R_{ii} = H_i^2 + \Phi_{ii}

where \mathbf{\Lambda} is the matrix of factor loadings, and \mathbf{\Phi} is the diagonal matrix of unique variances. Here, H_i^2 represents the portion of the i-th item's variance explained by the factor model. \mathbf{H}^2 reflects the amount of total variance in the variable accounted for by the factors in the model, indicating the explanatory power of the factor model for that variable.

Step 2. **Factor Extraction by Iteratoin**:

- Initial Communalities: Compute the initial communalities as the squared multiple correlations:

H_{i(t)}^2 = R_{ii(t)}

where H_{i(t)}^2 is the communality of i-th item in the t-th iteration, and R_{ii(t)} is the i-th diagonal element of the correlation matrix in the t-th iteration.

- Extract Factors and Update Communalities:

\Lambda_{ij} = \sqrt{\lambda_j} \times v_{ij}

H_{i(t+1)}^2 = \sum_j \Lambda_{ij}^2

R_{ii(t+1)} = H_{i(t+1)}^2

where \Lambda_{ij} represents the j-th factor loading for the i-th item, \lambda_j is the j-th eigenvalue, H_{i(t+1)}^2 is the communality of i-th item in the t+1-th iteration, and v_{ij} is the j-th value of the i-th item in the eigen vector matrix \mathbf{v}.

Step 3. **Iterative Refinement**:

- Calculate the Change between \mathbf{H}_{t}^2 and \mathbf{H}_{t+1}^2:

\Delta H_i^2 = \lvert H_{i(t+1)}^2 - H_{i(t)}^2 \lvert

where \Delta H_i^2 represents the change in communalities between iterations t and t+1.

- Convergence Criterion: Continue iterating until the change in communalities is less than the specified criterion criterion:

\sum_i \Delta H_i^2 < criterion

The iterative process is implemented using C++ code to ensure computational speed.

Value

A list containing:

loadings

The extracted factor loadings.

eigen.value

The eigenvalues of the correlation matrix.

H2

A vector that contains the explanatory power of the factor model for all items.

Author(s)

Haijiang Qin <Haijiang133@outlook.com>

Examples

library(EFAfactors)
set.seed(123)

##Take the data.bfi dataset as an example.
data(data.bfi)

response <- as.matrix(data.bfi[, 1:25]) ## loading data
response <- na.omit(response) ## Remove samples with NA/missing values

## Transform the scores of reverse-scored items to normal scoring
response[, c(1, 9, 10, 11, 12, 22, 25)] <- 6 - response[, c(1, 9, 10, 11, 12, 22, 25)] + 1


## Run factor.analysis function to extract 5 factors

 PAF.obj <- factor.analysis(response, nfact = 5)


 ## Get the loadings, eigen.value and  H2 results.
 loadings <- PAF.obj$loadings
 eigen.value <- PAF.obj$eigen.value
 H2 <- PAF.obj$H2

 print(loadings)
 print(eigen.value)
 print(H2)






EFAfactors documentation built on Sept. 30, 2024, 1:06 a.m.