# fdepth: Compute functional depth. In rainbow: Bagplots, Boxplots and Rainbow Plots for Functional Data

## Description

Compute functional depth.

## Usage

 `1` ```fdepth(data, type = c("FM", "mode", "RP", "RPD", "radius"), trim = 0.25, alpha, weight) ```

## Arguments

 `data` An object of class `fds` or `fts`. `type` Type of functional depth. See detail section below. `trim` Percentage of trimming. `alpha` Tuning parameter used when `type = "radius"`. `weight` Hard-thresholding or soft-thresholding when `type = "radius"`.

## Details

If `type = "FM"`, it computes the functional depth of Fraiman and Muniz (2001), which is considered as the first functional depth.

If `type = "mode"`, it computes the functional depth of Cuevas et al. (2006). A functional mode is defined as the curve most densely surrounded by the rest of curves of the dataset.

If `type = "RP"` and `type = "RPD"`, it computes random projection functional depth of Cuevas et al. (2007). Cuevas et al. (2007) considered the random projection depth based on measuring the depth of the functional data under projections and taking additional information of their derivatives. The basic idea is to project each functional curve, along a random direction, defining a point in R^2. A data depth in R^2 provides an order of the projected points.

If `type = "radius"`, it ranks the curves according to alpha-radius. Then using the hard thresholding or soft thresholding, trimmed mean and median can be computed.

The argument trim = 0.25 first order curves by depth, and then trim 25 percent curves that have comparably lower depth.

## Value

A list containing the following components is returned.

 `median` Median curve (highest depth). `lmed` Index of median curve. `ltrim` Indexes of the trimmed curves. `prof` Functional depth for each curve. `mtrim` Mean of trimmed curves. `weight` Weight values for all observations, when `type = "radius"`.

Han Lin Shang

## References

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

A. Cuevas and M. Febrero and R. Fraiman (2001) "Cluster Analysis:a further approach based on density estimation", Computational Statistics \& Data Analysis, 36(4), 441-456.

A. Cuevas and M. Febrero and R. Fraiman (2006) "On the use of bootstrap for estimating functions with functional data", Computational Statistics \& Data Analysis, 51(10), 1063-1074.

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

M. Febrero and P. Galeano and W. Gonzalez-Manteiga (2007) "A functional analysis of NOx levels: location and scale estimation and outlier detection", Computational Statistics, 22(3), 411-427.

M. Febrero and P. Galeano and W. Gonzalez-Manteiga (2008) "Outlier detection in functional data by depth measures, with application to identify abnormal NOx levels", Environmetrics, 19(4), 331-345.

M. Febrero and P. Galeano and W. Gonzalez-Manteiga (2010) "Measures of influence for the functional linear model with scalar response", Journal of Multivariate Analysis, 101(2), 327-339.

J. A. Cuesta-Albertos and A. Nieto-Reyes (2010) "Functional classification and the random Tukey depth. Practical issues", Combining Soft Computing and Statistical Methods in Data Analysis, Advances in Intelligent and Soft Computing, Volume 77, 123-130.

D. Gervini (2012) "Outlier detection and trimmed estimation in general functional spaces", Statistica Sinica, 22(4), 1639-1660.

P. Rana, G. Aneiros and J. M. Vilar (2015) "Detection of outliers in functional time series", Environmetrics, 26, 178-191.

## Examples

 ```1 2 3 4 5 6 7 8``` ```fdepth(data = ElNino_OISST_region_1and2, type = "FM") fdepth(data = ElNino_OISST_region_1and2, type = "mode") fdepth(data = ElNino_OISST_region_1and2, type = "RP") fdepth(data = ElNino_OISST_region_1and2, type = "RPD") fdepth(data = ElNino_OISST_region_1and2, type = "radius", trim = 0.25, alpha = 0.5, weight = "hard") fdepth(data = ElNino_OISST_region_1and2, type = "radius", trim = 0.25, alpha = 0.5, weight = "soft") ```

### Example output

