Title: | Test the Kronecker Product Structure in Tensor Factor Models |
---|---|
Description: | To test if a tensor time series following a Tucker-decomposition factor model has a Kronecker product structure. Supplementary functions for tensor reshape and its reversal are also included. |
Authors: | Zetai Cen [aut, cre] |
Maintainer: | Zetai Cen <[email protected]> |
License: | GPL-3 |
Version: | 0.1.1 |
Built: | 2025-01-09 05:44:57 UTC |
Source: | https://github.com/cran/KOFM |
Generating all possible divisor combination of certain length for a given positive integer.
divisors(x, d)
divisors(x, d)
x |
A positive integer. |
d |
A vector of positive integers whose length is the length of divisor combination and each value sets the maximum of each divisor. |
A matrix with each row representing a divisor combination.
divisors(6, c(20,20));
divisors(6, c(20,20));
Performing tensor reshape on a given tensor.
ten_reshape(ten, AA, time.mode = TRUE)
ten_reshape(ten, AA, time.mode = TRUE)
ten |
An array representing a tensor. |
AA |
A vector representing mode indices to reshape along. |
time.mode |
Logical. TRUE if mode-1 of the input tensor is the time mode and hence not involved in reshape; otherwise reshape is on the entire input tensor. Default is TRUE. |
An array representing a reshaped tensor.
ten_reshape(array(1:24, dim=c(2,3,4)), c(2,3), FALSE);
ten_reshape(array(1:24, dim=c(2,3,4)), c(2,3), FALSE);
Performing reversed tensor reshape on a given tensor.
ten_reshape_back(ten, AA, original.dim, time.mode = TRUE)
ten_reshape_back(ten, AA, original.dim, time.mode = TRUE)
ten |
An array representing a tensor. |
AA |
A vector representing mode indices to reshape along back. |
original.dim |
A vector representing the dimension of the original tensor before reshape. |
time.mode |
Logical. TRUE if mode-1 of the input tensor is the time mode and hence not involved in reshape; otherwise reshape is on the entire input tensor. Default is TRUE. |
An array representing a tensor.
ten_reshape_back(array(1:24, dim=c(2,12)), c(2,3), c(2,3,4), FALSE);
ten_reshape_back(array(1:24, dim=c(2,12)), c(2,3), c(2,3,4), FALSE);
Testing the Kronecker product structure of a tensor time series with a specified set of mode indices.
testKron_A(ten, AA, r, alpha = c(0.01, 0.05), q = 0.05, r.exact = FALSE)
testKron_A(ten, AA, r, alpha = c(0.01, 0.05), q = 0.05, r.exact = FALSE)
ten |
An array representing an order-(K+1) tensor which is an order-K tensor time series with mode-1 being the time mode. |
AA |
A vector with elements at least 1 and at most K, representing the tensor modes to test. |
r |
A vector representing the rank for 'ten'. |
alpha |
A vector representing the desired significance levels. Default is c(0.01, 0.05). |
q |
A number between 0 and 1, representing the quantile for the decision statistic. Default is 0.05. |
r.exact |
Logical. Perform the test only using 'r' if TRUE, otherwise using all divisor combinations of the last mode rank of the reshaped data. Default is FALSE. |
A list containing the following: level: a matrix with each entry reporting an example test size, corresponding to its rank used (row) and level of alpha (column); the alpha is reported in order of parameter 'alpha'. decision: a matrix with each entry reporting the decision statistic aggregated by quantile of parameter 'q', corresponding to its rank used (row) and level of alpha (column); the alpha is reported in order of parameter 'alpha'. rank: a matrix with K columns and each row represents a different rank used, corresponding to the rows in the 'level' and 'decision' matrices.
Testing the Kronecker product structure of a tensor time series without a specified set of mode indices.
testKron_auto( ten, r = 0, alpha = c(0.01, 0.05), q = 0.05, r.exact = FALSE, all = FALSE )
testKron_auto( ten, r = 0, alpha = c(0.01, 0.05), q = 0.05, r.exact = FALSE, all = FALSE )
ten |
An array representing an order-(K+1) tensor which is an order-K tensor time series with mode-1 being the time mode. |
r |
A vector representing the rank for 'ten'. |
alpha |
A vector representing the desired significance levels. Default is c(0.01, 0.05). |
q |
A number between 0 and 1, representing the quantile for the decision statistic. Default is 0.05. |
r.exact |
Logical. Perform the test only using 'r' if TRUE, otherwise using all divisor combinations of the last mode rank of the reshaped data. Default is FALSE. |
all |
Logical. when TRUE, all sets of mode indices are tested; otherwise each reshaped data using leave-one-out sets is sequentially tested. Default is FALSE. |
A list containing the following: decision: a data frame with each row reporting the decision rule aggregated by quantile of parameter 'q' for different levels of alpha; the first column represents all non-trivial sets of mode indices to test if 'all' is TRUE, otherwise represents each mode to identify. level: a data frame with each row reporting an example test size aggregated by quantile of parameter 'q' for different levels of alpha; the first column represents all non-trivial sets of mode indices to test if 'all' is TRUE, otherwise represents each mode to identify. rank: a vector of integers representing either the input rank or the estimated rank used in testing.