Skip to contents

Plot method for objects of class 'ppgmmga'.

Usage

# S3 method for ppgmmga
plot(x, 
     class = NULL, 
     dim = seq(x$d), 
     drawAxis = TRUE, 
     bins = nclass.numpy,
     ...)

Arguments

x

An object of class 'ppgmmga' obtained from a call to ppgmmga function.

class

A numeric or character vector indicating the classification of the observations/cases to be plotted.

dim

A numeric vector indicating the dimensions to use for plotting. By default, all the dimensions of the projection subspace (i.e. x$d) are used. Subsets of all the available dimensions can also be provided (see example below.)
The resulting graph depends on the dimension: in the 1D case a histogram is provided, a scatterplot in the 2D case, a scatterplot matrix in higher dimensions.

drawAxis

A logical value specifying whether or not the axes should be included in the 2D scatterplot. By default is to TRUE.

bins

An R function to be used for computing the number of classes for the histogram. By default nclass.Sturges is used. Users may provide a different function. This argument only applies to 1D graphs.

...

further arguments.

Details

Plots the cloud of points onto a subspace after appling the Projection Pursuit algorithm based on Gaussian mixtures and Genetic algorithm implemented in ppgmmga function.

Value

Returns a object of class ggplot.

Author

Serafini A. srf.alessio@gmail.com
Scrucca L. luca.scrucca@unipg.it

References

Scrucca, L. and Serafini, A. (2019) Projection pursuit based on Gaussian mixtures and evolutionary algorithms. Journal of Computational and Graphical Statistics, 28:4, 847–860. DOI: 10.1080/10618600.2019.1598871

See also

Examples

if (FALSE) {
data(iris)
X <- iris[,-5]
Class <- iris$Species

# 1D
pp1 <- ppgmmga(data = X, d = 1, approx = "UT")
summary(pp1, check = TRUE)
plot(pp1)
plot(pp1, Class)

# 2D
pp2 <- ppgmmga(data = X, d = 2, approx = "UT")
summary(pp2, check = TRUE)
plot(pp2)
plot(pp2, Class)

# 3D
pp3 <- ppgmmga(data = X, d = 3)
summary(pp3, check = TRUE)
plot(pp3)
plot(pp3, Class)
plot(pp3, Class, dim = c(1,3))
plot(pp3, Class, dim = c(2,3))
}