Title: | Factor Analysis for Data |
---|---|
Description: | Compute maximum likelihood estimators of parameters in a Gaussian factor model using the the matrix-free methodology described in Dai et al. (2020) <doi:10.1080/10618600.2019.1704296>. In contrast to the factanal() function from 'stats' package, fad() can handle high-dimensional datasets where number of variables exceed the sample size and is also substantially faster than the EM algorithms. |
Authors: | Somak Dutta [aut, cre], Fan Dai [aut], Ranjan Maitra [ctb] |
Maintainer: | Somak Dutta <[email protected]> |
License: | GPL-3 |
Version: | 0.9-1 |
Built: | 2024-11-21 06:40:42 UTC |
Source: | CRAN |
Perform fast matrix-free maximum-likelihood factor analysis on a covariance matrix or data matrix, works if number of variables is more than number of observations.
fad( x, factors, data = NULL, covmat = NULL, n.obs = NA, subset, na.action, start = NULL, scores = c("none", "regression", "Bartlett"), rotation = "varimax", control = NULL, lower = 0.005, ... )
fad( x, factors, data = NULL, covmat = NULL, n.obs = NA, subset, na.action, start = NULL, scores = c("none", "regression", "Bartlett"), rotation = "varimax", control = NULL, lower = 0.005, ... )
x |
A formula or a numeric matrix or an object that can be coerced to a numeric matrix. |
factors |
The number of factors to be fitted. |
data |
An optional data frame (or similar: see |
covmat |
A covariance matrix, or a covariance list as returned by
|
n.obs |
The number of observations, used if |
subset |
A specification of the cases to be used, if |
na.action |
The |
start |
|
scores |
Type of scores to produce, if any. The default is none,
|
rotation |
character. |
control |
A list of control values:
|
lower |
The lower bound for uniquenesses during optimization. Should be > 0. Default 0.005. |
... |
Components of |
An object of class "fad"
with components
loadings |
A matrix of loadings on the correlation scale, one column for each factor. The
factors are ordered in decreasing order of sums of squares of
loadings, and given the sign that will make the sum of the loadings
positive. This is of class |
uniquenesses |
The uniquenesses computed on the correlation scale. |
sd |
The estimated standard deviations. |
criteria |
The results of the optimization: the value of the criterion (a linear function of the negative log-likelihood) and information on the iterations used. |
factors |
The argument |
dof |
The number of degrees of freedom of the factor analysis model. |
method |
The method: always |
rotmat |
The rotation matrix if relevant. |
scores |
If requested, a matrix of scores. |
n.obs |
The number of observations if available, or |
call |
The matched call. |
na.action |
If relevant. |
loglik , BIC
|
The maximum log-likelihood and the Bayesian Information Criteria. |
set.seed(1234) ## Simulate a 200 x 3 loadings matrix ~i.i.d N(0,1) L <- matrix(rnorm(200*3),200,3) ## Simulate the uniquenesses i.i.d U(0.2,0.9) D <- runif(200,0.2,0.9) ## Generate a data matrix of size 50 x 200 with rows ## ~i.i.d. N(0,LL'+diag(D)) X <- tcrossprod(matrix(rnorm(50*3),50,3),L) + matrix(rnorm(50*200),50,200) %*% diag(sqrt(D)) ## Fit a factor model with 3 factors: fit = fad(X,3) ## Print the loadings: print(fit$loadings)
set.seed(1234) ## Simulate a 200 x 3 loadings matrix ~i.i.d N(0,1) L <- matrix(rnorm(200*3),200,3) ## Simulate the uniquenesses i.i.d U(0.2,0.9) D <- runif(200,0.2,0.9) ## Generate a data matrix of size 50 x 200 with rows ## ~i.i.d. N(0,LL'+diag(D)) X <- tcrossprod(matrix(rnorm(50*3),50,3),L) + matrix(rnorm(50*200),50,200) %*% diag(sqrt(D)) ## Fit a factor model with 3 factors: fit = fad(X,3) ## Print the loadings: print(fit$loadings)
Perform fast matrix-free maximum-likelihood factor analysis on data on sphere, works if number of variables is more than number of observations.
fads( inputs, q, ii = 123, M = NULL, L = NULL, D = NULL, gamma = NA, maxiter = 10000, epsi = 1e-04 )
fads( inputs, q, ii = 123, M = NULL, L = NULL, D = NULL, gamma = NA, maxiter = 10000, epsi = 1e-04 )
inputs |
A numeric matrix or an object that can be coerced to a numeric matrix. |
q |
The number of factors to be fitted. |
ii |
The random seeds for initialization. Default 123 if no initial values of parameters are imported. |
M |
The initial values of mean. |
L |
The initial values of loading matrix. |
D |
The initial values of uniquenesses. |
gamma |
The common constant used in the eBIC formula. Default 'NA'. |
maxiter |
The maximum iterations. Default 10,000 |
epsi |
The absolute difference between final data log-likelihood values on consecutive step. Default 0.0001. |
An object of class "fads"
with components
mu |
The estimate mean. |
loadings |
A matrix of loadings on the correlation scale, one column for each factor. The
factors are ordered in decreasing order of sums of squares of
loadings, and given the sign that will make the sum of the loadings
positive.This is of class |
uniquenesses |
The uniquenesses computed on the correlation scale. |
sd |
The estimated standard deviations. |
iter |
The number of iterations |
gerr |
the difference between the gradients on consecutive step. |
loglik , eBIC
|
The maximum log-likelihood the extended Bayesian Information Criteria (Chen and Chen,2008). |
Prints the output of the fad
.
## S3 method for class 'fad' print(x, digits = 3, ...)
## S3 method for class 'fad' print(x, digits = 3, ...)
x |
an object of class |
digits |
number of decimal places to use in printing uniquenesses and loadings. |
... |
further arguments to |
None.
Prints the output of the fads
.
## S3 method for class 'fads' print(x, digits = 3, ...)
## S3 method for class 'fads' print(x, digits = 3, ...)
x |
an object of class |
digits |
number of decimal places to use in printing uniquenesses and loadings. |
... |
further arguments to |
None.