# Compute and plot some halfspace depth contours of a two-dimensional dataset.
# The returned object is a ggplot2 object that may be edited
# using standard ggplot2 commands.
# One may consider different depth functions such as projection depth
# by changing the input parameter 'type'.
# By default the halfspace depth is used.
data(bloodfat)
Result <- depthContour(x = bloodfat,
alpha = c(0.03, 0.125, 0.25))
plotContours(x = bloodfat, depthContour = Result)
# Other options are projection depth, skewness-adjusted projection depth
# and directional projection depth
# they can be used by specifying type to be
# "projdepth", "sprojdepth" or "dprojdepth" respectively.
# When there is skewness in the data projection depth
# is less appropriate.
Result <- depthContour(x = bloodfat,
alpha = c(0.25, 0.35, 0.45),
type = "projdepth")
plotContours(x = bloodfat, depthContour = Result)
# The skewness-adjusted projection depth and directional projection depth
# better reflect the skewness in the data.
Result <- depthContour(x = bloodfat,
alpha = c(0.35, 0.45, 0.55),
type = "sprojdepth")
plotContours(x = bloodfat, depthContour = Result)
Result <- depthContour(x = bloodfat,
alpha = c(0.25, 0.35, 0.45),
type = "dprojdepth")
plotContours(x = bloodfat, depthContour = Result)
Run the code above in your browser using DataLab