Last data update: 2014.03.03

R: GmedianCov
GmedianCovR Documentation

GmedianCov

Description

Computes recursively the Geometric median and the (geometric) median covariation matrix with fast averaged stochastic gradient algorithms. The estimation of the Geometric median is performed first and then the median covariation matrix is estimated, as well as its leading eigenvectors. The original recursive estimator of the median covariation matrix may not be a non negative matrix. A fast projected estimator onto the convex closed cone of the non negative matrices allows to get a non negative solution.

Usage

GmedianCov(X, init=NULL, nn=TRUE, scores=2, gamma=2, gc=2, alpha=0.75, nstart=1)

Arguments

X

Data matrix, with n observations (rows) in dimension d (columns).

init

When NULL the starting point of the algorithm estimating the median is the first observation.

nn

When TRUE the algorithm provides a non negative estimates of the median covariation matrix. When nn=FALSE, the original algorithm is performed, with no guaranty that all the eigenvalues of the estimates are non negative

scores

An integer q, by default q=2. The function computes the eigenvectors of the median covariation matrix associated to the q largest eigenvalues and the corresponding principal component scores. No output if scores=NULL.

gamma

Value (positive) of the constant controling the descent steps (see details) for the algorithm computing median.

gc

Value (positive) of the constant controling the descent steps (see details) for algorithm computing the median covariation matrix

alpha

Rate of decrease of the descent steps, 1/2 < alpha <=1.

nstart

Number of time the algorithms are ran.

Details

The (fast) computation of the eigenvectors is performed by eigs_sym of package RSpectra. See the technical report Cardot, H. and Godichon-Baggioni (2015) for more details on the recursive algorithm. See also Gmedian. When nn=TRUE, the descent step is bounded above so that the solution remains non negative at each iteration. The principal components standard deviation is estimed robustly thanks to function scaleTau2 from package robustbase.

Value

median

Vector of the geometric median

covmedian

Median covariation matrix

vectors

The scores=q eigenvectors of the median covariation matrix associated to the q largest eigenvalues

scores

Principal component scores corresponding to the scores=q eigenvectors

sdev

The scores=q estimates of the standard deviation of the scores=q principal components.

References

Cardot, H., Cenac, P. and Zitt, P-A. (2013). Efficient and fast estimation of the geometric median in Hilbert spaces with an averaged stochastic gradient algorithm. Bernoulli, 19, 18-43.

Cardot, H. and Godichon-Baggioni, A. (2015). Fast Estimation of the Median Covariation Matrix with Application to Online Robust Principal Components Analysis. http://arxiv.org/abs/1504.02852

See Also

See also Gmedian and WeiszfeldCov.

Examples

## Simulated data - Brownian paths
n <- 1e3
d <- 50
x <- matrix(rnorm(n*d,sd=1/sqrt(d)), n, d)
x <- t(apply(x,1,cumsum))

## Estimation
median.est <- GmedianCov(x)

par(mfrow=c(1,2))
image(median.est$covmedian) ## median covariation function
plot(c(1:d)/d,median.est$vectors[,1]*sqrt(d),type="l",xlab="Time",
ylab="Eigenvectors",ylim=c(-1.4,1.4))
lines(c(1:d)/d,median.est$vectors[,2]*sqrt(d),lty=2)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(Gmedian)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/Gmedian/GmedianCov.Rd_%03d_medium.png", width=480, height=480)
> ### Name: GmedianCov
> ### Title: GmedianCov
> ### Aliases: GmedianCov
> ### Keywords: Gmedian
> 
> ### ** Examples
> 
> ## Simulated data - Brownian paths
> n <- 1e3
> d <- 50
> x <- matrix(rnorm(n*d,sd=1/sqrt(d)), n, d)
> x <- t(apply(x,1,cumsum))
> 
> ## Estimation
> median.est <- GmedianCov(x)
> 
> par(mfrow=c(1,2))
> image(median.est$covmedian) ## median covariation function
> plot(c(1:d)/d,median.est$vectors[,1]*sqrt(d),type="l",xlab="Time",
+ ylab="Eigenvectors",ylim=c(-1.4,1.4))
> lines(c(1:d)/d,median.est$vectors[,2]*sqrt(d),lty=2)
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>