Learn R Programming

rrcov3way (version 0.1-10)

Tucker3: Robust Tucker3 estimator for compositional data

Description

Compute a robust Tucker3 model for compositional data

Usage

Tucker3(X, P = 2, Q = 2, R = 2, conv = 1e-06, 
    center = FALSE, scale = FALSE, scale.mode = c("B", "A", "C"), 
    robust = FALSE, ilr = FALSE, ncomp.rpca = 2, alpha = 0.75, 
    maxiter=100, crit=0.975, trace = FALSE)

Arguments

X

3-way array of data

P

Number of A-mode components

Q

Number of B-mode components

R

Number of C-mode components

conv

Convergence criterion, defaults to 1e-6

center

Whether to center the data

scale

Whether to scale the data

scale.mode

If centering and/or scaling the data, on which mode to do this

robust

Whether to apply a robust estimation

ilr

If the data are a composition, use an ilr transformation

ncomp.rpca

Number of components for robust PCA

alpha

Measures the fraction of outliers the algorithm should resist. Allowed values are between 0.5 and 1 and the default is 0.75

maxiter

Maximal number of iterations

crit

Cut-off for identifying outliers, default crit=0.975

trace

Logical, provide trace output

Value

An object of class "tucker3" which is basically a list with components:

fit

Fit value

fp

Fit percentage

A

Orthogonal loading matrix for the A-mode

B

Orthogonal loading matrix for the B-mode

Bclr

Orthogonal loading matrix for the B-mode, clr transformed. Available only if ilr=TRUE (default), otherwise NULL

C

Orthogonal loading matrix for the C-mode

GA

Core matrix, which describes the relation between A, B and C, unfolded in A-form. The largest squared elements of the core matrix indicate the most important factors in the model of X.

iter

Number of iterations

RD

Residual distances

flag

The observations whose residual distance RD is larger than cutoff.RD can be considered as outliers and receive a flag equal to zero. The regular observations receive a flag 1

Details

The function can compute four versions of the Tucker3 model:

  1. Classical Tucker3,

  2. Tucker3 for compositional data,

  3. Robust Tucker3 and

  4. Robust Tucker3 for compositional data.

This is controlled through the parameters robust=TRUE and ilr=TRUE.

References

Tucker, L.R. (1966). Some mathematical notes on three-mode factor analysis. Psychometrika, 31: 279--311.

Egozcue J.J., Pawlowsky-Glahn, V., Mateu-Figueras G. and Barcel'o-Vidal, C. (2003). Isometric logratio transformations for compositional data analysis. Mathematical Geology, 35(3): 279--300.

Examples

Run this code
# NOT RUN {
##
## The Bus data from package ThreeWay
##
data(Bus)       # from ThreeWay: 7x5x37, unfolded to 7x185
dim(Bus)

## Preprocessing
##
max.scale <- c(47, 10, 10, 15, 15)
maxBus <- rep(max.scale, 37)
BusN <- t(t(Bus)/maxBus)

## Use toArray to turn to a 3-way array
##
X <- toArray(BusN, 7, 5, 37)
dimnames(X) <- list(dimnames(Bus)[[1]], 
                    substr(dimnames(Bus)[[2]][1:5], 1, 1), 
                    substr(dimnames(Bus)[[2]][seq(1, ncol(Bus), 5)], 3, 8))
dimnames(X)

## Perform classical Tucker3 (non-robust option and no
##  ilr transformation for compositional data)
res <- Tucker3(X, robust=FALSE, ilr=FALSE)

## Distance-distance plot
plot(res, which="dd", main="Distance-distance plot")

## Paired component plot, mode A
plot(res, which="comp", main="Paired component plot (mode A)")

## Paired component plot, mode B
plot(res, which="comp", mode="B", main="Paired component plot (mode B)")

## Joint biplot
plot(res, which="jbplot", main="Joint biplot")

## Trajectory plot
plot(res, which="tjplot", main="Trajectory biplot")


#############
##
## Example with the UNIDO Manufacturing value added data

data(va3way)
dim(va3way)

## Treat quickly and dirty the zeros in the data set (if any)
va3way[va3way==0] <- 0.001

##
res <- Tucker3(va3way)
res
print(res$fit)
print(res$A)

## Print the core matrix
print(res$GA)

## Distance-distance plot
plot(res, which="dd", main="Distance-distance plot")

## Paired component plot, mode A
plot(res, which="comp", main="Paired component plot (mode A)")

## Paired component plot, mode B
plot(res, which="comp", mode="B", main="Paired component plot (mode B)")

## Joint biplot
plot(res, which="jbplot", main="Joint biplot")

## Trajectory
plot(res, which="tjplot", main="Trajectory biplot")

# }

Run the code above in your browser using DataLab