makeplot: Plot Two-dimensional Quantile

View source: R/makeplot.R

makeplotR Documentation

Plot Two-dimensional Quantile

Description

This function calls muqie for multiple values of quantiles from 0.5 to 0.95 and then produces a set of plots with these quantiles for producing an animated GIF using package animation.

Usage

makeplot(xdata, dm=c(1,2), nsegs=20,
         quantile.increment= 0.001, 
         nprojs=2000, reltol=0.001)

Arguments

xdata

The data as a matrix or dataframe with the number of columns greater than or equal to two, with each row being viewed as one multivariate observation.

dm

A numeric vector with two entries representing the selected columns of the data considered. The default value is c(1,2), which means the first two columns of data are chosen if the dimension of data is greater than two.

nsegs

The number of the unit-length direction vectors u, which is computed by dividing a unit circle into nsegs equal sectors.

quantile.increment

A numeric value specifies the increment of the set of different quantiles.

nprojs

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

reltol

The tolerance of the optimisation process in the function yamm. The default value is 0.001.

Value

This function returns a set of plots with various specified quantiles.

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

yamm muqie

Examples


# 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),]
#
# Produce an animation of a set of multivariate quantile plots.

if (requireNamespace("animation"))	{

library("animation")
# Generate temporary file
f <- tempfile(fileext=".gif")
#
# Now generate movie into the temporary file.
# Here nprojs=40: for a real example, for production quality you should increase
# it to 1000, 2000 or even higher
#
# Here quantile.increment=0.1, for production quality this should be reduced to
# e.g. 0.01, of even smaller
#
saveGIF(makeplot(cluster_without_outlier, nprojs=40, quantile.increment=0.1), 
diff.col=3, interval=0.1,width=500, height=500, movie.name=f)
cat("Movie saved to: ", f, "\n")
}

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