Description Usage Arguments Details Value Note Author(s) Examples
Fiber-center across the levels of the specified mode. Can input 2-way, 3-way, and 4-way arrays, or input a list containing array elements.
1 |
X |
Array (2-way, 3-way, or 4-way) or a list containing array elements. |
mode |
Mode to center across. |
With X
a matrix (I-by-J) there are two options:
mode=1: | x[i,j] - mean(x[,j]) |
|
mode=2: | x[i,j] - mean(x[i,]) |
|
With X
a 3-way array (I-by-J-by-K) there are three options:
mode=1: | x[i,j,k] - mean(x[,j,k]) |
|
mode=2: | x[i,j,k] - mean(x[i,,k]) |
|
mode=3: | x[i,j,k] - mean(x[i,j,]) |
|
With X
a 4-way array (I-by-J-by-K-by-L) there are four options:
mode=1: | x[i,j,k,l] - mean(x[,j,k,l]) |
|
mode=2: | x[i,j,k,l] - mean(x[i,,k,l]) |
|
mode=3: | x[i,j,k,l] - mean(x[i,j,,l]) |
|
mode=4: | x[i,j,k,l] - mean(x[i,j,k,]) |
|
Returns centered version of X
.
When entering a list with array elements, each element must be an array (2-way, 3-way, or 4-way) that contains the specified mode
to center across.
Nathaniel E. Helwig <helwig@umn.edu>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ########## EXAMPLE 1 ##########
X <- matrix(rnorm(2000),100,20)
Xc <- ncenter(X) # center across rows
sum(colSums(Xc))
Xc <- ncenter(Xc,mode=2) # recenter across columns
sum(colSums(Xc))
sum(rowSums(Xc))
########## EXAMPLE 2 ##########
X <- array(rnorm(20000),dim=c(100,20,10))
Xc <- ncenter(X,mode=2) # center across columns
sum(rowSums(Xc))
########## EXAMPLE 3 ##########
X <- array(rnorm(100000),dim=c(100,20,10,5))
Xc <- ncenter(X,mode=4) # center across 4-th mode
sum(rowSums(Xc))
########## EXAMPLE 4 ##########
X <- replicate(5,array(rnorm(20000),dim=c(100,20,10)),simplify=FALSE)
Xc <- ncenter(X)
sum(colSums(Xc[[1]]))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.