plot.MFAmix: Graphical outputs of MFAmix

View source: R/plot.MFAmix.R

plot.MFAmixR Documentation

Graphical outputs of MFAmix

Description

Displays the graphical outputs of MFAmix. Individuals (observations), quantitative variables and levels of the qualitative variables are plotted as points using their factor coordinates (scores) in MFAmix. All the variables (quantitative and qualitative) are plotted on the same graph as points using their squared loadings. The groups of variables are plotted using their contributions to the component coordinates. Partial axes and partial individuals of separated analyses can also be plotted.

Usage

## S3 method for class 'MFAmix'
plot(
  x,
  axes = c(1, 2),
  choice = "ind",
  label = TRUE,
  coloring.var = "not",
  coloring.ind = NULL,
  nb.partial.axes = 3,
  col.ind = NULL,
  col.groups = NULL,
  partial = NULL,
  lim.cos2.plot = 0,
  lim.contrib.plot = 0,
  xlim = NULL,
  ylim = NULL,
  cex = 1,
  main = NULL,
  leg = TRUE,
  posleg = "topleft",
  cex.leg = 0.8,
  col.groups.sup = NULL,
  posleg.sup = "topright",
  nb.paxes.sup = 3,
  ...
)

Arguments

x

an object of class MFAmix obtained with the function MFAmix.

axes

a length 2 vector specifying the components to plot.

choice

the graph to plot:

  • "ind" for the individuals,

  • "cor" for the correlation circle of the quantitative variables,

  • "levels" for the levels of of the qualitative variables,

  • "sqload" for the plot of the squared loadings of all the variables,

  • "groups" for the plot of the contributions of the groups,

  • "axes" for the correlation circle of the partial axes.

label

boolean, if FALSE the labels of the points are not plotted.

coloring.var

a value to choose among:

  • "type": the variables in the plot of the squared loadings are colored according to their type (quantitative or qualitative),

  • "groups": the variables are colored according to their group.

  • NULL: variables are not colored.

coloring.ind

a qualitative variable such as a character vector or a factor of size n (the number of individuals). The individuals are colored according to the levels of this variable. If NULL, the individuals are not colored.

nb.partial.axes

f choice="axes", the maximum number of partial axes related to each group to plot on the correlation circle. By default equal to 3.

col.ind

a vector of colors, of size the number of levels of coloring.ind. If NULL, colors are chosen automatically.

col.groups

a vector of colors, of size the number of groups. If NULL, colors are chosen automatically.

partial

a vector of class character with the row names of the individuals, for which the partial individuals should be drawn. By default partial = NULL and no partial points are drawn. Partial points are colored according to col.groups

lim.cos2.plot

a value between 0 and 1. Points with squared cosinus below this value are not plotted.

lim.contrib.plot

a value between 0 and 100. Points with relative contributions (in percentage) below this value are not plotted.

xlim

a numeric vectors of length 2, giving the x coordinates range. If NULL (by default) the range is defined automatically (recommended).

ylim

a numeric vectors of length 2, giving the y coordinates range. If NULL (by default) the range is defined automatically (recommended).

cex

cf. function par in the graphics package

main

a string corresponding to the title of the graph to draw.

leg

boolean, if TRUE, a legend is displayed..

posleg

position of the legend.

cex.leg

a numerical value giving the amount by which the legend should be magnified. Default is 0.8.

col.groups.sup

a vector of colors, of size the number of supplementary groups. If NULL, colors are chosen automatically.

posleg.sup

position of the legend for the supplementary groups.

nb.paxes.sup

if choice="axes", the maximum number of partial axes of supplementary groups ploted on the correlation circle. By default equal to 3.

...

arguments to be passed to methods, such as graphical parameters.

Details

The observations can be colored according to the levels of a qualitative variable. The observations, the quantitative variables and the levels can be selected according to their squared cosine (lim.cos2.plot) or their relative contribution (lim.contrib.plot) to the component map. Only points with squared cosine or relative contribution greater than a given threshold are plotted. Note that the relative contribution of a point to the component map (a plan) is the sum of the absolute contributions to each dimension, divided by the sum of the corresponding eigenvalues.

Author(s)

, marie.chavent@u-bordeaux.fr, Amaury Labenne

References

