Description Usage Arguments Details Value Examples
View source: R/distance-depth.R
Calculates a localized distance-based depth vector using a distance matrix. Specifically we alter Geenens & Nieto-Reyes's global distance-based depth to a local depth similar to Agostinelli & Romanazzi (2011) localized approach, and define our local distance-based depth as:
1 2 3 4 5 6 7 | local_distance_depth_function(x, x_new = NULL, tau = Inf, df_out = "auto")
## S3 method for class 'matrix'
local_distance_depth_function(x, x_new = NULL, tau = Inf, df_out = F)
## S3 method for class 'tidy_dist_mat'
local_distance_depth_function(x, x_new = NULL, tau = Inf, df_out = T)
|
x |
a n x n square positive symmetric matrix or a tidy_dist_mat |
x_new |
a n_new x n matrix or tidy_dist_mat where the rows correspond to
new observations, the columns correspond to points in |
tau |
localizing parameter (default is Inf) Can either by a standard numerical value or a string as a percentage (e.g. "20%") |
df_out |
indicates if one should return a data.frame our a vector, by default returns data.frame if dist_mat is a tidy_dist_mat, and a vector if dist_mat is a matrix. |
LDD(x, \hat{P}, τ) = 1/(|S| choose 2) \cdot ∑_{i!=j, i,j \in S} I(d(X_i, X_j) > max(d(X_i,x), d(X_j,x)))
where S = {i : D(X_i,x) < τ}.
Note that if |S| = 1, then we say that LDD(x) = 0
.
This matrix function (renamed as depth_function
) is shared
with TCpredictionbands on github:
TCpredictionbands.
depth vector length n with depth values associated with indices in
dist_mat
or a data.frame with a column called local_depth
depth vector length n with depth values associated with indices in
dist_mat
1 2 3 4 5 6 7 8 9 10 11 12 13 | ## matrix-only examples
dist_mat <- matrix(c(0, 1, 1.5,
1, 0, 2,
1.5, 2, 0 ),
nrow = 3,
byrow = TRUE)
dd_vec <- local_distance_depth_function(dist_mat) # c(1,0,0)
ldd_vec1 <- local_distance_depth_function(dist_mat, tau = 2) # c(1,0,0)
ldd_vec2 <- local_distance_depth_function(dist_mat, tau = 1.5) # c(1,0,0)
ldd_vec3 <- local_distance_depth_function(dist_mat, tau = 1) # c(0,0,0)
ldd_vec <- local_distance_depth_function(dist_mat, tau = .1) # c(0,0,0)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.