Package 'IALS'

Title: Iterative Alternating Least Square Estimation for Large-Dimensional Matrix Factor Model
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) <arXiv:2301.00360>.
Authors: Yong He [aut], Ran Zhao [aut, cre], Wen-Xin Zhou [aut]
Maintainer: Ran Zhao <[email protected]>
License: GPL-2 | GPL-3
Version: 0.1.3
Built: 2024-12-13 06:30:03 UTC
Source: CRAN

Help Index


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 p×q1p \times q_1.

Z2

Input another matrix with p×q2p \times q_2

Details

Define

D(Q1,Q2)=(11max(q1,q2)Tr(Q1Q1Q2Q2))1/2.\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 D(Q1,Q2)\mathcal{D}(\bold{Q}_1,\bold{Q}_2), we can easily see that 0D(Q1,Q2)10 \leq \mathcal{D}(\bold{Q}_1,\bold{Q}_2)\leq 1, which measures the distance between the column spaces spanned by two orthogonal matrices Q1\bold{Q}_1 and Q2\bold{Q}_2, i.e., span(Q1)\text{span}(\bold{Q}_1) and span(Q2)\text{span}(\bold{Q}_2). In particular, span(Q1)\text{span}(\bold{Q}_1) and span(Q2)\text{span}(\bold{Q}_2) are the same when D(Q1,Q2)=0\mathcal{D}(\bold{Q}_1,\bold{Q}_2)=0, while span(Q1)\text{span}(\bold{Q}_1) and span(Q2)\text{span}(\bold{Q}_2) are orthogonal when D(Q1,Q2)=1\mathcal{D}(\bold{Q}_1,\bold{Q}_2)=1. The Gram-Schmidt orthogonalization can be used to make Q1\bold{Q}_1 and Q2\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 T×p1×p2T \times p_1 \times p_2, where TT is the sample size, p1p_1 is the the row dimension of each matrix observation and p2p_2 is the the column dimension of each matrix observation.

W1

The initial value for the row factor loading matrix. The default is NULL, with an initial estimate chosen from α\alpha-PCA if not provided.

W2

The initial value for the column factor loading matrix. The default is NULL, with an initial estimate chosen from α\alpha-PCA if not provided.

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 106×Tp1p210^{-6} \times Tp_1 p_2.

Details

Assume we have two weight matrices Wi\bold{W}_i of dimension pi×mip_{i} \times m_{i} for i=1,2i=1,2, as substitutes for R\bold{R} and C\bold{C} respectively. Then it is straightforward to estimate Ft\bold{F}_t simply by

F^t=1p1p2W1XtW2.\hat{\bold{F}}_{t}=\frac{1}{p_{1}p_{2}}\bold{W}_1^\top\bold{X}_t\bold{W}_2.

Given F^t\hat{\bold{F}}_t and W1\bold{W}_1, we can derive that

R^=p1(t=1TXtW2F^t)[(t=1TF^tW2Xt)(t=1TXtW2F^t)]1/2.\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

C^=p2(t=1TXtR^F^t)[(t=1TF^tR^Xt)(t=1TXtR^F^t)]1/2.\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 F\bold{F}, R\bold{R} and C\bold{C}. In simulation, the iterative procedure is terminated either when a pre-specified maximum iteration number (maxiter=100\text{maxiter}=100) is reached or when

t=1TS^t(s+1)S^t(s)FϵTp1p2,\sum_{t=1}^{T}\|\hat{\bold{S}}^{(s+1)}_t-\hat{\bold{S}}^{(s)}_t\|_{F} \leq \epsilon \cdot Tp_1p_2,

where S^t(s)\hat{\bold{S}}^{(s)}_t is the common component estimated at the ss-th step, ϵ\epsilon is a small constant (10610^{-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 p1×m1p_1\times m_1, satisfying RR=p1Im1\bold{R}^\top\bold{R}=p_1\bold{I}_{m_1}.

C

The estimated column loading matrix of dimension p2×m2p_2\times m_2, satisfying CC=p2Im2\bold{C}^\top\bold{C}=p_2\bold{I}_{m_2}.

F

The estimated factor matrix of dimension T×m1×m2T \times m_1\times m_2.

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 T×p1×p2T \times p_1 \times p_2, where TT is the sample size, p1p_1 is the the row dimension of each matrix observation and p2p_2 is the the column dimension of each matrix observation.

W1

The initial value for the row factor loading matrix. The default is NULL, with an initial estimate chosen from α\alpha-PCA if not provided.

W2

The initial value for the column factor loading matrix. The default is NULL, with an initial estimate chosen from α\alpha-PCA if not provided.

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 IALS.

ep

The stopping criterion in the iteration algorithm, default is 106×Tp1p210^{-6} \times Tp_1 p_2. See in IALS.

Details

In detail, we first set kmaxk_{\max} is a predetermined upper bound for k1,k2k_1,k_2 and thus by IALS method, we can obtain the estimate of Ft\bold{F}_t, denote as F^t\hat{\bold{F}}_t, which is of dimension kmax×kmaxk_{\max}\times k_{\max}. Then the dimensions k1k_1 and k2k_2 are further determined as follows:

k^1=argmaxjkmaxλj(1Tt=1TF^tF^t)λj+1(1Tt=1TF^tF^t),\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)},

k^2=argmaxjkmaxλj(1Tt=1TF^tF^t)λj+1(1Tt=1TF^tF^t).\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