| dd_plot | R Documentation |
Computes and plots the depth-depth (DD) plot for two samples. Each
observation from both samples is assigned two depth values — its depth
with respect to the empirical distribution of x and its depth
with respect to the empirical distribution of y. Points from the
same distribution cluster near the main diagonal.
dd_plot(
x,
y,
depth_fn = simplicial_depth,
plot = TRUE,
xlab = "Depth wrt X",
ylab = "Depth wrt Y",
main = "DD-Plot",
col_x = "steelblue",
col_y = "firebrick",
pch_x = 19L,
pch_y = 17L,
legend = TRUE,
...
)
x |
Numeric matrix (n1 x d) — first sample. |
y |
Numeric matrix (n2 x d) — second sample. Must have the same
number of columns as |
depth_fn |
Depth function to use. Must have signature
|
plot |
Logical. If |
xlab |
Label for the x-axis. Defaults to "Depth wrt X". |
ylab |
Label for the y-axis. Defaults to "Depth wrt Y". |
main |
Plot title. Defaults to "DD-Plot". |
col_x |
Color for points from |
col_y |
Color for points from |
pch_x |
Plot character for points from |
pch_y |
Plot character for points from |
legend |
Logical. If |
... |
Additional arguments passed to |
The DD-plot was introduced by Liu, Parelius & Singh (1999) as a nonparametric graphical tool for two-sample comparison. It is the multivariate analog of the QQ-plot, using depth in place of quantiles.
If the two distributions are identical, all points should fall near the diagonal. Systematic deviations indicate location shifts (points above or below the diagonal) or scale/shape differences (spread of points away from the diagonal).
Invisibly returns a data frame with columns:
Depth of each observation with respect to x.
Depth of each observation with respect to y.
Factor indicating which sample the observation came from.
Liu, R. Y., Parelius, J. M. & Singh, K. (1999). Multivariate analysis by data depth: descriptive statistics, graphics and inference. Annals of Statistics, 27(3), 783–858.
set.seed(42)
# Same distribution — points near diagonal
x <- matrix(rnorm(200), nrow = 100, ncol = 2)
y <- matrix(rnorm(200), nrow = 100, ncol = 2)
dd_plot(x, y, depth_fn = simplicial_depth)
# Location shift — points systematically off diagonal
y_shift <- matrix(rnorm(200, mean = 1), nrow = 100, ncol = 2)
dd_plot(x, y_shift, depth_fn = tukey_depth)
# Store results without plotting
result <- dd_plot(x, y, plot = FALSE)
head(result)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.