Title: | Group Factor Analysis |
---|---|
Description: | Several group factor analysis 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 Aggregated projection method. |
Authors: | Jiaqi Hu [cre, aut], Ting Li [aut], Xueqin Wang [aut] |
Maintainer: | Jiaqi Hu <[email protected]> |
License: | GPL-3 |
Version: | 0.2 |
Built: | 2024-11-23 03:15:43 UTC |
Source: | https://github.com/cran/GrFA |
Aggregated Projection Method
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. |
r0 |
the number of global factors, default is |
r |
the number of local factors in each group, default is |
localfactor |
if |
weight |
the weight of each projection matrix, default is |
method |
the method used in the algorithm, default is |
type |
the method used in estimating the factor numbers in each group initially, default is |
r0hat |
the estimated number of the global factors. |
rho |
the estimated number of the local factors. |
Ghat |
the estimated global factors. |
loading_G |
a list consisting of the estimated global factor loadings. |
Fhat |
the estimated local factors. |
loading_F |
a list consisting of the estimated local factor loadings. |
e |
a list consisting of the residuals. |
threshold |
the threshold used in determining the number of global factors, only for |
dat = gendata() dat APM(dat$y, rmax = 8, localfactor = TRUE, method = "ic") APM(dat$y, rmax = 8, localfactor = TRUE, method = "gap")
dat = gendata() dat APM(dat$y, rmax = 8, localfactor = TRUE, method = "ic") APM(dat$y, rmax = 8, localfactor = TRUE, method = "gap")
Canonical Correlation Estimation
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. |
r0 |
the number of global factors, default is |
r |
the number of local factors in each group, default is |
localfactor |
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 |
r0hat |
the estimated number of the global factors. |
rho |
the estimated number of the local factors. |
Ghat |
the estimated global factors. |
Fhat |
the estimated local factors. |
loading_G |
a list consisting of the estimated global factor loadings. |
loading_F |
a list consisting of the estimated local factor loadings. |
e |
a list consisting of the residuals. |
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 = gendata() dat CCA(dat$y, rmax = 8, localfactor = TRUE, method = "CCD") CCA(dat$y, rmax = 8, localfactor = TRUE, method = "MCC")
dat = gendata() dat CCA(dat$y, rmax = 8, localfactor = TRUE, method = "CCD") CCA(dat$y, rmax = 8, localfactor = TRUE, method = "MCC")
Circularly Projected Estimation
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. |
r0 |
the number of global factors, default is |
r |
the number of local factors in each group, default is |
localfactor |
if |
type |
the method used in estimating the local factor numbers in each group after projecting out the global factors, default is |
r0hat |
the estimated number of the global factors. |
rho |
the estimated number of the local factors. |
Ghat |
the estimated global factors. |
Fhat |
the estimated local factors. |
loading_G |
a list consisting of the estimated global factor loadings. |
loading_F |
a list consisting of the estimated local factor loadings. |
e |
a list consisting of the residuals. |
Chen, M. (2023). Circularly Projected Common Factors for Grouped Data. Journal of Business & Economic Statistics, 41(2), 636-649.
dat = gendata() dat CP(dat$y, rmax = 8, localfactor = TRUE)
dat = gendata() dat CP(dat$y, rmax = 8, localfactor = TRUE)
Estimate factor numbers.
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. |
type |
the criterion used in determining the number of factors, default is |
rhat |
the estimated number of factors. |
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.
Factor analysis.
FA(X, r)
FA(X, r)
X |
the observation data matrix of dimension |
r |
the factor numbers need to estimated. |
F |
the estimated factors. |
L |
the estimated factor loadings. |
Jiaqi Hu
Bai, J., & Ng, S. (2002). Determining the number of factors in approximate factor models. Econometrica, 70(1), 191-221.
Generalised Canonical Correlation
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. |
r0 |
the number of global factors, default is |
r |
the number of local factors in each group, default is |
localfactor |
if |
type |
the method used in estimating the factor numbers in each group initially, default is |
r0hat |
the estimated number of the global factors. |
rho |
the estimated number of the local factors. |
Ghat |
the estimated global factors. |
Fhat |
the estimated local factors. |
loading_G |
a list consisting of the estimated global factor loadings. |
loading_F |
a list consisting of the estimated local factor loadings. |
e |
a list consisting of the residuals. |
Lin, R., & Shin, Y. (2023). Generalised Canonical Correlation Estimation of the Multilevel Factor Model. Available at SSRN 4295429.
dat = gendata() dat GCC(dat$y, rmax = 8, localfactor = TRUE)
dat = gendata() dat GCC(dat$y, rmax = 8, localfactor = TRUE)
Generate the grouped data.
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. |
N |
a vector representing the number of variables in each group. |
r0 |
the number of global factors. |
r |
a vector representing the number of the local factors. Notice, the length of |
Phi_G |
hyperparameter of the global factors, default is 0.5, the value should between 0 and 1. |
Phi_F |
hyperparameter of the local factors, default is 0.5, the value should between 0 and 1. |
Phi_e |
hyperparameter of the errors, default is 0.5, the value should between 0 and 1. |
W_F |
hyperparameter of the correlation of local factors, only applicable in |
beta |
hyperparameter of the errors, 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 and 3. |
y |
a list of the data. |
G |
the global factors. |
F |
a list of the local factors. |
loading_G |
the global factor loadings. |
loading_F |
the local factor loadings. |
T |
the number of time points. |
N |
a vector representing the number of variables in each group. |
M |
the number of groups. |
r0 |
the number of global factors. |
r |
a vector representing the number of the local factors. |
case |
the case of the data-generating process. |
dat = gendata() dat
dat = gendata() dat
Print the summarized results of the estimated group factor model, such as the estimated global and local factors.
## S3 method for class 'GFA' print(x, ...)
## S3 method for class 'GFA' print(x, ...)
x |
the |
... |
additional print arguments. |
No return value, called for side effects
Evaluation of the estimated factors by trace ratios, the values is between 0 and 1, higher values means better estimation.
TraceRatio(G, Ghat)
TraceRatio(G, Ghat)
G |
the true factors. |
Ghat |
the estimated factors. |
trace ratio |
defined as |
Housing price data for 16 states in the U.S over the period Jan 2000 to April 2023.
data("UShouseprice")
data("UShouseprice")
A list with a length of 16. Each element is a matrix of dimension .
The original data is downloaded from the website of Zillow.
data(UShouseprice) log_diff = function(x){ T = nrow(x) res = log(x[2:T,]/x[1:(T-1),])*100 scale(res, center = TRUE, scale = TRUE) } UShouseprice1 = lapply(UShouseprice, log_diff)
data(UShouseprice) log_diff = function(x){ T = nrow(x) res = log(x[2:T,]/x[1:(T-1),])*100 scale(res, center = TRUE, scale = TRUE) } UShouseprice1 = lapply(UShouseprice, log_diff)