Description Usage Arguments Details Value Author(s) References See Also Examples
The function evaluates the depth and the local depth for a set of points with respect to a dataset.
1 2 3 4 5 |
x |
numeric; vector, dataframe or matrix. If |
y |
numeric; vector, dataframe or matrix with the same number of
columns as |
tau |
numeric; threshold value for the evaluation of the local
depth. Use function |
use |
character; the statistic used to measure the size of the
objects. Currently, for |
method |
character; the type of (local) depth to be evaluated |
type |
character; how to evaluate membership. Only active for
|
nsamp |
character or numeric; the number of objects that are
considered. If |
nmax |
numeric; maximum fraction (in the range (0,1]) of objects
to be considered when |
tol |
numeric; tolerance parameter to be fixed depending on the machine precision. Used to decide membership of points located near to the boundary of the objects |
dimension |
numeric; only used with |
location |
|
covariance |
|
With method="simplicial"
and type="exact"
, membership of
the points in simplices is evaluated; when type="approx"
,
an approximate membership function is used. See references below.
With method="hyperspheresimplicial"
the data matrix are normalize
to have vectors of length one, then the (local) angular simplicial depth
is evaluated.
The function returns an object of class
localdepth
with the following components:
localdepth |
vector of the local depth values for the given |
depth |
vector of the depth values |
max.localdepth |
|
max.depth |
|
num |
vector with two components. |
call |
match.call() result. Note that this is called from the internal function |
tau |
value of the corresponding input parameter |
use |
value of the corresponding input parameter |
tol |
value of the corresponding input parameter |
x |
value of the corresponding input parameter |
y |
value of the corresponding input parameter |
type |
value of the corresponding input parameter |
nsamp |
value of the corresponding input parameter |
method |
value of the corresponding input parameter |
Claudio Agostinelli and Mario Romanazzi
C. Agostinelli and M. Romanazzi (2007). Local depth of univariate distributions. Working paper n. 1/2007, Dipartimento di Statistica, Universita' Ca' Foscari, Venezia.
C. Agostinelli and M. Romanazzi (2008). Local depth of multidimensional data. Working paper n. 3/2008, Dipartimento di Statistica, Universita' Ca' Foscari, Venezia.
C. Agostinelli and M. Romanazzi (2011). Local depth. Journal of Statistical Planning and Inference, 141:817-830. doi:10.1016/j.jspi.2010.08.001.
C. Agostinelli e M. Romanazzi (2013). Nonparametric analysis of directional data based on data depth. Environmental and Ecological Statistics, 20(2):253-270. doi:10.1007/s10651-012-0218-z.
quantile.localdepth
, plot.localdepth
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | # Iris Setosa dataset
data(iris)
setosa <- iris[iris$Species=="setosa",-5]
str(setosa)
n <- dim(setosa)[1];p <- dim(setosa)[2]
lab <- paste("U",1:n,sep="")
pairs(setosa)
# Wiggling data with gaussian error
set.seed(1234)
err <- matrix(c(rnorm(n,0,sd(setosa[,1])/1000),
rnorm(n,0,sd(setosa[,2])/1000),
rnorm(n,0,sd(setosa[,3])/1000),
rnorm(n,0,sd(setosa[,4])/1000)),n,p,byrow=FALSE)
setosa1 <- setosa + as.data.frame(err)
## Not run:
qd <- quantile.localdepth(setosa1, probs=c(seq(0.01,0.09,0.01),
seq(0.1,0.9,0.1)), use="diameter", method="simplicial", nsamp="all", size=TRUE)
qv <- quantile.localdepth(setosa1, probs=c(seq(0.01,0.09,0.01),
seq(0.1,0.9,0.1)), use="volume", method="simplicial", nsamp="all",size=TRUE)
## End(Not run)
## Here we explore 10% of simplices (0.1*choose(50,4+1))
qd <- quantile.localdepth(setosa1,
probs=c(seq(0.01,0.09,0.01),seq(0.1,0.9,0.1)),
use="diameter", method="simplicial", nsamp=211876, size=TRUE)
qv <- quantile.localdepth(setosa1,
probs=c(seq(0.01,0.09,0.01),seq(0.1,0.9,0.1)),
use="volume", method="simplicial", nsamp=211876,size=TRUE)
c(mean(qd$stats),median(qd$stats))
c(mean(qv$stats),median(qv$stats))
round(qd$quantile,2)
round(qv$quantile,8)
boxplot(qd$stats,names="Diameter",xlab="Simplex Size",
horizontal=TRUE,main="Iris Setosa")
boxplot(qv$stats,names="Volume",xlab="Simplex Size",
horizontal=TRUE,main="Iris Setosa")
plot(qd$stats,qv$stats,xlab="Simplex Diameter",
ylab="Simplex Volume", main="Iris Setosa",pch=20)
# Simplicial global/local depth
sldv10 <- localdepth(setosa1,tau=qv$quantile[10],use="volume",
method="simplicial", type="approx", nsamp="all", nmax=0.2)
str(sldv10)
sd10 <- sldv10$depth # simplicial depth
sld10 <- sldv10$localdepth # simplicial local depth (volume, 10%)
lab[sd10 == (p+1)/n] # convex hull vertices (25 points out of 50)
sdmax <- max(sd10);imax <- which.max(sd10);setosa[imax,] # deepest point
# DD-Plot
plot(sldv10, xlab="Simplicial Depth",
ylab="Local Simplicial Depth", main="Iris Setosa",pch=20,ylim=c(0,1.02))
abline(a=0,b=1,lty="dashed")
## Not run:
# Mahalanobis Depth of Iris Versicolor wrt Iris Setosa
iversicolor <- iris[iris$Species == "versicolor",-5]
str(iversicolor)
set.seed(2345)
err <- matrix(c(rnorm(n,0,sd(iversicolor[,1])/1000),
rnorm(n,0,sd(iversicolor[,2])/1000),
rnorm(n,0,sd(iversicolor[,3])/1000),
rnorm(n,0,sd(iversicolor[,4])/1000)), n,p,byrow=FALSE)
iversicolor1 <- iversicolor + as.data.frame(err)
qm <- quantile.localdepth(setosa1,
probs=c(seq(0.01,0.09,0.01),seq(0.1,0.9,0.1)),
method="mahalanobis",nsamp="all",size=TRUE)
round(qm$quantile,2)
vers <- localdepth(x=setosa1, y=iversicolor1, tau=qm$quantile[10],
method="mahalanobis", nsamp="all")
str(vers)
round(vers$depth,6)
round(vers$localdepth,6) # identically zero
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.