Maf.data.frame: Generalised diagonalisations Calculate several generalized...

View source: R/genDiag.R

MafR Documentation

Generalised diagonalisations Calculate several generalized diagonalisations out of a data set and its empirical variogram

Description

Generalised diagonalisations Calculate several generalized diagonalisations out of a data set and its empirical variogram

Usage

Maf(x, ...)

## S3 method for class 'data.frame'
Maf(x, vg, i = 2, ...)

## S3 method for class 'rmult'
Maf(x, vg, i = 2, ...)

## S3 method for class 'aplus'
Maf(x, vg, i = 2, ...)

## S3 method for class 'rplus'
Maf(x, vg, i = 2, ...)

## S3 method for class 'ccomp'
Maf(x, vg, i = 2, ...)

## S3 method for class 'rcomp'
Maf(x, vg, i = 2, ...)

## S3 method for class 'acomp'
Maf(x, vg, i = 2, ...)

UWEDGE(x, ...)

## Default S3 method:
UWEDGE(x, ...)

## S3 method for class 'acomp'
UWEDGE(x, vg, i = NULL, ...)

## S3 method for class 'rcomp'
UWEDGE(x, vg, i = NULL, ...)

RJD(x, ...)

## Default S3 method:
RJD(x, ...)

## S3 method for class 'acomp'
RJD(x, vg, i = NULL, ...)

## S3 method for class 'rcomp'
RJD(x, vg, i = NULL, ...)

Arguments

x

a data set, typically of class "data.frame" or of a compositional class

...

generic functionality arguments

vg

empirical variogram, of a kind fitting to the data provided

i

a slicer for the variogram, typically this will be one or more indices of the lag distance to take. %For other options see codegetEmpVariogramSlice.

Value

An object extending c("princomp.CLASSOF(x)","princomp") with classes "genDiag", and an extra class argument depending on the diagonalisation method chosen.

Function Maf results carry the extra class "maf", and they correspond to minimum/maximum autocorrelation factors (MAF) as proposed by Switzer and Green (1984). In this case, the slicer is typically just the index of one lag distance (defaults to i=2). MAF provides the analytical solution to the joint diagonalisation of two matrices, the covariance of increments provided by the slicing and the conventional covariance matrix (of the idt transformed values, if appropriate). Resulting factors are ordered in decreasing order of spatial continuity, which might produce surprising scree-plots for those who are used to see a screeplot of a principal component analysis.

Function UWEDGE (Uniformly Weighted Exhaustive Diagonalization with Gauss iterations; Tichavsky and Yeredor, 2009) results carry the extra class "uwedge". The function is a wrapper on jointDiag::uwedge from package jointDiag (Gouy-Pailler, 2017). In this case the slicer is typically just a subset of indices of lag distances to consider (defaults to the nearest indexes to mininum, maximum and mean lag distances of the variogram). UWEDGE iteratively seeks for a pair of matrices (a mixing and a demixing matrices) diagonalises the set of matrices M_1, M_2, \ldots, M_K given, by minimizing the target quantity

Q_{uwedge}(A, W) = \sum_{k=1}^K Tr[E_k^t\cdot E_k],

where E_k = (W^t\cdot M_k \cdot W- A\cdot \Lambda_k\cdot A^t) and \Lambda_k = diag(W^t\cdot M_k \cdot W) is the resulting diagonalized version of each matrix. Obtained factors are ordered in decreasing order of spatial continuity, which might produce surprising scree-plots for those who are used to see a screeplot of a principal component analysis.

Function RJD results carry the extra class "rjd". The function is a wrapper on JADE::rjd (Miettinen, Nordhausen and Taskinen, 2017), implementing the Rotational joint diagonalisation method (Cardoso and Souloumiac, 1996). In this case the slicer is typically just a subset of indices of lag distances to consider (defaults to the nearest indexes to mininum, maximum and mean lag distances). This algorithm also served for quasi-diagonalising a set of matrices as in UWEDGE, just that in this case the quantity to minimise is the sum of sequares of all off-diagonal elements of A^t\cdot M_k\cdot A for all k=1, 2, \ldots K.

All these functions produce output mimicking princomp, i.e. with elements

sdev

contrary to the output in PCA, this contains the square root of the metric variance of the predictions obtained for each individual factor; this is the quantity needed for screeplot to create plots of explained variance by factor

loadings

matrix of contributions of each (cdt-transformed) original variable to the new factors

center

