Skip to contents

Several depth measures can be computed for functional data for descriptive or classification purposes.

Usage

depth.mode(
  fdataobj,
  fdataori = fdataobj,
  trim = 0.25,
  metric = metric.lp,
  h = NULL,
  scale = FALSE,
  draw = FALSE,
  ...
)

depth.RP(
  fdataobj,
  fdataori = fdataobj,
  trim = 0.25,
  nproj = 50,
  proj = "vexponential",
  dfunc = "TD1",
  par.dfunc = list(),
  scale = FALSE,
  draw = FALSE,
  ...
)

depth.RPD(
  fdataobj,
  fdataori = fdataobj,
  nproj = 20,
  proj = 1,
  deriv = c(0, 1),
  trim = 0.25,
  dfunc2 = mdepth.LD,
  method = "fmm",
  draw = FALSE,
  ...
)

depth.RT(
  fdataobj,
  fdataori = fdataobj,
  trim = 0.25,
  nproj = 10,
  proj = 1,
  xeps = 1e-07,
  draw = FALSE,
  ...
)

depth.KFSD(
  fdataobj,
  fdataori = fdataobj,
  trim = 0.25,
  h = NULL,
  scale = FALSE,
  draw = FALSE
)

depth.FSD(
  fdataobj,
  fdataori = fdataobj,
  trim = 0.25,
  scale = FALSE,
  draw = FALSE
)

depth.FM(
  fdataobj,
  fdataori = fdataobj,
  trim = 0.25,
  scale = FALSE,
  dfunc = "FM1",
  par.dfunc = list(scale = TRUE),
  draw = FALSE
)

Arguments

fdataobj

The set of new curves to evaluate the depth. fdata class object.

fdataori

The set of reference curves respect to which the depth is computed. fdata class object.

trim

The alpha of the trimming.

metric

Metric function, by default metric.lp. Distance matrix between fdataobj and fdataori.

h

Bandwidth, h>0. Default argument values are provided as the 15%–quantile of the distance between x and xx.

scale

=TRUE, the depth is scaled respect to depths in fdataori.

draw

=TRUE, draw the curves, the sample median and trimmed mean.

...

Further arguments passed to or from other methods. For depth.mode parameters for metric. For random projection depths, parameters to be included in rproc2fdata not included before.

nproj

The number of projections. Ignored if a fdata class object is provided in proj

proj

if a fdata class, projections provided by the user. Otherwise, it is the sigma parameter of rproc2fdata function.

dfunc

type of univariate depth function used inside depth function: "FM1" refers to the original Fraiman and Muniz univariate depth (default), "TD1" Tukey (Halfspace),"Liu1" for simplical depth, "LD1" for Likelihood depth and "MhD1" for Mahalanobis 1D depth. Also, any user function fulfilling the following pattern FUN.USER(x,xx,...) and returning a dep component can be included.f

par.dfunc

List of parameters for dfunc.

deriv

Number of derivatives described in integer vector deriv. =0 means no derivative.

dfunc2

Multivariate depth function (second step depth function) in RPD depth, by default mdepth.LD. Any user function with the pattern FUN.USER(x,xx,...) can be employed.

method

Type of derivative method. See fdata.deriv for more details.

  • numeric: the procedure considers the argument value as the bandwidth.

  • NULL: (by default) the bandwidth is provided as the 15%–quantile of the distance among curves of fdataori.

  • character: a string (like "0.15"), the procedure reads the numeric value and consider it as the quantile of the distance in fdataori (as in the second case).

xeps

Accuracy. The left limit of the empirical distribution function.

Value

Return a list with:

  • median: Deepest curve.

  • lmed: Index deepest element median.

  • mtrim: fdata class object with the average from the (1-trim)% deepest curves.

  • ltrim: Indexes of curves that conform the trimmed mean mtrim.

  • dep: Depth of each curve of fdataobj w.r.t. fdataori.

  • dep.ori: Depth of each curve of fdataori w.r.t. fdataori.

  • proj: The projection value of each point on the curves.

  • dist: Distance matrix between curves or functional data.

