4. Principal component analysis of histogram data

library(HistDAWass)

The principal component analysis (PCA) of histogram data is based on the quantile functions: each histogram is represented by a set of its quantiles, and a PCA of the quantiles is consistent with the L2 Wasserstein distance (Verde, Irpino and Balzanella, 2016). The results are shown by “Spanish-fan” plots of the quantiles and by plotting the histograms on the factorial planes.

We use the BLOOD data (14 groups of patients, three histogram variables).

PCA of one histogram variable

WH.1d.PCA() analyses a single variable. By default it draws, for each factorial plane, four plots: the quantiles (Spanish-fan plot), the individuals, and the individuals coloured by their mean and by their standard deviation.

pca1 <- WH.1d.PCA(BLOOD, var = 1, quantiles = 10, listaxes = c(1, 2))

The results of FactoMineR::PCA() are in PCAout:

round(head(pca1$PCAout$eig, 3), 2)
#>        eigenvalue percentage of variance cumulative percentage of variance
#> comp 1     365.43                  90.38                             90.38
#> comp 2      29.92                   7.40                             97.78
#> comp 3       6.59                   1.63                             99.41
round(head(pca1$PCAout$ind$coord[, 1:2]), 3)
#>            Dim.1 Dim.2
#> u1: F-20 -29.335 4.203
#> u2: F-30 -29.001 4.072
#> u3: F-40 -15.411 2.853
#> u4: F-50   5.048 4.858
#> u5: F-60  12.434 3.239
#> u6: F-70  12.078 2.363

The first axis is mainly related to the position (the mean) of the histograms, the second one to their variability: the supplementary variables vmeans and vstds (means and standard deviations of the histograms) show it.

round(pca1$PCAout$quanti.sup$cor[, 1:2], 3)
#>        Dim.1 Dim.2
#> vmeans 0.999 0.011
#> vstds  0.140 0.896

outl removes a share of the probability from the tails of each histogram (e.g. outl = 0.05 removes 5% from each tail), to reduce the effect of outlying values.

PCA of several histogram variables

WH.MultiplePCA() analyses several variables together: it is a multiple factor analysis (FactoMineR::MFA()) where each variable is a group of quantiles.

mpca <- WH.MultiplePCA(BLOOD, list.of.vars = 1:3, quantiles = 10, graph = FALSE)
round(head(mpca$eig, 3), 2)
#>        eigenvalue percentage of variance cumulative percentage of variance
#> comp 1       2.27                  68.97                             68.97
#> comp 2       0.71                  21.44                             90.40
#> comp 3       0.16                   4.79                             95.19

The Spanish-fan plot of the quantiles of all the variables on the first plane (correlations with the axes):

WH.plot_multiple_Spanish.funs(mpca, axes = c(1, 2), var = 1:3)

The histograms of a variable, for each individual, plotted at the coordinates of the individuals on the first factorial plane (each histogram is centred on its mean). A second plot colours the histograms by a statistic (here the mean):

WH.plot_multiple_indivs(BLOOD, mpca, axes = c(1, 2), var = 1,
                        HISTO = TRUE, stat = "mean")

The histograms are measured on the scale of the variable, while the plane has the scale of the principal components, so their size is set automatically: by default the average width of the histograms is one tenth of the range of the coordinates on the x axis (strx = 0.1) and the highest density is one eighth of the range on the y axis (stry = 1/8). All the histograms share the same scales, so their spreads and their densities remain comparable. Larger or smaller values zoom the histograms:

WH.plot_multiple_indivs(BLOOD, mpca, axes = c(1, 2), var = 2,
                        strx = 0.15, stry = 0.2, HISTO = FALSE)

With HISTO = FALSE smoothed densities are drawn instead of histograms.

Reference

Verde, R., Irpino, A., Balzanella, A. (2016) Dimension reduction techniques for distributional symbolic data. IEEE Transactions on Cybernetics, 46(2), 344-355. https://doi.org/10.1109/TCYB.2015.2389653