tensorCentering: Center an Array of Observations

Description Usage Arguments Details Value Author(s) Examples

View source: R/tensorCentering.R

Description

Centers an array of array-valued observations by substracting a location array (the mean array by default) from each observation.

Usage

1
tensorCentering(x, location = NULL)

Arguments

x

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

location

The location to be used in the centering. Either NULL, defaulting to the mean array, or a user-specified p_1 x p_2 x ... x p_r-dimensional array.

Details

Centers a p_1 x p_2 x ... x p_r x n-dimensional array by substracting the p_1 x p_2 x ... x p_r-dimensional location from each of the observed arrays.

Value

Array of centered observations with the same dimensions as the input array. The used location is returned as attribute "location".

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 <- 1000
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)

## Centered data
xcen <- tensorCentering(x)

## Check the means of individual cells
apply(xcen, 1:2, mean)

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