| Title: | Group Factor Analysis |
|---|---|
| Description: | Implements statistical methods for group factor analysis, focusing on estimating the number of global and local factors and extracting them. Several algorithms are implemented, including Canonical Correlation-based Estimation by Choi et al. (2021) <doi:10.1016/j.jeconom.2021.09.008>, Generalised Canonical Correlation Estimation by Lin and Shin (2023) <doi:10.2139/ssrn.4295429>, Circularly Projected Estimation by Chen (2022) <doi:10.1080/07350015.2022.2051520>, and the Aggregated Projection Method by Hu et al. (2025) <doi:10.1080/01621459.2025.2491154>. |
| Authors: | Jiaqi Hu [cre, aut], Ting Li [aut], Xueqin Wang [aut] |
| Maintainer: | Jiaqi Hu <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.2.2 |
| Built: | 2026-06-05 09:51:44 UTC |
| Source: | https://github.com/cran/GrFA |
Aggregated Projection Method for Group Factor Model.
APM( y, rmax = 8, r0 = NULL, r = NULL, localfactor = FALSE, weight = TRUE, method = "ic", type = "IC3" )APM( y, rmax = 8, r0 = NULL, r = NULL, localfactor = FALSE, weight = TRUE, method = "ic", type = "IC3" )
y |
A list of the observation data, each element is a data matrix of each group with dimension |
rmax |
The maximum factor numbers of all groups. Default is 8. |
r0 |
The number of global factors. Default is |
r |
The number of local factors in each group. Default is |
localfactor |
Logical. If |
weight |
The weight of each projection matrix.
If |
method |
The method used in the algorithm. Default is |
type |
The method used in estimating the factor numbers in each group initially. Default is |
An object of class "GFA" containing:
r0hat |
The estimated number of global factors. |
rhat |
The estimated number of local factors (if |
rho |
The first |
Ghat |
The estimated global factors. |
loading_G |
A list consisting of the estimated global factor loadings. |
Fhat |
The estimated local factors (if |
loading_F |
A list consisting of the estimated local factor loadings (if |
residual |
A list consisting of the residuals (if |
threshold |
The threshold used in determining the number of global factors (only for |
Aggregated Projection Method: A New Approach for Group Factor Model. Jiaqi Hu, Ting Li, Xueqin Wang (2025). Journal of the American Statistical Association, doi:10.1080/01621459.2025.2491154
## Not run: dat <- GrFA::gendata() APM(dat$y, rmax = 8, localfactor = TRUE, method = "ic") APM(dat$y, rmax = 8, localfactor = TRUE, method = "gap") ## End(Not run)## Not run: dat <- GrFA::gendata() APM(dat$y, rmax = 8, localfactor = TRUE, method = "ic") APM(dat$y, rmax = 8, localfactor = TRUE, method = "gap") ## End(Not run)
Canonical Correlation Estimation for Group Factor Model.
CCA( y, rmax = 8, r0 = NULL, r = NULL, localfactor = FALSE, method = "CCD", type = "IC3" )CCA( y, rmax = 8, r0 = NULL, r = NULL, localfactor = FALSE, method = "CCD", type = "IC3" )
y |
A list of the observation data, each element is a data matrix of each group with dimension |
rmax |
The maximum factor numbers of all groups. Default is 8. |
r0 |
The number of global factors. Default is |
r |
The number of local factors in each group. Default is |
localfactor |
Logical. If |
method |
The method used in the algorithm. Default is |
type |
The method used in estimating the factor numbers in each group initially. Default is |
An object of class "GFA" containing:
r0hat |
The estimated number of global factors. |
rhat |
The estimated number of local factors (if |
rho |
The vector of average canonical correlations (eigenvalues). |
Ghat |
The estimated global factors. |
Fhat |
The estimated local factors (if |
loading_G |
A list consisting of the estimated global factor loadings. |
loading_F |
A list consisting of the estimated local factor loadings (if |
residual |
A list consisting of the residuals (if |
threshold |
The threshold used in determining the number of global factors (only for |
Choi, I., Lin, R., & Shin, Y. (2021). Canonical correlation-based model selection for the multilevel factors. Journal of Econometrics.
dat <- GrFA::gendata() CCA(dat$y, rmax = 8, localfactor = TRUE, method = "CCD") CCA(dat$y, rmax = 8, localfactor = TRUE, method = "MCC")dat <- GrFA::gendata() CCA(dat$y, rmax = 8, localfactor = TRUE, method = "CCD") CCA(dat$y, rmax = 8, localfactor = TRUE, method = "MCC")
Circularly Projected Estimation for Group Factor Model.
CP(y, rmax = 8, r0 = NULL, r = NULL, localfactor = FALSE, type = "IC3")CP(y, rmax = 8, r0 = NULL, r = NULL, localfactor = FALSE, type = "IC3")
y |
A list of the observation data, each element is a data matrix of each group with dimension |
rmax |
The maximum factor numbers of all groups. Default is 8. |
r0 |
The number of global factors. Default is |
r |
The number of local factors in each group. Default is |
localfactor |
Logical. If |
type |
The method used in estimating the local factor numbers in each group after projecting out the global factors. Default is |
An object of class "GFA" containing:
r0hat |
The estimated number of global factors. |
rhat |
The estimated number of local factors (if |
rho |
The eigenvalues of the circular projection matrix. |
Ghat |
The estimated global factors. |
Fhat |
The estimated local factors (if |
loading_G |
A list consisting of the estimated global factor loadings. |
loading_F |
A list consisting of the estimated local factor loadings (if |
residual |
A list consisting of the residuals (if |
Chen, M. (2023). Circularly Projected Common Factors for Grouped Data. Journal of Business & Economic Statistics, 41(2), 636-649.
dat <- GrFA::gendata() CP(dat$y, rmax = 8, localfactor = TRUE)dat <- GrFA::gendata() CP(dat$y, rmax = 8, localfactor = TRUE)
Estimates the number of factors using various Information Criteria (IC) and Eigenvalue Ratio tests.
est_num(X, kmax = 8, type = "BIC3")est_num(X, kmax = 8, type = "BIC3")
X |
The observation data matrix of dimension |
kmax |
The maximum number of factors to consider. Default is 8. |
type |
The criterion used in determining the number of factors. Default is |
rhat |
The estimated number of factors (an integer). |
Bai, J., & Ng, S. (2002). Determining the number of factors in approximate factor models. Econometrica, 70(1), 191-221.
Ahn, S. C., & Horenstein, A. R. (2013). Eigenvalue ratio test for the number of factors. Econometrica, 81(3), 1203-1227.
## Not run: X <- matrix(rnorm(100*20), 100, 20) est_num(X, kmax = 8, type = "BIC3") est_num(X, kmax = 8, type = "ER") ## End(Not run)## Not run: X <- matrix(rnorm(100*20), 100, 20) est_num(X, kmax = 8, type = "BIC3") est_num(X, kmax = 8, type = "ER") ## End(Not run)
Performs Factor Analysis using Principal Component Analysis (PCA) to extract factors and loadings.
FA(X, r)FA(X, r)
X |
The observation data matrix of dimension |
r |
The number of factors to estimate. |
A list containing:
F |
The estimated factors matrix of dimension |
L |
The estimated factor loadings matrix of dimension |
Jiaqi Hu
Bai, J., & Ng, S. (2002). Determining the number of factors in approximate factor models. Econometrica, 70(1), 191-221.
X <- matrix(rnorm(100*20), 100, 20) res <- FA(X, r = 2) head(res$F) head(res$L)X <- matrix(rnorm(100*20), 100, 20) res <- FA(X, r = 2) head(res$F) head(res$L)
Generalised Canonical Correlation Estimation for Group Factor Model.
GCC(y, rmax = 8, r0 = NULL, r = NULL, localfactor = FALSE, type = "IC3")GCC(y, rmax = 8, r0 = NULL, r = NULL, localfactor = FALSE, type = "IC3")
y |
A list of the observation data, each element is a data matrix of each group with dimension |
rmax |
The maximum factor numbers of all groups. Default is 8. |
r0 |
The number of global factors. Default is |
r |
The number of local factors in each group. Default is |
localfactor |
Logical. If |
type |
The method used in estimating the factor numbers in each group initially. Default is |
An object of class "GFA" containing:
r0hat |
The estimated number of global factors. |
rhat |
The estimated number of local factors (if |
rho |
The ratio of the singular values used to estimate the number of global factors. |
Ghat |
The estimated global factors. |
Fhat |
The estimated local factors (if |
loading_G |
A list consisting of the estimated global factor loadings. |
loading_F |
A list consisting of the estimated local factor loadings (if |
residual |
A list consisting of the residuals (if |
Lin, R., & Shin, Y. (2023). Generalised Canonical Correlation Estimation of the Multilevel Factor Model. Available at SSRN 4295429.
dat <- GrFA::gendata() GCC(dat$y, rmax = 8, localfactor = TRUE)dat <- GrFA::gendata() GCC(dat$y, rmax = 8, localfactor = TRUE)
Generate the grouped data for simulation studies.
gendata( seed = 1, T = 50, N = rep(30, 5), r0 = 2, r = rep(2, 5), Phi_G = 0.5, Phi_F = 0.5, Phi_e = 0.5, W_F = 0.5, beta = 0.2, kappa = 1, case = 1 )gendata( seed = 1, T = 50, N = rep(30, 5), r0 = 2, r = rep(2, 5), Phi_G = 0.5, Phi_F = 0.5, Phi_e = 0.5, W_F = 0.5, beta = 0.2, kappa = 1, case = 1 )
seed |
The seed used in |
T |
The number of time points. Default is 50. |
N |
A vector representing the number of variables in each group. Default is |
r0 |
The number of global factors. Default is 2. |
r |
A vector representing the number of the local factors. Notice, the length of |
Phi_G |
Hyperparameter of the global factors (AR(1) coefficient). Default is 0.5. The value should be between 0 and 1. |
Phi_F |
Hyperparameter of the local factors (AR(1) coefficient). Default is 0.5. The value should be between 0 and 1. |
Phi_e |
Hyperparameter of the errors. Default is 0.5. The value should be between 0 and 1. |
W_F |
Hyperparameter of the correlation of local factors. Only applicable when |
beta |
Hyperparameter of the errors (spatial correlation). Default is 0.2. |
kappa |
Hyperparameter of signal to noise ratio. Default is 1. |
case |
The case of the data-generating process. Default is 1. It can also be 2 or 3. |
An object of class "GFD" containing:
y |
A list of the generated data matrices. |
G |
The global factors matrix. |
F |
A list of the local factors. |
loading_G |
A list of the global factor loadings. |
loading_F |
A list of the local factor loadings. |
T |
The number of time points. |
N |
The vector of variables per group. |
M |
The number of groups. |
r0 |
The number of global factors. |
r |
The vector of local factors. |
case |
The generation case used. |
Aggregated Projection Method: A New Approach for Group Factor Model. Jiaqi Hu, Ting Li, Xueqin Wang (2025). Journal of the American Statistical Association, doi:10.1080/01621459.2025.2491154
dat <- gendata() print(dat)dat <- gendata() print(dat)
Print the summarized results of the estimated group factor model, such as the estimated global and local factor numbers and reference statistics.
## S3 method for class 'GFA' print(x, ...)## S3 method for class 'GFA' print(x, ...)
x |
The |
... |
Additional arguments passed to methods. |
No return value, called for side effects.
Print the summary of the generated grouped data.
## S3 method for class 'GFD' print(x, ...)## S3 method for class 'GFD' print(x, ...)
x |
The |
... |
Additional arguments passed to methods. |
No return value, called for side effects.
Evaluation of the estimated factors by trace ratios. The value is between 0 and 1; higher values indicate better estimation accuracy.
TraceRatio(G, Ghat)TraceRatio(G, Ghat)
G |
The true factors matrix. |
Ghat |
The estimated factors matrix. |
A numeric value representing the trace ratio, defined as:
.
G <- matrix(rnorm(100 * 2), 100, 2) Ghat <- G + matrix(rnorm(100 * 2, sd = 0.1), 100, 2) TraceRatio(G, Ghat)G <- matrix(rnorm(100 * 2), 100, 2) Ghat <- G + matrix(rnorm(100 * 2, sd = 0.1), 100, 2) TraceRatio(G, Ghat)
This dataset contains the Zillow Home Value Index (ZHVI) at the county level for single-family residences and condos with 1, 2, 3, 4, or 5+ bedrooms. It focuses on the middle tier of home values (33rd to 67th percentile) and features smoothed, seasonally adjusted values presented on a monthly basis. The data spans 16 U.S. states from January 2000 to April 2023. Within each state, the data is organized as a matrix, and the data for all states is compiled into a list.
data(UShouseprice)data(UShouseprice)
The dataset is structured as a list containing 16 elements, with each element corresponding to a state. Each element is a matrix where the columns represent time series data for house prices at the county level.
Each time series has a length of 280, representing monthly data points from January 2000 to April 2023.
The number of columns in each matrix varies, ranging from 90 to 250, depending on the number of counties and bedroom categories in the state.
The columns are labeled with the county name and bedroom count (e.g., "Pulaski County bd1" for one-bedroom homes or "Garland County bd5" for homes with five or more bedrooms).
The column names of the data matrix represent county names combined with bedroom counts. For example, "Pulaski County bd1" indicates the house price in Pulaski County for one-bedroom homes, while "Garland County bd5" refers to the house price in Garland County for homes with more than five bedrooms.
The abbreviations and full names of these 16 states are as follows:
AR: Arkansas
CA: California
CO: Colorado
FL: Florida
GA: Georgia
KY: Kentucky
MD: Maryland
MI: Michigan
NC: North Carolina
NJ: New Jersey
NY: New York
OH: Ohio
OK: Oklahoma
PA: Pennsylvania
TN: Tennessee
VA: Virginia
The original data is downloaded from the website of Zillow.
Aggregated Projection Method: A New Approach for Group Factor Model. Jiaqi Hu, Ting Li, Xueqin Wang (2025). Journal of the American Statistical Association, doi:10.1080/01621459.2025.2491154
data(UShouseprice) # Helper function to calculate log differences and scale log_diff <- function(x) { T <- nrow(x) res <- log(x[2:T, ] / x[1:(T - 1), ]) * 100 scale(res, center = TRUE, scale = TRUE) } # Apply to all states UShouseprice1 <- lapply(UShouseprice, log_diff)data(UShouseprice) # Helper function to calculate log differences and scale log_diff <- function(x) { T <- nrow(x) res <- log(x[2:T, ] / x[1:(T - 1), ]) * 100 scale(res, center = TRUE, scale = TRUE) } # Apply to all states UShouseprice1 <- lapply(UShouseprice, log_diff)