Chavent M., Kuentz-Simonet V., Labenne A., Saracco J., Multivariate analysis of mixed data: The PCAmixdata R package, arXiv:1411.4911 [stat.CO].

See Also

summary.PCAmix,PCAmix,PCArot

Examples

data(gironde)
class.var<-c(rep(1,9),rep(2,5),rep(3,9),rep(4,4))
names <- c("employment","housing","services","environment")
dat <- cbind(gironde$employment[1:20,],gironde$housing[1:20,],
           gironde$services[1:20,],gironde$environment[1:20,])
res <- MFAmix(data=dat,groups=class.var,
            name.groups=names, rename.level=TRUE, ndim=3,graph=FALSE)

#---- quantitative variables
plot(res,choice="cor",cex=0.6)
plot(res,choice="cor",cex=0.6,coloring.var="groups")
plot(res,choice="cor",cex=0.6,coloring.var="groups",
     col.groups=c("red","yellow","pink","brown"),leg=TRUE)

#----partial axes
plot(res,choice="axes",cex=0.6)
plot(res,choice="axes",cex=0.6,coloring.var="groups")
plot(res,choice="axes",cex=0.6,coloring.var="groups",
     col.groups=c("red","yellow","pink","brown"),leg=TRUE)

#----groups
plot(res,choice="groups",cex=0.6)   #no colors for groups
plot(res,choice="groups",cex=0.6,coloring.var="groups") 
plot(res,choice="groups",cex=0.6,coloring.var="groups",
     col.groups=c("red","yellow","pink","blue")) 
#----squared loadings
plot(res,choice="sqload",cex=0.8)    #no colors for groups
plot(res,choice="sqload",cex=0.8,coloring.var="groups",
     posleg="topright") 
plot(res,choice="sqload",cex=0.6,coloring.var="groups",
     col.groups=c("red","yellow","pink","blue"),ylim=c(0,1)) 
plot(res,choice="sqload",cex=0.8,coloring.var="type",
     cex.leg=0.9,posleg="topright")  

#----individuals 
plot(res,choice="ind",cex=0.6) 

#----individuals with squared cosine greater than 0.5
plot(res,choice="ind",cex=0.6,lim.cos2.plot=0.5)  

#----individuals colored with a qualitative variable
nbchem <- gironde$services$chemist[1:20]
plot(res,choice="ind",cex=0.6,coloring.ind=nbchem,
     posleg="topright")   
plot(res,choice="ind",coloring.ind=nbchem,
     col.ind=c("pink","brown","darkblue"),label=FALSE,posleg="topright")     

#----partial individuals colored by groups
plot(res,choice="ind",partial=c("AUBIAC","ARCACHON"),
    cex=0.6,posleg="bottomright")

#----levels of qualitative variables
plot(res,choice="levels",cex=0.8)
plot(res,choice="levels",cex=0.8,coloring.var="groups")

#levels with squared cosine greater than 0.6
plot(res,choice="levels",cex=0.8, lim.cos2.plot=0.6)

#supplementary groups
data(wine)
X.quanti <- splitmix(wine)$X.quanti[,1:5]
X.quali <- splitmix(wine)$X.quali[,1,drop=FALSE]
X.quanti.sup <- splitmix(wine)$X.quanti[,28:29]
X.quali.sup <- splitmix(wine)$X.quali[,2,drop=FALSE]
data <- cbind(X.quanti,X.quali)
data.sup <- cbind(X.quanti.sup,X.quali.sup)

groups <-c(1,2,2,3,3,1)
name.groups <- c("G1","G2","G3")
groups.sup <- c(1,1,2)
name.groups.sup <- c("Gsup1","Gsup2")
mfa <- MFAmix(data,groups,name.groups,ndim=4,rename.level=TRUE,graph=FALSE)
mfa.sup <- supvar(mfa,data.sup,groups.sup,name.groups.sup,rename.level=TRUE)
plot(mfa.sup,choice="sqload",coloring.var="groups")
plot(mfa.sup,choice="axes",coloring.var="groups")
plot(mfa.sup,choice="groups",coloring.var="groups")
plot(mfa.sup,choice="levels",coloring.var="groups")
plot(mfa.sup,choice="levels")
plot(mfa.sup,choice="cor",coloring.var = "groups")


chavent/PCAmixdata documentation built on Dec. 15, 2022, 5:56 p.m.