center of the data set (eventually, represented through cdt), in compositional methods

scale

the scalings applied to each original variable

n.obs

number of observations

scores

the scores of the supplied data on the new factors

call

the call to the function (attention: it actually may come much later)

and additionally some of the following arguments, in different order

invLoadings

matrix of contributions of each factor onto each original variable

Center

compositional methods return here the cdt-backtransformed center

InvLoadings

compositional methods return here the clr-backtransformed inverse loadings, so that each column of this matrix can be understood as a composition on itself

DownInvLoadings

compositional methods return here the clr-backtransformed "minus inverse loadings", so that each column of this matrix can be understood as a composition on itself; details in princomp.acomp

C1, C2

Maf returns the two matrices that were diagonalised

eigenvalues

Maf returns the generalized eigenvalues of the diagonalisation of C1 and C2

gof

UWEDGE returns the values of the goodness of fit criterion across sweeps

diagonalized

RJD returns the diagonalized matrices, in an array of (K,D,D)-dimensions, being D the number of variables in x

type

a string describing which package and which function was used as a workhorse for the calculation

NOTE: if the arguments you provide to RJD and UWEDGE are not of the appropriate type (i.e. data.frames or equivalent) the default method of these functions will just attempt to call the basis functions JADE:rjd and JointDiag:uwedge respectively. This will be the case if you provide x as a "matrix", or as an "array". In those cases, the output will NOT be structured as an extension to princomp results; instead they will be native output from those functions.

Functions

  • Maf: Generalised diagonalisations

  • Maf.rmult: Generalised diagonalisations

  • Maf.aplus: Generalised diagonalisations

  • Maf.rplus: Generalised diagonalisations

  • Maf.ccomp: Generalised diagonalisations

  • Maf.rcomp: Generalised diagonalisations

  • Maf.acomp: Generalised diagonalisations

  • UWEDGE: Generalised diagonalisations

  • UWEDGE.default: Generalised diagonalisations

  • UWEDGE.acomp: Generalised diagonalisations

  • UWEDGE.rcomp: Generalised diagonalisations

  • RJD: Generalised diagonalisations

  • RJD.default: Generalised diagonalisations

  • RJD.acomp: Generalised diagonalisations

  • RJD.rcomp: Generalised diagonalisations

References

Cardoso, J. K. and Souloumiac A. 1996. Jacobi angles for simultaneous diagonalization. SIAM Journal of Matrix Analysis and Applications 17(1), 161-164.

Gouy-Pailler C., 2017. jointDiag: Joint approximate diagonalization of a set of square matrices. R package version 0.3. https://CRAN.R-project.org/package=jointDiag

Miettinen J., Nordhausen K., and Taskinen, S., 2017. Blind source separation based on Joint diagonalization in R: The packages JADE and BSSasymp. Journal of Statistical Software 76(2), 1-31.

Switzer P. and Green A.A., 1984. Min/Max autocorrelation factors for multivariate spatial imaging, Stanford University, Palo Alto, USA, 14pp.

Tichavsky, P. and Yeredor, A., 2009. Fast approximate joint diagonalization incorporating weight matrices. IEEE Transactions on Signal Processing 57, 878 ??? 891.

See Also

Other generalised Diagonalisations: coloredBiplot.genDiag(), predict.genDiag()

Examples

require("magrittr")
require("gstat")
require("compositions")
data("jura", package="gstat")
gs = gstat(id="Cd", formula=log(Cd)~1, locations=~Xloc+Yloc, data=jura.pred) %>% 
gstat(id="Co", formula=log(Cd)~1, locations=~Xloc+Yloc, data=jura.pred) %>% 
gstat(id="Cr", formula=log(Cr)~1, locations=~Xloc+Yloc, data=jura.pred) %>% 
gstat(id="Cu", formula=log(Cu)~1, locations=~Xloc+Yloc, data=jura.pred) %>% 
gstat(id="Ni", formula=log(Ni)~1, locations=~Xloc+Yloc, data=jura.pred) %>% 
gstat(id="Pb", formula=log(Pb)~1, locations=~Xloc+Yloc, data=jura.pred) %>% 
gstat(id="Zn", formula=log(Zn)~1, locations=~Xloc+Yloc, data=jura.pred)
vg = variogram(gs)
mf = Maf(aplus(jura.pred[, -(1:6)]), vg=vg)
mf
mf$loadings
biplot(mf)

gmGeostats documentation built on April 18, 2023, 5:08 p.m.