```Loading required package: MASS
\$data
Sliced functional time series
y: Sea surface temperature (region 1 and 2)
x: Month

\$output
\$output\$median
1     2     3     4     5     6     7     8     9    10    11    12
24.02 25.88 26.16 25.22 24.05 22.68 21.00 20.25 20.13 20.28 20.84 22.45

\$output\$lmed
[1] 9

\$output\$mtrim
1        2        3        4        5        6        7        8
24.36036 26.04821 26.51857 25.45179 24.12786 22.72607 21.47321 20.54571
9       10       11       12
20.27357 20.71107 21.55679 22.73571

\$output\$ltrim
[1]  1  3  5  8  9 10 11 12 13 14 18 19 20 21 22 23 24 25 27 28 29 30 31 32 33
[26] 35 36 37

\$output\$prof
[1] 0.6959459 0.5833333 0.8738739 0.6531532 0.8333333 0.6193694 0.6734234
[8] 0.8693694 0.9166667 0.8445946 0.7927928 0.8018018 0.7747748 0.8085586
[15] 0.6441441 0.5833333 0.6463964 0.7139640 0.8400901 0.7454955 0.7770270
[22] 0.8040541 0.8220721 0.8085586 0.7409910 0.6036036 0.7972973 0.8243243
[29] 0.7252252 0.8310811 0.7747748 0.7747748 0.6981982 0.6238739 0.7680180
[36] 0.6959459 0.7770270

attr(,"class")
[1] "fdepth"
\$data
Sliced functional time series
y: Sea surface temperature (region 1 and 2)
x: Month

\$output
\$output\$median
1     2     3     4     5     6     7     8     9    10    11    12
24.02 25.88 26.16 25.22 24.05 22.68 21.00 20.25 20.13 20.28 20.84 22.45

\$output\$lmed
[1] 9

\$output\$mtrim
1        2        3        4        5        6        7        8
24.26036 25.91929 26.38000 25.23500 23.89357 22.54357 21.28607 20.38321
9       10       11       12
20.14286 20.57321 21.37750 22.58429

\$output\$ltrim
[1]  3  4  5  7  8  9 10 12 13 14 15 18 19 20 21 22 23 24 25 27 28 29 30 31 32
[26] 33 35 37

\$output\$prof
[1] 0.111647998 0.001834854 0.940182657 0.640444706 0.867396602 0.319487604
[7] 0.693442263 0.955519788 1.000000000 0.831931275 0.434793285 0.744622990
[13] 0.703615288 0.834738552 0.649881460 0.000000000 0.027978730 0.788490733
[19] 0.917900346 0.663635460 0.665925169 0.791907553 0.846285900 0.853910747
[25] 0.537129843 0.411261473 0.675271248 0.711968908 0.566575187 0.763135437
[31] 0.547976714 0.840739418 0.437473570 0.062144370 0.637656164 0.348636596
[37] 0.806284085

attr(,"class")
[1] "fdepth"
\$data
Sliced functional time series
y: Sea surface temperature (region 1 and 2)
x: Month

\$output
\$output\$median
1     2     3     4     5     6     7     8     9    10    11    12
24.02 25.88 26.16 25.22 24.05 22.68 21.00 20.25 20.13 20.28 20.84 22.45

\$output\$lmed
[1] 9

\$output\$mtrim
[,1]   [,2]     [,3]     [,4]     [,5]     [,6]     [,7]     [,8]
[1,] 24.39 26.095 26.60214 25.49321 24.16107 22.72036 21.49071 20.53964
[,9]    [,10]    [,11]    [,12]
[1,] 20.27143 20.70714 21.50536 22.65214

\$output\$ltrim
[1]  3  5  6  7  8  9 10 11 12 13 14 18 19 20 21 22 23 24 25 27 28 30 31 32 33
[26] 35 36 37

\$output\$prof
[1] 0.13336742 0.08821037 0.23035793 0.15850986 0.20723156 0.16078890
[7] 0.16137327 0.22870709 0.24336012 0.22831264 0.17088386 0.22674945
[13] 0.17982469 0.20083272 0.14509861 0.07335281 0.12523009 0.18901388
[19] 0.22334551 0.17910884 0.21171658 0.17301680 0.19332359 0.20638422
[25] 0.17490139 0.11554419 0.20929145 0.21485756 0.15479912 0.20419284
[31] 0.17382031 0.18629657 0.18113952 0.11009496 0.21117604 0.18045289
[37] 0.22100804

attr(,"class")
[1] "fdepth"
\$data
Sliced functional time series
y: Sea surface temperature (region 1 and 2)
x: Month

\$output
\$output\$median
1     2     3     4     5     6     7     8     9    10    11    12
23.86 25.97 26.51 24.99 24.37 23.05 22.05 21.08 20.75 21.13 22.18 23.43

\$output\$lmed
[1] 10

\$output\$mtrim
1        2        3        4        5        6        7        8
24.32286 26.04607 26.52893 25.42679 24.03750 22.60143 21.33286 20.42179
9       10       11       12
20.17036 20.63643 21.41679 22.60750

\$output\$ltrim
[1]  3  5  6  7  8  9 10 11 12 13 14 15 18 19 20 21 22 23 24 25 27 28 29 30 31
[26] 32 35 37

\$output\$prof
[1] 0.1395740 0.1132193 0.1923433 0.1450846 0.2201140 0.1725318 0.1877776
[8] 0.2047299 0.2253251 0.2320915 0.1652327 0.2238747 0.1714527 0.1932906
[15] 0.1657788 0.1009817 0.1213315 0.1908967 0.1966285 0.1685034 0.1925367
[22] 0.1884660 0.1938247 0.1958624 0.1898121 0.1493756 0.2031126 0.2129081
[29] 0.1864660 0.1953026 0.1779243 0.1924383 0.1559495 0.1378814 0.1939047
[36] 0.1639302 0.2152257

attr(,"class")
[1] "fdepth"
There were 50 or more warnings (use warnings() to see the first 50)
\$data
Sliced functional time series
y: Sea surface temperature (region 1 and 2)
x: Month

\$output
\$output\$median
1     2     3     4     5     6     7     8     9    10    11    12
24.09 25.91 26.21 25.16 23.77 22.43 21.12 20.17 20.07 20.52 21.31 22.45

\$output\$mtrim
1        2        3        4        5        6        7        8
24.24074 25.93852 26.39926 25.23519 23.83148 22.47074 21.22333 20.32667
9       10       11       12
20.10000 20.53741 21.34222 22.57259

\$output\$weight
[1] 0 0 1 1 1 0 1 1 1 1 0 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 0 0 1 0 1

attr(,"class")
[1] "fdepth"
\$data
Sliced functional time series
y: Sea surface temperature (region 1 and 2)
x: Month

\$output
\$output\$median
1      2      3      4      5      6      7      8      9     10     11
24.085 25.845 26.175 25.075 23.595 22.340 21.150 20.210 20.100 20.445 21.405
12
22.595

\$output\$mtrim
1        2        3        4        5        6        7        8
24.23444 25.90676 26.36121 25.16211 23.77865 22.42795 21.21342 20.33110
9       10       11       12
20.10942 20.56903 21.38289 22.63033

\$output\$weight
[1] 0.00000000 0.00000000 1.00000000 1.00000000 1.00000000 0.00000000
[7] 0.67883442 1.00000000 1.00000000 1.00000000 0.00000000 1.00000000
[13] 1.00000000 1.00000000 0.82034628 0.00000000 0.00000000 1.00000000
[19] 1.00000000 0.35980100 1.00000000 0.52026533 1.00000000 1.00000000
[25] 0.21260340 0.00000000 0.99155035 0.92963892 0.09383452 1.00000000
[31] 0.01865635 1.00000000 0.00000000 0.00000000 1.00000000 0.00000000
[37] 1.00000000

attr(,"class")
[1] "fdepth"
```

rainbow documentation built on May 2, 2019, 3:30 p.m.