Description Usage Arguments Details Value References See Also Examples

View source: R/factor_functions.R

The main function for factor analysis with potentially high dimensional variables. Here we implement some recent algorithms that is optimized for the high dimensional problem where the number of samples n is less than the number of variables p.

1 | ```
factor.analysis(Y, r, method = c("ml", "pc", "esa"))
``` |

`Y` |
data matrix, a n*p matrix |

`r` |
number of factors |

`method` |
algorithm to be used |

The three methods are quasi-maximum likelihood (ml), principal component analysis (pc), and factor analysis using an early stopping criterion (esa).

The ml is iteratively solved the Expectation-Maximization algorithm using the PCA solution as the initial value. See Bai and Li (2012) and for more details. For the esa method, see Owen and Wang (2015) for more details.

a list of objects

- Gamma
estimated factor loadings

- Z
estimated latent factors

- Sigma
estimated noise variance matrix

Bai, J. and Li, K. (2012). Statistical analysis of factor models of high dimension. *The Annals of Statistics 40*, 436-465.
Owen, A. B. and Wang, J. (2015). Bi-cross-validation for factor analysis. *arXiv:1503.03515*.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ```
## a factor model
n <- 100
p <- 1000
r <- 5
Z <- matrix(rnorm(n * r), n, r)
Gamma <- matrix(rnorm(p * r), p, r)
Y <- Z %*% t(Gamma) + rnorm(n * p)
## to check the results, verify the true factors are in the linear span of the estimated factors.
pc.results <- factor.analysis(Y, r = 5, "pc")
sapply(summary(lm(Z ~ pc.results$Z)), function(x) x$r.squared)
ml.results <- factor.analysis(Y, r = 5, "ml")
sapply(summary(lm(Z ~ ml.results$Z)), function(x) x$r.squared)
esa.results <- factor.analysis(Y, r = 5, "esa")
sapply(summary(lm(Z ~ esa.results$Z)), function(x) x$r.squared)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.