Plot3dMedian: Plot Three-dimensional Medians

View source: R/Plot3dMedian.R

Plot3dMedianR Documentation

Plot Three-dimensional Medians

Description

This function plots multivariate medians in the three-dimensional case. The grey dots presented in the figure are the data points and the Spatial, Component-wise (CWmed), Tukey's, Liu's, Projection medians as well as the mean value of the data set are plotted in the figure. Oja's median is no longer used, as the package used to compute it has been archived from CRAN.

Usage

Plot3dMedian(data, xvec, yvec, zvec, yamm.nprojs = 2000,
             PmedMCInt.nprojs = 20000, no.subinterval = c(18,36),
             opt.method = "BFGS", xlab = "Component1", 
             ylab = "Component2", zlab = "Component3")

Arguments

data

The data as a matrix or data frame, with each row being viewed as one multivariate observation.

xvec

A numeric vector containing the maximum and minimum values you desire for the x-axis.

yvec

A numeric vector containing the maximum and minimum values you desire for the y-axis.

zvec

A numeric vector containing the maximum and minimum values you desire for the z-axis.

yamm.nprojs

The number of projections for the dataset when computing yamm. The default value is 2000.

PmedMCInt.nprojs

The number of projections for the dataset when computing PmedMCInt. The default value is 20000, since PmedMCInt requires large number of projections while doing the Monte Carlo integration to ensure accuracy.

no.subinterval

A numeric vector of two entries which represents the number of subintervals chosen while using the trapezoidal rule to approximate the projection median with PmedTrapz function. The default vector is c(36,36). Note small values (e.g. less than 10) for each entry of no.subinterval should not be used, to safeguard accuracy.

opt.method

The method chosen for the optimiser when computing the yamm, with default function “BFGS”. optim is used to minimise the objective function yamm.obj. Apart from BFGS, other functions in optim like “Nelder-Mead”, “CG”, “L-BFGS-B”, and “SANN” can also be used.

xlab

Title for x-axis. Must be a character string.

ylab

Title for y-axis. Must be a character string.

zlab

Title for z-axis. Must be a character string.

Details

The Spatial median is obtained using L1median in the Rpackage robustX. The Component-wise (CWmed), and Tukey's median are produced using function med in the Rpackage depth. Oja's median is no longer computed here. Liu's median is not available in higher dimensions (>2), so it is not shown here. When computing the projection median, three approximations are implemented and diplayed in the plot, where PmedMCInt uses Monte Carlo method, PmedTrapz is computed by the trapezoidal rule, and yamm uses an optimiser.

The argument xvec, yvec and zvec are useful when there are outliers in the dataset, which are not expected to be shown in the figure in some cases. Determining the x-axis y-axis, and z-axis allows you to zoom in the plot and see the difference between multivariate medians and mean value.

References

Chen, F. and Nason, Guy P. (2020) A new method for computing the projection medi an, its influence curve and techniques for the production of projected quantile plots. PLOS One, doi: 10.1371/journal.pone.0229845

See Also

PmedMCInt, PmedTrapz yamm, yamm.obj, optim.

Examples

# Load a data frame with 105 rows and 3 columns.
# The last five rows of the data are the outliers.
data(clusters3d)
#
# Remove the outliers of the dataset.
cluster_without_outlier <- clusters3d[c(1:100),]
myxvec <- c(min(cluster_without_outlier[,1]), 
          max(cluster_without_outlier[,1]))
myyvec <- c(min(cluster_without_outlier[,2]), 
          max(cluster_without_outlier[,2]))
myzvec <- c(min(cluster_without_outlier[,3]), 
          max(cluster_without_outlier[,3]))
#
# Plot the figure.
set.seed(15)
Plot3dMedian(cluster_without_outlier, myxvec, myyvec, myzvec, 
             yamm.nprojs = 2000, PmedMCInt.nprojs = 15000, 
             no.subinterval = c(18,36),opt.method = "BFGS",
             xlab = "Component1",ylab = "Component2", 
             zlab = "Component3")

Yamm documentation built on May 20, 2022, 5:06 p.m.