tensorVectorize {tensorBSS}R Documentation

Vectorize an Observation Tensor

Description

Vectorizes an array of array-valued observations into a matrix so that each column of the matrix corresponds to a single observational unit.

Usage

tensorVectorize(x)

Arguments

x

Array of an order at least two with the last dimension corresponding to the sampling units.

Details

Vectorizes a p_1 \times p_2 \times \ldots \times p_r \times n-dimensional array into a p_1 p_2 \ldots p_r \times n-dimensional matrix, each column of which then corresponds to a single observational unit. The vectorization is done so that the rth index goes through its cycle the fastest and the first index the slowest.

Note that the output is a matrix of the size "number of variables" x "number of observations", that is, a transpose of the standard format for a data matrix.

Value

Matrix whose columns contain the vectorized observed tensors.

Author(s)

Joni Virta

Examples

# Generate sample data.
n <- 100
x <- t(cbind(rnorm(n, mean = 0),
             rnorm(n, mean = 1),
             rnorm(n, mean = 2),
             rnorm(n, mean = 3),
             rnorm(n, mean = 4),
             rnorm(n, mean = 5)))
             
dim(x) <- c(3, 2, n)

# Matrix of vectorized observations.
vecx <- tensorVectorize(x)

# The covariance matrix of individual tensor elements
cov(t(vecx))

[Package tensorBSS version 0.3.8 Index]