# How to find quantiles for multivariate data using R?

Quantile for a single variable is easy to implement in R. However, it is not an easy task to quantile for multivariate data. There are several papers have been proposed to quantile for multivariate data such as Chaudhuri, P (1996), On a geometric notion of quantiles for multivariate data, Journal of the American Statistical Association 91, 862-872. The existing approaching is not easy to implement. Is there any R package can do quantiles for multivariate data? many thanks in advance

## locked by whuber♦Nov 16 '18 at 18:32

This question exists because it has historical significance, but it is not considered a good, on-topic question for this site so please do not use it as evidence that you can ask similar questions here. This question and its answers are frozen and cannot be changed. See the help center for guidance on writing a good question.

• Some of the methods used to identify multivariate outliers can be adapted to ranking the data (often by identifying "outliers", removing them, and iterating). You might therefore have some interest in reviewing our thread at stats.stackexchange.com/questions/213/…. – whuber Feb 17 '12 at 18:32
• Several different methods of calculating multivariate quantiles, as well as some related plotting methods, are given in the documentation for R's depth plot package (pdf). – ritwik33 Nov 16 '18 at 17:48

I would try here (mvnormtest, mvoutlier, mvtnorm): http://cran.r-project.org/web/views/Multivariate.html

Why don't you try my package cepp. It can compute PC's quantiles for you!

http://cran.r-project.org/web/packages/cepp/index.html

You need the function $evaluator$ in this package. It takes two arguments which correspond to the number of rows and columns in the data. It returns a function which can be optimized to get the spatial quantiles.

For a minimal example, see this snippet from the package documentation.

x <- rnorm(500)
dim(x) <- c(250,2)
ev <- evaluator(250,2)
##The Spatial Median
trust(ev, parinit=c(median(x[1,]), median(x[2,])), u=c(0,0),
rinit=0.5, rmax=2e5, samp = x)
##Quantile for vector (0.2,0.3)
trust(ev, parinit=c(median(x[1,]), median(x[2,])), u=c(0.2,0.3),
rinit=0.5, rmax=2e5, samp = x)

• Would it be possible to give a short code example or perhaps show what function you refer to? – Rasmus Bååth Nov 9 '14 at 23:07

You need to compute the CDF of the joint distribution f(x1,x2,...,xn). The CDF will give you the quantiles you seek.