| Type: | Package |
| Title: | Penalized Likelihood Factor Analysis via Nonconvex Penalty |
| Version: | 2.4.0 |
| Date: | 2026-07-26 |
| Depends: | Matrix |
| Imports: | grDevices, graphics, stats, utils |
| Description: | Computes the penalized maximum likelihood estimates of factor loadings and unique variances for various tuning parameters. The pathwise coordinate descent along with EM algorithm is used. This package also includes a graphical tool which outputs path diagrams, heatmaps, goodness-of-fit indices and model selection criteria for each regularization parameter (Yamamoto, M., Hirose, K. and Nagata, H., 2017 <doi:10.1007/s41237-016-0007-3>). The user can change the regularization parameter interactively with a built-in self-contained HTML viewer (no additional packages required), which is helpful to find a suitable value of regularization parameter. As a penalty, we can choose either the minimax concave penalty (Hirose, K. and Yamamoto, M., 2015 <doi:10.1007/s11222-014-9458-0>; Hirose, K. and Yamamoto, M., 2014 <doi:10.1016/j.csda.2014.05.011>) or the product-based elastic net penalty (Hirose, K. and Terada, Y., 2023 <doi:10.1007/s11336-022-09868-4>). |
| License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
| URL: | https://doi.org/10.1007/s11222-014-9458-0, https://doi.org/10.1016/j.csda.2014.05.011, https://doi.org/10.1007/s41237-016-0007-3, https://doi.org/10.1007/s11336-022-09868-4, https://keihirose.com |
| NeedsCompilation: | yes |
| Packaged: | 2026-07-26 06:40:46 UTC; hirosekei |
| Author: | Kei Hirose |
| Maintainer: | Kei Hirose <mail@keihirose.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-07-26 07:10:02 UTC |
Penalized Likelihood Factor Analysis via Nonconvex Penalties
Description
Computes solution paths of penalized maximum likelihood estimates for factor analysis or probabilistic principal component analysis. The available penalties are MC+, the product-based elastic net (prenet), and the elastic net.
Usage
fanc(x, factors, n.obs, rho, gamma, cor.factor=FALSE, normalize=TRUE,
normalize.penalty=FALSE, covmat, type="MC", model="FA", control=list())
## S3 method for class 'fanc'
print(x, digits=max(3, getOption("digits") - 3),
num.result=20, ...)
Arguments
x |
A numeric data matrix. |
factors |
The number of factors. |
n.obs |
The number of observations. This is required to calculate model-selection
criteria and goodness-of-fit indices when only |
rho |
Values of rho. This may be a scalar or a matrix with one column for each gamma value. |
gamma |
Values of gamma. |
cor.factor |
Logical; if |
normalize |
Logical; if |
normalize.penalty |
Logical; if |
covmat |
A covariance matrix, used when the data matrix |
type |
Penalty type: |
model |
Model type: |
control |
A list of control parameters. See ‘Details’. |
digits |
Number of digits used by the print method. |
num.result |
Retained for compatibility with earlier versions; it currently does not change the printed output. |
... |
Reserved for compatibility; currently unused. |
Details
The control argument can contain the following components:
length.rhoNumber of rho candidates.
length.gammaNumber of gamma candidates.
max.rho-
Maximum rho. For prenet and enet, a scalar is repeated for every gamma. Alternatively, supply one value per gamma. Other lengths are invalid.
max.gammaMaximum finite gamma.
min.gammaMinimum gamma.
eta-
Non-negative tuning parameter used to prevent improper solutions.
ncand.initial-
Number of candidate initial loading matrices. The default is 10.
ncand.initial.prenet-
Number of candidate initial values for the prenet penalty. The default is 100.
maxit.emMaximum number of EM iterations.
maxit.cdMaximum number of coordinate-descent iterations.
maxit.bfgsMaximum number of BFGS iterations.
maxit.initial-
Maximum number of iterations used when choosing initial values.
start-
Starting-value strategy, either
"warm"or"cold". Delta-
Ratio of the minimum rho to the maximum rho.
min.uniquevarMinimum unique variance.
tol.emConvergence tolerance for the EM algorithm.
tol.cdConvergence tolerance for coordinate descent.
tol.bfgsConvergence tolerance for BFGS.
min.rhozero-
Logical; if
TRUE, the minimum rho is zero. zitaHyper-parameter for factor correlations.
progress-
Logical; if
TRUE, fitting progress is displayed. openmp-
Logical; if
TRUE, OpenMP parallel computation is requested. num.threadsNumber of OpenMP threads.
gamma.ebicGamma used in the extended BIC.
Value
An object of class "fanc". Important components include:
loadings |
Factor-loading matrices for every rho and gamma. |
uniquenesses |
Unique variances for every rho and gamma. |
Phi |
Factor-correlation matrices. |
rho |
Matrix of rho values. |
gamma |
Vector of gamma values. |
df, dfnonzero |
Degrees of freedom. |
AIC, BIC, CAIC, EBIC |
Model-selection criteria based on reparametrized degrees of freedom. |
AIC_dfnonzero, BIC_dfnonzero, CAIC_dfnonzero, EBIC_dfnonzero |
Model-selection criteria based on active parameters. |
GFI, AGFI, CFI, RMSEA, SRMR |
Goodness-of-fit indices. |
AGFI_dfnonzero, CFI_dfnonzero, RMSEA_dfnonzero |
Goodness-of-fit indices based on active parameters. |
factors |
Number of factors. |
cor.factor |
Whether factor correlations were estimated. |
x |
The original data matrix, or |
convergence |
Convergence indicators for the fitting algorithms. |
type, model |
Penalty and model types. |
When only covmat is supplied and n.obs is omitted, the
model-selection criteria and goodness-of-fit indices are NULL.
Author(s)
Kei Hirose
mail@keihirose.com
References
Hirose, K. and Yamamoto, M. (2015). Sparse estimation via nonconcave penalized likelihood in a factor analysis model, Statistics and Computing, 25, 633–648.
See Also
out, select, and plot.fanc.
Examples
set.seed(0)
loadings0 <- matrix(c(rep(0.8, 5), rep(0, 5),
rep(0, 5), rep(0.8, 5)), 10, 2)
common.factors0 <- matrix(rnorm(50 * 2), 50, 2)
unique.factors0 <- matrix(rnorm(50 * 10, sd=sqrt(0.36)), 50, 10)
x <- common.factors0 %*% t(loadings0) + unique.factors0
fit <- fanc(x, 2)
print(fit)
out(fit, rho=0.1, gamma=Inf)
select(fit, criterion="BIC", gamma=Inf)
## Not run:
plot(fit)
plot(fit, file="fanc-viewer.html")
## End(Not run)
Extract a Result from a "fanc" Object
Description
Extracts the fitted model at specified values of rho and gamma
from a "fanc" object.
Usage
out(x, rho, gamma, scores=FALSE, df.method="active")
Arguments
x |
Fitted |
gamma |
The value of gamma. |
rho |
The value of rho. |
scores |
Logical flag for outputting factor scores. The original data matrix must have
been supplied to |
df.method |
Two types of degrees of freedom are supported. If
|
Value
loadings |
factor loadings |
uniquenesses |
unique variances |
Phi |
Factor-correlation matrix, when factor correlations were estimated. |
scores |
Factor scores, when |
df |
Degrees of freedom under the selected |
criteria |
Values of AIC, BIC, CAIC and EBIC, when available. |
goodness.of.fit |
Values of GFI, AGFI, CFI, RMSEA and SRMR, when available. |
rho |
The selected value of rho. |
gamma |
The selected value of gamma. |
Author(s)
Kei Hirose
mail@keihirose.com
References
Hirose, K. and Yamamoto, M. (2015).
Sparse estimation via nonconcave penalized likelihood in a factor analysis model,
Statistics and Computing, 25, 633–648.
See Also
fanc and plot.fanc objects.
Plot a Solution Path from a "fanc" Object
Description
This function plots the solution paths or heatmaps from a "fanc" object.
By default it opens a self-contained, interactive HTML viewer in the browser or
RStudio viewer pane (no additional packages required). The viewer has sliders
for rho and gamma, buttons that jump to the model selected by AIC,
BIC, CAIC or EBIC, and an overview mode showing every rho along the path
at once. All data and code are embedded in the page, so it runs without a
server and can be saved and shared as a single file via the file
argument.
Usage
## S3 method for class 'fanc'
plot(x, Window.Height=500, type=NULL, df.method="active",
viewer=c("auto", "html", "base"), file=NULL,
rho.index=1, gamma.index=1, ...)
Arguments
x |
Fitted |
Window.Height |
Maximum plot height in pixels for the HTML viewer. It does not change the internal layout of base R plots. It must be between 250 and 2000. The default is 500. |
type |
Two plot types are supported. If |
df.method |
Two types of degrees of freedom are supported. If
|
viewer |
Viewer backend. |
file |
Optional path for the generated HTML file. When |
rho.index |
Initial index of the |
gamma.index |
Initial index of the |
... |
Reserved for compatibility; currently unused. |
Value
For viewer="html" the path to the generated HTML file (invisibly);
otherwise NULL (invisibly). Called for the side effect of drawing or
opening the viewer.
Author(s)
Kei Hirose
mail@keihirose.com
References
Hirose, K. and Yamamoto, M. (2015).
Sparse estimation via nonconcave penalized likelihood in a factor analysis model,
Statistics and Computing, 25, 633–648.
See Also
fanc and out objects.
Select a Model from a "fanc" Object
Description
Selects the value of rho that minimizes a model-selection criterion,
optionally at a specified value of gamma.
Usage
select(x, criterion=c("BIC","AIC","CAIC","EBIC"),
gamma, scores=FALSE, df.method="active")
Arguments
x |
Fitted |
criterion |
The criterion by which to select the tuning parameter rho. One of "AIC", "BIC", "CAIC", or "EBIC". Default is "BIC". |
gamma |
The value of gamma. |
scores |
Logical flag for outputting factor scores. The original data matrix must have
been supplied to |
df.method |
Two types of degrees of freedom are supported. If |
Value
loadings |
factor loadings |
uniquenesses |
unique variances |
Phi |
Factor-correlation matrix, when factor correlations were estimated. |
scores |
Factor scores, when |
df |
Degrees of freedom under the selected |
AIC, BIC, CAIC, EBIC |
The value of the selected criterion. |
goodness.of.fit |
Values of GFI, AGFI, CFI, RMSEA and SRMR, when available. |
rho |
The selected value of rho. |
gamma |
The selected value of gamma. |
Author(s)
Kei Hirose
mail@keihirose.com
References
Hirose, K. and Yamamoto, M. (2015).
Sparse estimation via nonconcave penalized likelihood in a factor analysis model,
Statistics and Computing, 25, 633–648.
See Also
fanc and plot.fanc objects.