Details

Type of depth functions: Fraiman and Muniz (FM) depth, modal depth, random Tukey (RT), random projection (RP) depth and double random projection depth (RPD).

  • depth.FM: computes the integration of an univariate depth along the axis x (see Fraiman and Muniz 2001). It is also known as Integrated Depth.

  • depth.mode: implements the modal depth (see Cuevas et al 2007).

  • depth.RT: implements the Random Tukey depth (see Cuesta–Albertos and Nieto–Reyes 2008).

  • depth.RP: computes the Random Projection depth (see Cuevas et al. 2007).

  • depth.RPD: implements a depth measure based on random projections possibly using several derivatives (see Cuevas et al. 2007).

  • depth.FSD: computes the Functional Spatial Depth (see Sguera et al. 2014).

  • depth.KFSD: implements the Kernelized Functional Spatial Depth (see Sguera et al. 2014).

  • depth.mode: calculates the depth of a datum accounting the number of curves in its neighbourhood. By default, the distance is calculated using metric.lp function although any other distance could be employed through argument metric (with the general pattern
    USER.DIST(fdataobj,fdataori)).

  • depth.RP: summarizes the random projections through averages whereas the depth.RT function uses the minimum of all projections.

  • depth.RPD: involves the original trajectories and the derivatives of each curve in two steps. It builds random projections for the function and their derivatives (indicated in the parameter deriv) and then applies a depth function (by default depth.mode) to this set of random projections (by default the Tukey one).

  • depth.FSD and depth.KFSD: are the implementations of the default versions of the functional spatial depths proposed in Sguera et al 2014. At this moment, it is not possible to change the kernel in the second one.

References

Cuevas, A., Febrero-Bande, M., Fraiman, R. (2007). Robust estimation and classification for functional data via projection-based depth notions. Computational Statistics 22, 3, 481-496.

Fraiman R, Muniz G. (2001). Trimmed means for functional data. Test 10: 419-440.

Cuesta–Albertos, JA, Nieto–Reyes, A. (2008) The Random Tukey Depth. Computational Statistics and Data Analysis Vol. 52, Issue 11, 4979-4988.

Febrero-Bande, M, Oviedo de la Fuente, M. (2012). Statistical Computing in Functional Data Analysis: The R Package fda.usc. Journal of Statistical Software, 51(4), 1-28. https://www.jstatsoft.org/v51/i04/

Sguera C, Galeano P, Lillo R (2014). Spatial depth based classification for functional data. TEST 23(4):725–750.

See also

See Also as Descriptive.

Author

Manuel Febrero-Bande, Manuel Oviedo de la Fuente manuel.oviedo@udc.es

Examples

if (FALSE) { # \dontrun{
#Ex: CanadianWeather data
tt=1:365
fdataobj<-fdata(t(CanadianWeather$dailyAv[,,1]),tt)
# Fraiman-Muniz Depth
out.FM=depth.FM(fdataobj,trim=0.1,draw=TRUE)
#Modal Depth
out.mode=depth.mode(fdataobj,trim=0.1,draw=TRUE)
out.RP=depth.RP(fdataobj,trim=0.1,draw=TRUE)
out.RT=depth.RT(fdataobj,trim=0.1,draw=TRUE)
out.FSD=depth.FSD(fdataobj,trim=0.1,draw=TRUE)
out.KFSD=depth.KFSD(fdataobj,trim=0.1,draw=TRUE)
## Double Random Projections
out.RPD=depth.RPD(fdataobj,deriv=c(0,1),dfunc2=mdepth.LD,
trim=0.1,draw=TRUE)
out<-c(out.FM$mtrim,out.mode$mtrim,out.RP$mtrim,out.RPD$mtrim)
plot(fdataobj,col="grey")
lines(out)
cdep<-cbind(out.FM$dep,out.mode$dep,out.RP$dep,out.RT$dep,out.FSD$dep,out.KFSD$dep)
colnames(cdep)<-c("FM","mode","RP","RT","FSD","KFSD")
pairs(cdep)
round(cor(cdep),2)
} # }