tensorVectorize: Vectorize an Observation Tensor

Description Usage Arguments Details Value Author(s) Examples

View source: R/tensorVectorize.R

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

1

Arguments

x

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

Details

Vectorizes a p_1 x p_2 x ... x p_r x n-dimensional array into a p_1 p_2 ... p_r x 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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# 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))

tensorBSS documentation built on June 2, 2021, 9:08 a.m.