Type: | Package |
Title: | Iterative Alternating Least Square Estimation for Large-Dimensional Matrix Factor Model |
Version: | 0.1.3 |
Author: | Yong He [aut], Ran Zhao [aut, cre], Wen-Xin Zhou [aut] |
Maintainer: | Ran Zhao <Zhaoran@mail.sdu.edu.cn> |
Description: | The matrix factor model has drawn growing attention for its advantage in achieving two-directional dimension reduction simultaneously for matrix-structured observations. In contrast to the Principal Component Analysis (PCA)-based methods, we propose a simple Iterative Alternating Least Squares (IALS) algorithm for matrix factor model, see the details in He et al. (2023) <doi:10.48550/arXiv.2301.00360>. |
License: | GPL-2 | GPL-3 |
Encoding: | UTF-8 |
Depends: | R (≥ 4.0) |
Imports: | RSpectra, pracma, HDMFA |
NeedsCompilation: | no |
Packaged: | 2024-02-16 11:31:24 UTC; 赵冉 |
Repository: | CRAN |
Date/Publication: | 2024-02-16 11:50:07 UTC |
The distance between the spaces spanned by the column of two matrices.
Description
Calculate the distance between spaces spanned by the column of two matrices. The distance is between 0 and 1. If the two spaces are the same, the distance is 0. if the two spaces are orthogonal, the distance is 1.
Usage
Distance(Z1, Z2)
Arguments
Z1 |
Input a matrix with |
Z2 |
Input another matrix with |
Details
Define
\mathcal{D}(\bold{Q}_1,\bold{Q}_2)=\left(1-\frac{1}{\max{(q_1,q_2)}}\text{Tr}\left(\bold{Q}_1\bold{Q}_1^\top\bold{Q}_2\bold{Q}_2^\top\right)\right)^{1/2}.
By the definition of \mathcal{D}(\bold{Q}_1,\bold{Q}_2)
, we can easily see that 0 \leq \mathcal{D}(\bold{Q}_1,\bold{Q}_2)\leq 1
, which measures the distance between the column spaces spanned by two orthogonal matrices \bold{Q}_1
and \bold{Q}_2
, i.e., \text{span}(\bold{Q}_1)
and \text{span}(\bold{Q}_2)
. In particular, \text{span}(\bold{Q}_1)
and \text{span}(\bold{Q}_2)
are the same when \mathcal{D}(\bold{Q}_1,\bold{Q}_2)=0
, while \text{span}(\bold{Q}_1)
and \text{span}(\bold{Q}_2)
are orthogonal when \mathcal{D}(\bold{Q}_1,\bold{Q}_2)=1
. The Gram-Schmidt orthogonalization can be used to make \bold{Q}_1
and \bold{Q}_2
column-orthogonal matrices.
Value
Output a number between 0 and 1.
Author(s)
Yong He, Ran Zhao, Wen-Xin Zhou.
References
He, Y., Zhao, R., & Zhou, W. X. (2023). Iterative Least Squares Algorithm for Large-dimensional Matrix Factor Model by Random Projection. <arXiv:2301.00360>.
Examples
set.seed(1111)
A=matrix(rnorm(10),5,2)
B=matrix(rnorm(15),5,3)
Distance(A,B)
Iterative Alternating Least Square Estimation for Large-dimensional Matrix Factor Model
Description
This function is designed to fit the matrix factor model using the Iterative Least Squares (IALS) method, rather than Principal Component Analysis (PCA)-based methods. In detail, in the first step, we propose to estimate the latent factor matrices by projecting the matrix observations with two deterministic weight matrices, chosen to diversify away the idiosyncratic components. In the second step, we update the row/column loading matrices by minimizing the squared loss function under the identifiability condition. The estimators of the loading matrices are then treated as the new weight matrices, and the algorithm iteratively performs these two steps until a convergence criterion is reached.
Usage
IALS(X, W1 = NULL, W2 = NULL, m1, m2, max_iter = 100, ep = 1e-06)
Arguments
X |
Input an array with |
W1 |
The initial value for the row factor loading matrix. The default is NULL, with an initial estimate chosen from |
W2 |
The initial value for the column factor loading matrix. The default is NULL, with an initial estimate chosen from |
m1 |
A positive integer indicating the row factor number. |
m2 |
A positive integer indicating the column factor number. |
max_iter |
The maximum number of iterations for the algorithm, default is 100. |
ep |
The stopping criterion in the iteration algorithm, default is |
Details
Assume we have two weight matrices \bold{W}_i
of dimension p_{i} \times m_{i}
for i=1,2
, as substitutes for \bold{R}
and \bold{C}
respectively. Then it is straightforward to estimate \bold{F}_t
simply by
\hat{\bold{F}}_{t}=\frac{1}{p_{1}p_{2}}\bold{W}_1^\top\bold{X}_t\bold{W}_2.
Given \hat{\bold{F}}_t
and \bold{W}_1
, we can derive that
\hat{\bold{R}}=\sqrt{p_{1}}\left(\sum_{t=1}^{T}\bold{X}_t\bold{W}_2\hat{\bold{F}}_t^\top\right)\left[\left(\sum_{t=1}^{T}\hat{\bold{F}}_t\bold{W}_2^\top\bold{X}_t^\top\right)\left(\sum_{t=1}^{T}\bold{X}_t\bold{W}_2\hat{\bold{F}}_t^\top\right)\right]^{-1/2}.
Similarly, we get the following estimator of the column factor loading matrix
\hat{\bold{C}}=\sqrt{p_{2}}\left(\sum_{t=1}^{T}\bold{X}_t^\top\hat{\bold{R}}\hat{\bold{F}}_t\right)\left[\left(\sum_{t=1}^{T}\hat{\bold{F}}_t^\top\hat{\bold{R}}^\top\bold{X}_t\right)\left(\sum_{t=1}^{T}\bold{X}_t^\top\hat{\bold{R}}\hat{\bold{F}}_t\right)\right]^{-1/2}.
Afterwards, we sequentially update \bold{F}
, \bold{R}
and \bold{C}
. In simulation, the iterative procedure is terminated either when a pre-specified maximum iteration number (\text{maxiter}=100
) is reached or when
\sum_{t=1}^{T}\|\hat{\bold{S}}^{(s+1)}_t-\hat{\bold{S}}^{(s)}_t\|_{F} \leq \epsilon \cdot Tp_1p_2,
where \hat{\bold{S}}^{(s)}_t
is the common component estimated at the s
-th step, \epsilon
is a small constant (10^{-6}
) given in advance.
Value
The return value is a list. In this list, it contains the following:
R |
The estimated row loading matrix of dimension |
C |
The estimated column loading matrix of dimension |
F |
The estimated factor matrix of dimension |
iter |
The number of iterations when the stopping criterion is met. |
Author(s)
Yong He, Ran Zhao, Wen-Xin Zhou.
References
He, Y., Zhao, R., & Zhou, W. X. (2023). Iterative Alternating Least Square Estimation for Large-dimensional Matrix Factor Model. <arXiv:2301.00360>.
Examples
set.seed(11111)
T=20;p1=20;p2=20
k1=3;k2=3
R=matrix(runif(p1*k1,min=-1,max=1),p1,k1)
C=matrix(runif(p2*k2,min=-1,max=1),p2,k2)
X=E=array(0,c(T,p1,p2))
F=array(0,c(T,k1,k2))
for(t in 1:T){
F[t,,]=matrix(rnorm(k1*k2),k1,k2)
E[t,,]=matrix(rnorm(p1*p2),p1,p2)
}
for(t in 1:T){
X[t,,]=R%*%F[t,,]%*%t(C)+E[t,,]
}
#Estimating the matrix factor model using the default initial values
fit1 = IALS(X, W1 = NULL, W2 = NULL,k1, k2, max_iter = 100, ep = 1e-06)
Distance(fit1$R,R);Distance(fit1$C,C)
#Estimating the matrix factor model using one-step iteration
fit2 = IALS(X, W1 = NULL , W2 = NULL, k1, k2, max_iter = 1, ep = 1e-06)
Distance(fit2$R,R);Distance(fit2$C,C)
Estimating the Pair of Factor Numbers via Eigenvalue Ratios Corresponding to IALS
Description
The function is to estimate the pair of factor numbers via eigenvalue ratios corresponding to IALS method.
Usage
KIALS(X, W1 = NULL, W2 = NULL, kmax, max_iter = 100, ep = 1e-06)
Arguments
X |
Input an array with |
W1 |
The initial value for the row factor loading matrix. The default is NULL, with an initial estimate chosen from |
W2 |
The initial value for the column factor loading matrix. The default is NULL, with an initial estimate chosen from |
kmax |
The user-supplied maximum factor numbers. Here it means the upper bound of the number of row factors and column factors. |
max_iter |
The maximum number of iterations for the algorithm, default is 100. See in |
ep |
The stopping criterion in the iteration algorithm, default is |
Details
In detail, we first set k_{\max}
is a predetermined upper bound for k_1,k_2
and thus by IALS
method, we can obtain the estimate of \bold{F}_t
, denote as \hat{\bold{F}}_t
, which is of dimension k_{\max}\times k_{\max}
. Then the dimensions k_1
and k_2
are further determined as follows:
\hat{k}_{1}=\arg\max_{j \leq k_{\max}}\frac{\lambda_{j}\left(\dfrac{1}{T}\sum_{t=1}^{T}\hat{\bold{F}}_t\hat{\bold{F}}_t^\top\right)}{\lambda_{j+1}\left(\frac{1}{T}\sum_{t=1}^{T}\hat{\bold{F}}_t\hat{\bold{F}}_t^\top\right)},
\hat{k}_{2}=\arg\max_{j \leq k_{\max}}\frac{\lambda_{j}\left(\dfrac{1}{T}\sum_{t=1}^{T}\hat{\bold{F}}_t^\top\hat{\bold{F}}_t\right)}{\lambda_{j+1}\left(\frac{1}{T}\sum_{t=1}^{T}\hat{\bold{F}}_t^\top\hat{\bold{F}}_t\right)}.
Value
\eqn{k_1} |
The estimated row factor number. |
\eqn{k_2} |
The estimated column factor number. |
Author(s)
Yong He, Ran Zhao, Wen-Xin Zhou.
References
He, Y., Zhao, R., & Zhou, W. X. (2023). Iterative Alternating Least Square Estimation for Large-dimensional Matrix Factor Model. <arXiv:2301.00360>.
Examples
set.seed(11111)
T=20;p1=20;p2=20
k1=3;k2=3
R=matrix(runif(p1*k1,min=-1,max=1),p1,k1)
C=matrix(runif(p2*k2,min=-1,max=1),p2,k2)
X=E=array(0,c(T,p1,p2))
F=array(0,c(T,k1,k2))
for(t in 1:T){
F[t,,]=matrix(rnorm(k1*k2),k1,k2)
E[t,,]=matrix(rnorm(p1*p2),p1,p2)
}
for(t in 1:T){
X[t,,]=R%*%F[t,,]%*%t(C)+E[t,,]
}
kmax=8
K=KIALS(X, W1 = NULL, W2 = NULL, kmax, max_iter = 100, ep = 1e-06);K