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.1 |
Built: | 2024-12-23 06:17:47 UTC |
Source: | CRAN |
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 |
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). This structure provides a comprehensive and organized representation of the Zillow Home Value Index (ZHVI) across multiple counties and bedroom categories for the 16 states included in the dataset.
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.
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)