Package 'KOFM'

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

Help Index


Divisor combination generator

Description

Generating all possible divisor combination of certain length for a given positive integer.

Usage

divisors(x, d)

Arguments

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.

Value

A matrix with each row representing a divisor combination.

Examples

divisors(6, c(20,20));

Tensor reshape

Description

Performing tensor reshape on a given tensor.

Usage

ten_reshape(ten, AA, time.mode = TRUE)

Arguments

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.

Value

An array representing a reshaped tensor.

Examples

ten_reshape(array(1:24, dim=c(2,3,4)), c(2,3), FALSE);

Tensor reshape reversal

Description

Performing reversed tensor reshape on a given tensor.

Usage

ten_reshape_back(ten, AA, original.dim, time.mode = TRUE)

Arguments

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.

Value

An array representing a tensor.

Examples

ten_reshape_back(array(1:24, dim=c(2,12)), c(2,3), c(2,3,4), FALSE);

Testing Kronecker product structure along specified modes

Description

Testing the Kronecker product structure of a tensor time series with a specified set of mode indices.

Usage

testKron_A(ten, AA, r, alpha = c(0.01, 0.05), q = 0.05, r.exact = FALSE)

Arguments

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.

Value

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 Kronecker product structure without specified modes

Description

Testing the Kronecker product structure of a tensor time series without a specified set of mode indices.

Usage

testKron_auto(
  ten,
  r = 0,
  alpha = c(0.01, 0.05),
  q = 0.05,
  r.exact = FALSE,
  all = FALSE
)

Arguments

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.

Value

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.