| Title: | Estimate Number of Latent Factors and Factor Matrix for Factor Analysis |
|---|---|
| Description: | These functions estimate the latent factors of a given matrix, no matter it is high-dimensional or not. It tries to first estimate the number of factors using bi-cross-validation and then estimate the latent factor matrix and the noise variances. For more information about the method, see Art B. Owen and Jingshu Wang 2015 archived article on factor model (<doi:10.48550/arXiv.1503.03515>). Compatibility updates by Renova. |
| Authors: | Art B. Owen [aut], Jingshu Wang [aut, cre] |
| Maintainer: | Jingshu Wang <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 1.2.1.1.9001 |
| Built: | 2026-11-15 20:38:45 UTC |
| Source: | https://github.com/renova-r/esaBcv |
Estimate the latent factor matrix and noise variance using early stopping alternation (ESA) given the number of factors.
ESA(Y, r, X = NULL, center = F, niter = 3, svd.method = "fast")ESA(Y, r, X = NULL, center = F, niter = 3, svd.method = "fast")
Y |
observed data matrix. p is the number of variables and
n is the sample size. Dimension is |
r |
The number of factors to use |
X |
the known predictors of size |
center |
logical, whether to add an intercept term in the model. Default is False. |
niter |
the number of iterations for ESA. Default is 3. |
svd.method |
either "fast", "propack" or "standard".
"fast" is using the |
The model used is
where and are diagonal matrices, and
are orthogonal and
and mean _mu transposed_ and _V transposed_ respectively.
The entries of are assumed to be i.i.d. standard Gaussian.
The model assumes heteroscedastic noises and especially works well for
high-dimensional data. The method is based on Owen and Wang (2015). Notice that
when nonnull X is given or centering the data is required (which is essentially
adding a known covariate with all ), for identifiability, it's required that
or respectively. Then the method will first make a rotation
of the data matrix to remove the known predictors or centers, and then use
the latter n - k (or n - k - 1 if centering is required) samples to
estimate the latent factors.
The returned value is a list with components
estSigma |
the diagonal entries of estimated |
estU |
the estimated |
estD |
the estimated diagonal entries of |
estV |
the estimated |
beta |
the estimated |
estS |
the estimated signal (factor) matrix
|
mu |
the sample centers of each variable which is a vector of length
|
Art B. Owen and Jingshu Wang(2015), Bi-cross-validation for factor analysis, http://arxiv.org/abs/1503.03515
Y <- matrix(rnorm(100), nrow = 10) + 3 * rnorm(10) %*% t(rep(1, 10)) ESA(Y, 1)Y <- matrix(rnorm(100), nrow = 10) + 3 * rnorm(10) %*% t(rep(1, 10)) ESA(Y, 1)
Find out the best number of factors using Bi-Cross-Validation (BCV) with Early-Stopping-Alternation (ESA) and then estimate the factor matrix.
EsaBcv(Y, X = NULL, r.limit = 20, niter = 3, nRepeat = 12, only.r = F, svd.method = "fast", center = F)EsaBcv(Y, X = NULL, r.limit = 20, niter = 3, nRepeat = 12, only.r = F, svd.method = "fast", center = F)
Y |
observed data matrix. p is the number of variables and
n is the sample size. Dimension is |
X |
the known predictors of size |
r.limit |
the maximum number of factor to try. Default is 20. Can be set to Inf. |
niter |
the number of iterations for ESA. Default is 3. |
nRepeat |
number of repeats of BCV. In other words, the random partition of |
only.r |
whether only to estimate and return the number of factors. |
svd.method |
either "fast", "propack" or "standard".
"fast" is using the |
center |
logical, whether to add an intercept term in the model. Default is False. |
The model is
where and are diagonal matrices, and
are orthogonal and
and represent _mu transposed_ and _V transposed_ respectively.
The entries of are assumed to be i.i.d. standard Gaussian.
The model assumes heteroscedastic noises and especially works well for
high-dimensional data. The method is based on Owen and Wang (2015). Notice that
when nonnull X is given or centering the data is required (which is essentially
adding a known covariate with all ), for identifiability, it's required that
or respectively. Then the method will first make a rotation
of the data matrix to remove the known predictors or centers, and then use
the latter n - k (or n - k - 1 if centering is required) samples to
estimate the latent factors. The rotation idea first appears in Sun et.al. (2012).
EsaBcv returns an obejct of class "esabcv"
The function plot plots the cross-validation results and points out the
number of factors estimated
An object of class "esabcv" is a list containing the following components:
best.r |
the best number of factor estimated |
estSigma |
the diagonal entries of estimated |
estU |
the estimated |
estD |
the estimated diagonal entries of |
estV |
the estimated |
beta |
the estimated |
estS |
the estimated signal(factor) matrix
|
mu |
the sample centers of each variable which is a vector of length
|
max.r |
the actual maximum number of factors used. For the details of how this is decided, please refer to Owen and Wang (2015) |
result.list |
a matrix with dimension |
Art B. Owen and Jingshu Wang(2015), Bi-cross-validation for factor analysis, http://arxiv.org/abs/1503.03515
Yunting Sun, Nancy R. Zhang and Art B. Owen, Multiple hypothesis testing adjusted for latent variables, with an application to the AGEMAP gene expression data. The Annuals of Applied Statistics, 6(4): 1664-1688, 2012
Y <- matrix(rnorm(100), nrow = 10) EsaBcv(Y)Y <- matrix(rnorm(100), nrow = 10) EsaBcv(Y)
The esaBcv package provides functions to estimate the latent factors of a given matrix, no matter it is high-dimensional or not. It tries to first estimate the number of factors using Bi-cross-validation and then estimate the latent factor matrix and the noise variances using an Early-stopping-alternation method. The method is proposed by Art B. Owen and Jingshu Wang (2015).
Maintainer: Jingshu Wang <[email protected]>
Owen and Wang (2015) Bi-cross-validation for factor analysis, http://arxiv.org/abs/1503.03515
## Not run: data(simdat) result <- EsaBcv(simdat$Y) plot(result) ## End(Not run)## Not run: data(simdat) result <- EsaBcv(simdat$Y) plot(result) ## End(Not run)
Plot the average BCV entrywise MSE against the number of factors tried, with error bars and the best number of factors picked.
## S3 method for class 'esabcv' plot(x, start.r = 0, end.r = NA, xlab = "Number of Factors", ylab = "BCV MSE", main = "Bi-cross-validation Error", col.line = "BLUE", ...)## S3 method for class 'esabcv' plot(x, start.r = 0, end.r = NA, xlab = "Number of Factors", ylab = "BCV MSE", main = "Bi-cross-validation Error", col.line = "BLUE", ...)
x |
|
start.r |
the starting number of factors to display in the plot. |
end.r |
the largest number of factors allowed to display in the plot.
Default is NA, which means to make |
xlab |
title for the x axis. |
ylab |
title for the y axis. |
main |
title for the plot. |
col.line |
the line color. |
... |
other parameters to be passed through to plotting functions. |
The esabcv object contains the raw BCV result result.list,
which is a matrix with dimension c(nRepeat, (max.r + 1)) where nRepeat
is the number of BCV repeats and max.r is the maximum number of factors tried.
If either tail of the error curve dominates, then the user has the option to change the start
and end rank for plotting.
A plot ploting the average BCV entrywise MSE against the number of
factors tried (start.r to max.r + 1), with error bars (one standard deviation)
in grey and selected number of factors marked by a red crossing.
## Not run: data(simdat) result <- EsaBcv(simdat$Y) plot(result) plot(result, start.r = 1) ## End(Not run)## Not run: data(simdat) result <- EsaBcv(simdat$Y) plot(result) plot(result, start.r = 1) ## End(Not run)
The data is a simulated data set where the data matrix is generated from the latent factor model
where and are diagonal matrices, and and
are orthogonal. means _V transposed_. For the factors, we include one giant
factor, five useful factors, one harmful factor and one undetectable factor.
For more details of the simulation method
used, please refer to Appendix A.1 of Owen and Wang (2015) Bi-cross-validation for factor analysis, http://arxiv.org/abs/1503.03515.
The dataset is a list of components:
Y a data matrix of 200 by 1000, where each row is a sample and each column
is a variable
U the orthogonal factor matrix of size 200 by 8.
V the orthogonal factor matrix of size 1000 by 8.
D the vector of diagonal entries of .
Sigma the vector of diagonal entries of .
oracle.r the oracle rank (the optimal number of factors that should be kept)
of the factor matrix.