Title: | Factor and Autoregressive Models for Tensor Time Series |
---|---|
Description: | Factor and autoregressive models for matrix and tensor valued time series. We provide functions for estimation, simulation and prediction. The models are discussed in Li et al (2021) <doi:10.48550/arXiv.2110.00928>, Chen et al (2020) <DOI:10.1080/01621459.2021.1912757>, Chen et al (2020) <DOI:10.1016/j.jeconom.2020.07.015>, and Xiao et al (2020) <doi:10.48550/arXiv.2006.02611>. |
Authors: | Zebang Li [aut, cre], Ruofan Yu [aut], Rong Chen [aut], Yuefeng Han [aut], Han Xiao [aut], Dan Yang [aut] |
Maintainer: | Zebang Li <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.0.2 |
Built: | 2025-03-03 03:40:53 UTC |
Source: | https://github.com/zebang/tensorts |
Estimation of the reduced rank MAR(1) model, using least squares (RRLSE) or MLE (RRMLE), as determined by the value of method
.
matAR.RR.est(xx, method, A1.init=NULL, A2.init=NULL,Sig1.init=NULL,Sig2.init=NULL, k1=NULL, k2=NULL, niter=200,tol=1e-4)
matAR.RR.est(xx, method, A1.init=NULL, A2.init=NULL,Sig1.init=NULL,Sig2.init=NULL, k1=NULL, k2=NULL, niter=200,tol=1e-4)
xx |
|
method |
character string, specifying the method of the estimation to be used.
|
A1.init |
initial value of |
A2.init |
initial value of |
Sig1.init |
only if |
Sig2.init |
only if |
k1 |
rank of |
k2 |
rank of |
niter |
maximum number of iterations if error stays above |
tol |
relative Frobenius norm error tolerance. |
The reduced rank MAR(1) model takes the form:
where are
coefficient matrices of ranks
,
. For the MLE method we also assume
return a list containing the following:
A1
estimator of , a
by
matrix.
A2
estimator of , a
by
matrix.
loading
a list of estimated ,
,
where we write
as the singular value decomposition (SVD) of
,
.
Sig1
only if method=MLE
, when .
Sig2
only if method=MLE
, when .
res
residuals.
Sig
sample covariance matrix of the residuals vec().
cov
a list containing
Sigma
asymptotic covariance matrix of (vec( ),vec(
)).
Theta1.u
, Theta1.v
asymptotic covariance matrix of vec(), vec(
).
Theta2.u
, Theta2.v
asymptotic covariance matrix of vec(), vec(
).
sd.A1
element-wise standard errors of , aligned with
A1
.
sd.A2
element-wise standard errors of , aligned with
A2
.
niter
number of iterations.
BIC
value of the extended Bayesian information criterion.
Reduced Rank Autoregressive Models for Matrix Time Series, by Han Xiao, Yuefeng Han, Rong Chen and Chengcheng Liu.
set.seed(333) dim <- c(3,3) xx <- tenAR.sim(t=500, dim, R=2, P=1, rho=0.5, cov='iid') est <- matAR.RR.est(xx, method="RRLSE", k1=1, k2=1)
set.seed(333) dim <- c(3,3) xx <- tenAR.sim(t=500, dim, R=2, P=1, rho=0.5, cov='iid') est <- matAR.RR.est(xx, method="RRLSE", k1=1, k2=1)
Asymptotic covariance matrix of the reduced rank MAR(1) model. If Sigma1
and Sigma2
is provided in input,
we assume a separable covariance matrix, Cov(vec()) =
.
matAR.RR.se(A1,A2,k1,k2,method,Sigma.e=NULL,Sigma1=NULL,Sigma2=NULL,RU1=diag(k1), RV1=diag(k1),RU2=diag(k2),RV2=diag(k2),mpower=100)
matAR.RR.se(A1,A2,k1,k2,method,Sigma.e=NULL,Sigma1=NULL,Sigma2=NULL,RU1=diag(k1), RV1=diag(k1),RU2=diag(k2),RV2=diag(k2),mpower=100)
A1 |
left coefficient matrix. |
A2 |
right coefficient matrix. |
k1 |
rank of |
k2 |
rank of |
method |
character string, specifying the method of the estimation to be used.
|
Sigma.e |
only if |
Sigma1 , Sigma2
|
only if |
RU1 , RV1 , RU2 , RV2
|
orthogonal rotations of |
mpower |
truncate the VMA( |
a list containing the following:
Sigma
asymptotic covariance matrix of (vec(),vec(
)).
Theta1.u
asymptotic covariance matrix of vec().
Theta1.v
asymptotic covariance matrix of vec().
Theta2.u
asymptotic covariance matrix of vec().
Theta2.v
asymptotic covariance matrix of vec().
Han Xiao, Yuefeng Han, Rong Chen and Chengcheng Liu, Reduced Rank Autoregressive Models for Matrix Time Series.
Plot matrix-valued time series, can be also used to plot a given slice of a tensor-valued time series.
mplot(xx)
mplot(xx)
xx |
|
a figure.
dim <- c(3,3,3) xx <- tenAR.sim(t=50, dim, R=2, P=1, rho=0.5, cov='iid') mplot(xx[1:30,,,1])
dim <- c(3,3,3) xx <- tenAR.sim(t=50, dim, R=2, P=1, rho=0.5, cov='iid') mplot(xx[1:30,,,1])
Plot ACF of matrix-valued time series, can be also used to plot ACF of a given slice of a tensor-valued time series.
mplot.acf(xx)
mplot.acf(xx)
xx |
|
a figure.
dim <- c(3,3,3) xx <- tenAR.sim(t=50, dim, R=2, P=1, rho=0.5, cov='iid') mplot.acf(xx[1:30,,,1])
dim <- c(3,3,3) xx <- tenAR.sim(t=50, dim, R=2, P=1, rho=0.5, cov='iid') mplot.acf(xx[1:30,,,1])
S3 method for the 'tenAR' class using the generic predict function. Prediction based on the tensor autoregressive model or reduced rank MAR(1) model. If rolling = TRUE
, returns the rolling forecasts.
## S3 method for class 'tenAR' predict( object, n.ahead = 1, xx = NULL, rolling = FALSE, n0 = NULL, print.true = TRUE, ... )
## S3 method for class 'tenAR' predict( object, n.ahead = 1, xx = NULL, rolling = FALSE, n0 = NULL, print.true = TRUE, ... )
object |
a model object returned by |
n.ahead |
prediction horizon. |
xx |
|
rolling |
TRUE or FALSE, rolling forecast, is FALSE by default. |
n0 |
only if |
print.true |
only if |
... |
Additional arguments passed to the method. |
a tensor time series of length n.ahead
if rolling = FALSE
;
a tensor time series of length if
rolling = TRUE
.
'predict.ar' or 'predict.arima'
set.seed(333) dim <- c(2,2,2) t = 20 xx <- tenAR.sim(t, dim, R=2, P=1, rho=0.5, cov='iid') est <- tenAR.est(xx, R=1, P=1, method="LSE") pred <- predict(est, n.ahead = 1) # rolling forcast n0 = t - min(50,t/2) pred.rolling <- predict(est, n.ahead = 5, xx = xx, rolling=TRUE, n0) # prediction for reduced rank MAR(1) model dim <- c(2,2) t = 20 xx <- tenAR.sim(t, dim, R=1, P=1, rho=0.5, cov='iid') est <- matAR.RR.est(xx, method="RRLSE", k1=1, k2=1) pred <- predict(est, n.ahead = 1) # rolling forcast n0 = t - min(50,t/2) pred.rolling <- predict(est, n.ahead = 5, rolling=TRUE, n0=n0)
set.seed(333) dim <- c(2,2,2) t = 20 xx <- tenAR.sim(t, dim, R=2, P=1, rho=0.5, cov='iid') est <- tenAR.est(xx, R=1, P=1, method="LSE") pred <- predict(est, n.ahead = 1) # rolling forcast n0 = t - min(50,t/2) pred.rolling <- predict(est, n.ahead = 5, xx = xx, rolling=TRUE, n0) # prediction for reduced rank MAR(1) model dim <- c(2,2) t = 20 xx <- tenAR.sim(t, dim, R=1, P=1, rho=0.5, cov='iid') est <- matAR.RR.est(xx, method="RRLSE", k1=1, k2=1) pred <- predict(est, n.ahead = 1) # rolling forcast n0 = t - min(50,t/2) pred.rolling <- predict(est, n.ahead = 5, rolling=TRUE, n0=n0)
Simulate tensor time series by autoregressive models, using estimated coefficients by taxi data.
taxi.sim.AR(t, print.tar.coef=FALSE, print.sig=FALSE, seed=123)
taxi.sim.AR(t, print.tar.coef=FALSE, print.sig=FALSE, seed=123)
t |
length of output series. |
print.tar.coef |
print coefficients, default FALSE. |
print.sig |
print covariance matrices, default FALSE. |
seed |
random seed. |
A tensor-valued time series of dimension (5,5,7).
xx = taxi.sim.AR(t=753)
xx = taxi.sim.AR(t=753)
Simulate tensor time series by factor models, using estimated coefficients by taxi data.
taxi.sim.FM(t, print.tar.coef=FALSE, print.loading=FALSE, seed=216)
taxi.sim.FM(t, print.tar.coef=FALSE, print.loading=FALSE, seed=216)
t |
length of output series. |
print.tar.coef |
print coefficients used for simulation, default FALSE. |
print.loading |
print loading matrices used for simulation, default FALSE. |
seed |
random seed. |
A tensor-valued time series of dimension (4,4,3).
xx = taxi.sim.FM(t=252)
xx = taxi.sim.FM(t=252)
Estimation function for tensor autoregressive models. Methods include
projection (PROJ), Least Squares (LSE), maximum likelihood estimation (MLE)
and vector autoregressive model (VAR), as determined by the value of method
.
tenAR.est(xx,R=1,P=1,method="LSE",init.A=NULL,init.sig=NULL,niter=150,tol=1e-6)
tenAR.est(xx,R=1,P=1,method="LSE",init.A=NULL,init.sig=NULL,niter=150,tol=1e-6)
xx |
|
R |
Kronecker rank for each lag, a vector for |
P |
Autoregressive order, a positive integer. |
method |
character string, specifying the type of the estimation method to be used.
|
init.A |
initial values of coefficient matrices |
init.sig |
only if |
niter |
maximum number of iterations if error stays above |
tol |
error tolerance in terms of the Frobenius norm. |
Tensor autoregressive model (of autoregressive order one) has the form:
where are
coefficient matrices,
, and
is a tensor white noise.
is the Kronecker rank.
The model of autoregressive order
takes the form
For the "MLE" method, we also assume,
return a list containing the following:
A
a list of estimated coefficient matrices . It is a multi-layer list,
the first layer for the lag
, the second the term
, and the third the mode
. See "Details".
SIGMA
only if method=MLE
, a list of estimated .
res
residuals
Sig
sample covariance matrix of the residuals vec().
cov
grand covariance matrix of all estimated entries of
sd
standard errors of the coefficient matrices , returned as a list aligned with
A
.
niter
number of iterations.
BIC
value of extended Bayesian information criterion.
Rong Chen, Han Xiao, and Dan Yang. "Autoregressive models for matrix-valued time series". Journal of Econometrics, 2020.
Zebang Li, Han Xiao. "Multi-linear tensor autoregressive models". arxiv preprint arxiv:2110.00928 (2021).
set.seed(333) # case 1: tensor-valued time series dim <- c(2,2,2) xx <- tenAR.sim(t=100, dim, R=2, P=1, rho=0.5, cov='iid') est <- tenAR.est(xx, R=2, P=1, method="LSE") # two-term tenAR(1) model A <- est$A # A is a multi-layer list length(A) == 1 # TRUE, since the order P = 1 length(A[[1]]) == 2 # TRUE, since the number of terms R = 2 length(A[[1]][[1]]) == 3 # TRUE, since the mode K = 3 # est <- tenAR.est(xx, R=c(1,2), P=2, method="LSE") # tenAR(2) model with R1=1, R2=2 # case 2: matrix-valued time series dim <- c(2,2) xx <- tenAR.sim(t=100, dim, R=2, P=1, rho=0.5, cov='iid') est <- tenAR.est(xx, R=2, P=1, method="LSE") # two-term MAR(1) model A <- est$A # A is a multi-layer list length(A) == 1 # TRUE, since the order P = 1 length(A[[1]]) == 2 # TRUE, since the number of terms R = 2 length(A[[1]][[1]]) == 2 # TRUE, since the mode K = 2
set.seed(333) # case 1: tensor-valued time series dim <- c(2,2,2) xx <- tenAR.sim(t=100, dim, R=2, P=1, rho=0.5, cov='iid') est <- tenAR.est(xx, R=2, P=1, method="LSE") # two-term tenAR(1) model A <- est$A # A is a multi-layer list length(A) == 1 # TRUE, since the order P = 1 length(A[[1]]) == 2 # TRUE, since the number of terms R = 2 length(A[[1]][[1]]) == 3 # TRUE, since the mode K = 3 # est <- tenAR.est(xx, R=c(1,2), P=2, method="LSE") # tenAR(2) model with R1=1, R2=2 # case 2: matrix-valued time series dim <- c(2,2) xx <- tenAR.sim(t=100, dim, R=2, P=1, rho=0.5, cov='iid') est <- tenAR.est(xx, R=2, P=1, method="LSE") # two-term MAR(1) model A <- est$A # A is a multi-layer list length(A) == 1 # TRUE, since the order P = 1 length(A[[1]]) == 2 # TRUE, since the number of terms R = 2 length(A[[1]][[1]]) == 2 # TRUE, since the mode K = 2
Simulate from the TenAR(p) model.
tenAR.sim(t, dim, R, P, rho, cov, A = NULL, Sig = NULL)
tenAR.sim(t, dim, R, P, rho, cov, A = NULL, Sig = NULL)
t |
length of output series, a strictly positive integer. |
dim |
dimension of the tensor at each time. |
R |
Kronecker rank for each lag. |
P |
autoregressive order. |
rho |
spectral radius of coefficient matrix |
cov |
covariance matrix of the error term: diagonal ("iid"), separable ("mle"), random ("svd"). |
A |
coefficient matrices. If not provided, they are randomly generated according to given |
Sig |
only if |
A tensor-valued time series generated by the TenAR(p) model.
set.seed(123) dim <- c(3,3,3) xx <- tenAR.sim(t=500, dim, R=2, P=1, rho=0.5, cov='iid')
set.seed(123) dim <- c(3,3,3) xx <- tenAR.sim(t=500, dim, R=2, P=1, rho=0.5, cov='iid')
Estimation function for Tucker structure factor models of tensor-valued time series.
Two unfolding methods of the auto-covariance tensor, Time series Outer-Product Unfolding Procedure (TOPUP), Time series Inner-Product Unfolding Procedure (TIPUP),
are included, as determined by the value of method
.
tenFM.est(x,r,h0=1,method='TIPUP',iter=TRUE,tol=1e-4,maxiter=100)
tenFM.est(x,r,h0=1,method='TIPUP',iter=TRUE,tol=1e-4,maxiter=100)
x |
|
r |
input rank of factor tensor. |
h0 |
the number of lags used in auto-covariance tensor. If h0=0, covariance tensor is used. |
method |
character string, specifying the type of the estimation method to be used.
|
iter |
boolean, specifying using an iterative approach or an non-iterative approach. |
tol |
tolerance in terms of the Frobenius norm. |
maxiter |
maximum number of iterations if error stays above |
Tensor factor model with Tucker structure has the following form,
where is the deterministic loading matrix of size
and
,
the core tensor
itself is a latent tensor factor process of dimension
,
and the idiosyncratic noise tensor
is uncorrelated (white) across time. Two estimation approaches, named TOPUP and TIPUP, are studied.
Time series Outer-Product Unfolding Procedure (TOPUP) are based on
where is a predetermined positive integer,
is tensor product. Note that
is a function mapping a tensor time series to an order-5 tensor.
Time series Inner-Product Unfolding Procedure (TIPUP) replaces the tensor product in TOPUP with the inner product:
returns a list containing the following:
Ft
estimated factor processes of dimension .
Ft.all
Summation of factor processes over time, of dimension .
Q
a list of estimated factor loading matrices .
x.hat
fitted signal tensor, of dimension .
niter
number of iterations.
fnorm.resid
Frobenius norm of residuals, divide the Frobenius norm of the original tensor.
Chen, Rong, Dan Yang, and Cun-Hui Zhang. "Factor models for high-dimensional tensor time series." Journal of the American Statistical Association (2021): 1-59.
Han, Yuefeng, Rong Chen, Dan Yang, and Cun-Hui Zhang. "Tensor factor model estimation by iterative projection." arXiv preprint arXiv:2006.02611 (2020).
set.seed(333) dims <- c(16,18,20) # dimensions of tensor time series r <- c(3,3,3) # dimensions of factor series Ft <- tenAR.sim(t=100, dim=r, R=1, P=1, rho=0.9, cov='iid') lambda <- sqrt(prod(dims)) x <- tenFM.sim(Ft,dims=dims,lambda=lambda,A=NULL,cov='iid') # generate t*dims tensor time series result <- tenFM.est(x,r,h0=1,iter=TRUE,method='TIPUP') # Estimation Ft <- result$Ft
set.seed(333) dims <- c(16,18,20) # dimensions of tensor time series r <- c(3,3,3) # dimensions of factor series Ft <- tenAR.sim(t=100, dim=r, R=1, P=1, rho=0.9, cov='iid') lambda <- sqrt(prod(dims)) x <- tenFM.sim(Ft,dims=dims,lambda=lambda,A=NULL,cov='iid') # generate t*dims tensor time series result <- tenFM.est(x,r,h0=1,iter=TRUE,method='TIPUP') # Estimation Ft <- result$Ft
Function for rank determination of tensor factor models with Tucker Structure.
Two unfolding methods of the auto-covariance tensor, Time series Outer-Product Unfolding Procedure (TOPUP), Time series Inner-Product Unfolding Procedure (TIPUP),
are included, as determined by the value of method
.
Different penalty functions for the information criterion (IC) and the eigen ratio criterion (ER) can be used,
which should be specified by the value of rank
and penalty
. The information criterion resembles BIC in the vector factor model literature.
And the eigen ratio criterion is similar to the eigenvalue ratio based methods in the vector factor model literature.
tenFM.rank(x,r=NULL,h0=1,rank='IC',method='TIPUP',inputr=FALSE,iter=TRUE,penalty=1, delta1=0,tol=1e-4,maxiter=100)
tenFM.rank(x,r=NULL,h0=1,rank='IC',method='TIPUP',inputr=FALSE,iter=TRUE,penalty=1, delta1=0,tol=1e-4,maxiter=100)
x |
|
r |
initial guess of the rank of factor tensor. |
h0 |
the number of lags used in auto-covariance tensor. If h0=0, covariance tensor is used. |
rank |
character string, specifying the type of the rank determination method to be used.
|
method |
character string, specifying the type of the factor estimation method to be used.
|
inputr |
boolean, if TRUE, always use initial guess rank r in each iteration; if FLASE, the rank will be updated in each iteration. |
iter |
boolean, specifying using an iterative approach or a non-iterative approach. |
penalty |
takes value in
|
delta1 |
weakest factor strength, a tuning parameter used for IC method only |
tol |
tolerance in terms of the Frobenius norm. |
maxiter |
maximum number of iterations if error stays above |
Let be a
symmetric and non-negative definite matrix and
be its sample version,
be the eigenvalues of
such that
.
The rank determination methods using the information criterion ("IC") and the eigen ratio criterion ("ER") are defined as follows:
where is a predefined upper bound,
and
are some appropriate positive penalty functions. We have provided 5 choices for
and
;
see more details in the argument "
penalty
".
For non-iterative TOPUP and TIPUP methods, is
or
, for each tensor mode
,
,
where
and
are defined in the Details section of the function
tenFM.est
.
For iterative TOPUP and TIPUP methods, we refer to the literature in the References section for more information.
return a list containing the following:
path
a matrix of the estimated Tucker rank of the factor process as a path of the maximum number of iteration (
) used. The first row is the estimated rank under non-iterative approach, the
-th row is the estimated rank
at
-th iteration.
factor.num
final solution of the estimated Tucker rank of the factor process .
Han, Yuefeng, Cun-Hui Zhang, and Rong Chen. "Rank Determination in Tensor Factor Model." Available at SSRN 3730305 (2020).
set.seed(333) dims <- c(16,18,20) # dimensions of tensor time series r <- c(3,3,3) # dimensions of factor series Ft <- tenAR.sim(t=100, dim=r, R=1, P=1, rho=0.9, cov='iid') lambda <- sqrt(prod(dims)) x <- tenFM.sim(Ft,dims=dims,lambda=lambda,A=NULL,cov='iid') # generate t*dims tensor time series rank <- tenFM.rank(x,r=c(4,4,4),h0=1,rank='IC',iter=TRUE,method='TIPUP') # Estimate the rank
set.seed(333) dims <- c(16,18,20) # dimensions of tensor time series r <- c(3,3,3) # dimensions of factor series Ft <- tenAR.sim(t=100, dim=r, R=1, P=1, rho=0.9, cov='iid') lambda <- sqrt(prod(dims)) x <- tenFM.sim(Ft,dims=dims,lambda=lambda,A=NULL,cov='iid') # generate t*dims tensor time series rank <- tenFM.rank(x,r=c(4,4,4),h0=1,rank='IC',iter=TRUE,method='TIPUP') # Estimate the rank
Simulate tensor time series using a given factor process
. The factor process
can be generated by the function
tenAR.sim
.
tenFM.sim(Ft,dims=NULL,lambda=1,A=NULL,cov='iid',rho=0.2)
tenFM.sim(Ft,dims=NULL,lambda=1,A=NULL,cov='iid',rho=0.2)
Ft |
input of the factor process, of dimension |
dims |
dimensions of the output tensor at each time, |
lambda |
signal strength parameter of the tensor factor models, see Details section for more information. |
A |
a list of the factor loading matrices |
cov |
covariance matrix of the error tensor: identity ("iid"), separable Kronecker structure ("separable"), random ("random"). |
rho |
a parameter only for "separable" covariance matrix of the error tensor. It is the off-diagonal element of the error matrices, with the diagonal being 1. |
Simulate from the model :
where is the deterministic loading matrix of size
and
,
the core tensor
itself is a latent tensor factor process of dimension
,
is an additional signal strength parameter,
and the idiosyncratic noise tensor
is uncorrelated (white) across time. In this function, by default
are orthogonal matrices.
A tensor-valued time series of dimension .
set.seed(333) dims <- c(16,18,20) # dimensions of tensor time series r <- c(3,3,3) # dimensions of factor series Ft <- tenAR.sim(t=100, dim=r, R=1, P=1, rho=0.9, cov='iid') lambda <- sqrt(prod(dims)) # generate t*dims tensor time series with iid error covaraince structure x <- tenFM.sim(Ft,dims=dims,lambda=lambda,A=NULL,cov='iid') # generate t*dims tensor time series with separable error covaraince structure x <- tenFM.sim(Ft,dims=dims,lambda=lambda,A=NULL,cov='separable',rho=0.2)
set.seed(333) dims <- c(16,18,20) # dimensions of tensor time series r <- c(3,3,3) # dimensions of factor series Ft <- tenAR.sim(t=100, dim=r, R=1, P=1, rho=0.9, cov='iid') lambda <- sqrt(prod(dims)) # generate t*dims tensor time series with iid error covaraince structure x <- tenFM.sim(Ft,dims=dims,lambda=lambda,A=NULL,cov='iid') # generate t*dims tensor time series with separable error covaraince structure x <- tenFM.sim(Ft,dims=dims,lambda=lambda,A=NULL,cov='separable',rho=0.2)