Center an Array of Observations

Description

Centers an array of array-valued observations by substracting the mean array from each observation.

Usage

1

Arguments

x

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

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 array of element-wise means from each of the observed arrays.

Value

Array of centered observations with the same dimensions as the input array.

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)