Plot2dMedian | R Documentation |
This function plots various multivariate medians in the two-dimensional case. The grey dots presented in the figure are the data points and the Spatial, Component-wise (CWmed), Tukey's, Liu's, Projection median 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 produce this function has been archived
Plot2dMedian(data, xvec, yvec, yamm.nprojs = 2000, PmedMCInt.nprojs = 20000, no.subinterval = 36, opt.method = "BFGS", xlab = "Component1", ylab = "Component2")
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. |
yamm.nprojs |
The number of projections for the dataset when computing |
PmedMCInt.nprojs |
The number of projections for the dataset when computing |
no.subinterval |
The number of subintervals while using the trapezoidal rule to approximate the projection median with |
opt.method |
The method chosen for the optimiser when computing the |
xlab |
Title for x-axis. Must be a character string. |
ylab |
Title for y-axis. Must be a character string. |
The Spatial median is obtained using L1median
in the Rpackage robustX. The Component-wise (CWmed), Liu's and Tukey's median are produced using function med
in the Rpackage depth. Oja's median is NO LONGER produced using function ojaMedian
in the Rpackage OjaNP
,
as this package has been archived.
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
and yvec
are useful when there are outliers in the data set, which are not expected to be shown in the figure in some cases. Determining the x-axis and y-axis allows you to zoom in the plot and see the difference between multivariate medians and mean value.
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
PmedTrapz
,
PmedMCInt
,
yamm
,
yamm.obj
,
optim
.
# Load a data frame with 103 rows and 2 columns. # The last two rows of the data are the outliers. data(clusters2d) # # Remove the outliers of the dataset. cluster_without_outlier <- clusters2d[c(1:101),] myxvec <- c(min(cluster_without_outlier[,1]), max(cluster_without_outlier[,1])) myyvec <- c(min(cluster_without_outlier[,2]), max(cluster_without_outlier[,2])) # # Plot the figure. set.seed(5) Plot2dMedian(clusters2d, myxvec, myyvec, yamm.nprojs = 2000, PmedMCInt.nprojs = 20000, no.subinterval = 36, opt.method = "BFGS", xlab = "Component1", ylab = "Component2")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.