Title: | Multivariate Analysis of Variance Based on Distances and Permutations |
---|---|
Description: | Calculates multivariate analysis of variance based on permutations and some associated pictorial representations. The pictorial representation is based on the principal coordinates of the group means. There are some original results that will be published soon. |
Authors: | Laura Vicente-Gonzalez, Jose Luis Vicente-Villardon |
Maintainer: | Laura Vicente-Gonzalez <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.2.0 |
Built: | 2025-02-15 04:24:14 UTC |
Source: | https://github.com/cran/PERMANOVA |
The function add clusters to a biplot object to be represented on the biplot. The clusters can be defined by a nominal variable provided by the user, obtained from the hclust
function of the base package or from the kmeans
function.
AddClusterToBiplot(Bip, NGroups = 3, ClusterType = "hi", Groups = NULL, Original = FALSE, ...)
AddClusterToBiplot(Bip, NGroups = 3, ClusterType = "hi", Groups = NULL, Original = FALSE, ...)
Bip |
A Biplot object obtained from any biplot procedure. It has to be a list containing a field called |
NGroups |
Number of groups or clusters. Only necessary when hierarchical or k-means procedures are used. |
ClusterType |
The type of cluster to add. There are three possibilities "us" (User Defined), "hi" (hierarchical clusters), "km" (kmeans clustering) or "gm" (gaussian mixture). |
Groups |
A factor defining the groups provided by the user. |
Original |
Should the clusters be calculated using the original data rather than the reduced dimensions? |
... |
Any other parameter for the |
One of the main shortcomings of cluster analysis is that it is not easy to search for the variables associated to the obtained classification; representing the clusters on the biplot can help to perform that interpretation. If you consider the technique for dimension reduction as a way to separate the signal from the noise, clusters should be constructed using the dimensions retained in the biplot, otherwise the complete original data matrix can be used. The colors used by each cluster should match the color used in the Dendrogram. User defined clusters can also be plotted, for example, to investigate the relation of the biplot solution to an external nominal variable.
The function returns the biplot object with the information about the clusters added in new fields
ClusterType |
The method of clustering as defined in the argument |
Clusters |
A factor containing the solution or the user defined clusters |
ClusterNames |
The names of the clusters |
ClusterColors |
The colors of the clusters |
Dendrogram |
The Dendrogram if we have used hirarchical clustering |
ClusterObject |
The object obtained from |
Jose Luis Vicente-Villardon, Laura Vicente-Gonzalez
Demey, J. R., Vicente-Villardon, J. L., Galindo-Villardon, M. P., & Zambrano, A. Y. (2008). Identifying molecular markers associated with classification of genotypes by External Logistic Biplots. Bioinformatics, 24(24), 2832-2838.
Gallego-Alvarez, I., & Vicente-Villardon, J. L. (2012). Analysis of environmental indicators in international companies by applying the logistic biplot. Ecological Indicators, 23, 250-261.
Galindo, P. V., Vaz, T. D. N., & Nijkamp, P. (2011). Institutional capacity to dynamically innovate: an application to the Portuguese case. Technological Forecasting and Social Change, 78(1), 3-12.
Vazquez-de-Aldana, B. R., Garcia-Criado, B., Vicente-Tavera, S., & Zabalgogeazcoa, I. (2013). Fungal Endophyte (Epichloë festucae) Alters the Nutrient Content of Festuca rubra Regardless of Water Availability. PloS one, 8(12), e84539.
For clusters not provided by the user the function uses the standard procedures in hclust
and kmeans
.
Checks if all the entries of a vector are 0 or 1.
BinaryVectorCheck(x)
BinaryVectorCheck(x)
x |
The vector to check |
The logical result.
Jose Luis Vicente-Villardon
x=c(0, 0, 0, 0, 1, 1, 1, 2) BinaryVectorCheck(x)
x=c(0, 0, 0, 0, 1, 1, 1, 2) BinaryVectorCheck(x)
Draws a continuous variable on a biplot.
BiplotVar(bi1, bi2, b0 = 0, xmin = -3, xmax = 3, ymin = -3, ymax = 3, label = "Point", mode = "a", CexPoint = 0.8, PchPoint = 1, Color = "blue", ticks = c(-3, -2.5, -2, -1.5, -1, -0.5, 0.5, 1, 1.5, 2, 2.5, 3), ticklabels = round(ticks, digits = 2), tl = 0.03, ts = "Complete", Position = "Angle", AddArrow = FALSE, ...)
BiplotVar(bi1, bi2, b0 = 0, xmin = -3, xmax = 3, ymin = -3, ymax = 3, label = "Point", mode = "a", CexPoint = 0.8, PchPoint = 1, Color = "blue", ticks = c(-3, -2.5, -2, -1.5, -1, -0.5, 0.5, 1, 1.5, 2, 2.5, 3), ticklabels = round(ticks, digits = 2), tl = 0.03, ts = "Complete", Position = "Angle", AddArrow = FALSE, ...)
bi1 |
First component of the direction vector. |
bi2 |
Second component of the direction vector. |
b0 |
Constant for the regression adjusted biplots. |
xmin |
Minimum value of the x axis. |
xmax |
Maximum value of the x axis. |
ymin |
Minimum value of the y axis. |
ymax |
Maximum value of the y axis. |
label |
Label of the variable. |
mode |
Mode of the biplot: "p", "a", "b", "h", "ah" and "s". |
CexPoint |
Size for the symbols and labels of the variables. |
PchPoint |
Symbols for the variable (when represented as a point). |
Color |
Color for the variable. |
ticks |
Ticks when the variable is represented as a graded scale. |
ticklabels |
Labels for the ticks when the variable is represented as a graded scale. |
tl |
Thick length. |
ts |
Size of the mark in the graded scale. |
Position |
If the Position is "Angle" the label of the variable is placed using the angle of the vector. |
AddArrow |
Add an arrow to the representation of other modes of the biplot. |
... |
Any other graphical parameters |
See plot.PCA.Biplot
No value returned
Jose Luis Vicente-Villardon
Multivariate Analysis of variance based on distances and Bootstrap.
BootDisMANOVA(Distance, groups, C = NULL, Effects = NULL, nB = 1000, seed = NULL, CoordPrinc = FALSE, dimens = 2, PCoA = "Standard", ProjectInd = TRUE, tol = 1e-04, DatosIni = TRUE)
BootDisMANOVA(Distance, groups, C = NULL, Effects = NULL, nB = 1000, seed = NULL, CoordPrinc = FALSE, dimens = 2, PCoA = "Standard", ProjectInd = TRUE, tol = 1e-04, DatosIni = TRUE)
Distance |
A matrix of distances. |
groups |
A factor containing the groups to compare. |
C |
A matrix of contrasts (if null the identity is used). |
Effects |
A vector of effects. |
nB |
Number of Bootstrap replicates. |
seed |
Seed for the random numbers. |
CoordPrinc |
Should Principal Coordinates be calculated. |
dimens |
Dimension of the solution. |
PCoA |
Type of Principal Coordinates to calulate. |
ProjectInd |
Should the individuals be projected onto the graph. |
tol |
Tolerance for convergence of the algorithms. |
DatosIni |
Should the initial data be included in the results. |
Multivariate Analysis of Variance based on distances and Bootstrap.
call |
Function |
Title |
Title of the study |
Type |
BootMANOVA |
Distances |
A matrix containing the distances between individuals. |
C |
Contrasts Matrix. |
Initial |
Containing two matrices: * Global -> Global contrast. * Contrastes ->Contrasts for groups. |
DistMuestral |
Sample distribution of F-exp from permutations. |
pvalue |
Estimate p-valor for PERMANOVA. |
ExplainedVariance |
Explained variance by Principal Coordinates selected. |
Inertias |
Eigenvalue, Explained variance, Cumulative explained variance. |
MeanCoordinates |
Mean Coordinates by groups for the dimensions obtained in the Principal Coordinates Analysis. |
Qualities |
Qualities representation by groups for the dimensions of PCoA. |
CummulativeQualities |
Cummulative qualities representation. |
ClusterType |
Cluster type selected. |
Clusters |
Clusters created. |
ClusterNames |
Names of clusters |
ClusterColors |
Colors of clusters, color name and HTML code. |
Laura Vicente-Gonzalez, Jose Luis Vicente-Villardon
Anderson, M. J. (2001). A new method for non-parametric multivariate analysis of variance. Austral ecology, 26(1):32–46.
Anderson, M. J. (2005). Permanova: a fortran computer program for permutational multivariate analysis of variance. Department of Statistics, University of Auckland, New Zealand, 24.
data(wine) X = wine[,4:21] D = DistContinuous (X) bootwine=BootDisMANOVA(D, wine$Group) bootwine
data(wine) X = wine[,4:21] D = DistContinuous (X) bootwine=BootDisMANOVA(D, wine$Group) bootwine
Canonical Analysis based on distances. Confidence Regions for the mean vectors are calculated using bootstrap.
BootDistCanonicalAnalysis(Distance, groups, dimens = NULL, nB = 100, seed = NULL, PCoA = "Standard", ProcrustesRot = TRUE, DatosIni = TRUE, tol = 1e-04)
BootDistCanonicalAnalysis(Distance, groups, dimens = NULL, nB = 100, seed = NULL, PCoA = "Standard", ProcrustesRot = TRUE, DatosIni = TRUE, tol = 1e-04)
Distance |
A list of three elements containing the data, the distances between individuals and type of distance used. |
groups |
A factor containing the groups to compare. |
dimens |
Number of dimensions to choose . By default is 2. |
nB |
Number of Bootstrap samples. |
seed |
Seed for the generation of the random samples (Added for reproducibility) |
PCoA |
The type of Principal Coordinates Analysis. There are two possibilities: * Standard * Weighted By default is Standard. |
ProcrustesRot |
Should Procrustes rotation be applied to the configurations? |
DatosIni |
The input object contains the initial data?. By default is TRUE. |
tol |
Tolerance |
Calculates a Canonical Analysis based on distance matrices with confidence regions based on bootstrap resampling.
D |
The distance matrix used for calculations |
Coefficient |
Dissimilarity coefficient used to calculate the proximities |
nB |
Number of bootstrap samples |
Groups |
Factor containing the groups to compare |
GroupNames |
Names of the groups |
Inertia |
Variance accounted for ech canonical coordinate |
Inertias |
able with the eigenvalue, variance accounted and cumulated variance |
MeanCoordinates |
Coordinates of the groups in the representation |
Qualities |
Qualities of the representation of the group means |
CumulativeQualities |
Cumulative Qualities of the representation |
CoordBoot |
Coordinates of the bootstrap replicates |
RowCoordinates |
Coordinates of the individuals |
Laura Vicente-Gonzalez, Jose Luis Vicente-Villardon
Gower, J. C. and Krzanowski, W. J. (1999). Analysis of distance for structured multivariate data and extensions to multivariate analysis of variance. Journal of the Royal Statistical Society: Series C (Applied Statistics), 48(4):505–519.
data(wine) X=wine[,4:21] Dist=DistContinuous(X) canon=BootDistCanonicalAnalysis(Dist, groups=wine$Group, nB=10)
data(wine) X=wine[,4:21] Dist=DistContinuous(X) canon=BootDistCanonicalAnalysis(Dist, groups=wine$Group, nB=10)
Draws a circle for a given radius at the specified center with the given color.
Circle2(radius = 1, origin = c(0, 0), col = 1, ...)
Circle2(radius = 1, origin = c(0, 0), col = 1, ...)
radius |
Radius of the circle. |
origin |
Centre of the circle. |
col |
Color of the circle. |
... |
Additional graphical parameters. |
Draws a circle for a given radius at the specified center with the given color.
No value is returned.
Jose Luis Vicente-Villardon
plot(0,0) Circle2(1,c(0,0))
plot(0,0) Circle2(1,c(0,0))
Calculates non-parametric concentration ellipses for a two-dimensional set of points
ConcEllipse(data, center = NULL, confidence = 1, npoints = 100)
ConcEllipse(data, center = NULL, confidence = 1, npoints = 100)
data |
A two dimensional set of points. |
center |
Center of the data. |
confidence |
Confidence for the concentration ellipse. |
npoints |
Number of points to plot. |
Calculates non-parametric concentration ellipses for a two-dimensional set of points using distances to the center.
data |
Original data |
confidence |
Percent of points selected for the ellipse |
ellipse |
points to plot the ellipse |
center |
center of the ellipse |
Laura Vicente-Gonzalez, Jose Luis Vicente-Villardon
Meulman, J. J., & Heiser, W. J. (1983). The display of bootstrap solutions in multidimensional scaling. Murray Hill, NJ: Bell Laboratories.
Linting, M., Meulman, J. J., Groenen, P. J., & Van der Kooij, A. J. (2007). Stability of nonlinear principal components analysis: An empirical study using the balanced bootstrap. Psychological Methods, 12(3), 359.
x=runif(30) y=x+rnorm(30)*0.3 plot(x, y) el=ConcEllipse(cbind(x,y), confidence=0.95) plot(el)
x=runif(30) y=x+rnorm(30)*0.3 plot(x, y) el=ConcEllipse(cbind(x,y), confidence=0.95) plot(el)
Constructs the contrasts for main effects and interaction for a dataframe of factors.
ConstructContrasts(Factors, MaxOrderIter = 2)
ConstructContrasts(Factors, MaxOrderIter = 2)
Factors |
A data frame of factors (For general data frames the functions extracts all the columns that are factors). |
MaxOrderIter |
Maximum order of the interaction to construct. |
Constructs the contrasts for main effects and interaction for a dataframe of factors. For a general data frame the functions extracts all the factors first. The function constructs the contrasts for all the main effects and the interactions up to order MaxOrderIter.
Groups |
The groups resulting of combining the levels of all the factors. |
Contrasts |
A matrix of contrasts containing the contrasts that are associated to the main affects and interaction. The rows contain contrasts and the columns the groups to combine. |
Effects |
A factor describing which contrasts correspond to each effect. |
Jose Luis Vicente-Villardon, Laura Vicente-Gonzalez
Bapat, R. B. (2012). Linear algebra and linear models. Springer Science & Business Media.
ConstructContrasts(wine[,1:2])
ConstructContrasts(wine[,1:2])
Cumulative sums.
Cumsum(X, dimens = 1)
Cumsum(X, dimens = 1)
X |
Data Matrix. |
dimens |
Dimension for summing. |
Cumulative sums within rows (dimens=1) or columns (dimens=2) of a data matrix.
A matrix of the same size as X with cumulative sums within each row or each column.
Jose Luis Vicente-Villardon
data(wine) X=wine[,4:21] Cumsum(X,1) Cumsum(X,2)
data(wine) X=wine[,4:21] Cumsum(X,1) Cumsum(X,2)
Calculates distancies among individuals for binary data. It is possible introduce two matrices (x, y) and calculate the distancies between them or introduce only one matrix (x) and calculate the distancies among individuals in the single matrix.
DistBinary(x, y = NULL, coefficient = "Simple_Matching", transformation = "sqrt(1-S)")
DistBinary(x, y = NULL, coefficient = "Simple_Matching", transformation = "sqrt(1-S)")
x |
A matrix containing binary data. |
y |
A matrix containing binary data different than x. By default it is null because if we want calculate the distancies between individuals it's not necessary. |
coefficient |
Similarity coefficients for binary data.By default it is Simple_Matching. See details. |
transformation |
Transformations of similarities into distances. By default it is sqrt(1-S). See details. |
The function calculates coefficients of similarity (among individuals) for binary data and converts them into measures of distance.
We have 17 different coefficients (numbers instead of names can be used as arguments of the function) :
* 1.- Kulezynski
* 2.- Russell_and_Rao
* 3.- Jaccard
* 4.- Simple_Matching
* 5.- Anderberg
* 6.- Rogers_and_Tanimoto
* 7.- Sorensen_Dice_and_Czekanowski
* 8.- Sneath_and_Sokal
* 9.- Hamman
* 10.- Kulezynski2
* 11.- Anderberg2
* 12.- Ochiai
* 13.- S13
* 14.- Pearson_phi
* 15.- Yule
* 16.- Sorensen
* 17.- Dice
There are nine possible transformations of the initial similarities:
* 1.- Identity
* 2.- 1-S
* 3.- sqrt(1-S)
* 4.- (-log(S))
* 5.- (1/S-1)
* 6.- (sqrt(2(1-S)))
* 7.- (1-(S+1)/2)
* 8.- 1-abs(S)
* 9.- 1/(S+1)
The DistBinary function creates a list that return:
Data |
A matrix with initial data. |
D |
A matrix containing binary distancies. |
Coefficient |
Character containing the name of the coefficient used. |
Laura Vicente-Gonzalez, Jose Luis Vicente-Villardon
Gower, J. C. (2006) Similarity dissimilarity and Distance, measures of. Encyclopedia of Statistical Sciences. 2nd. ed. Volume 12. Wiley
data(spidersb) DD=DistBinary(spidersb)
data(spidersb) DD=DistBinary(spidersb)
Calculate distances among individuals for continuous data. It is possible introduce two matrices (x, y) and calculate the distances between the two sets of rows or introduce only one matrix (x) and calculate the distances between its rows.
DistContinuous(x, y = NULL, coef = "Pythagorean", r = 1)
DistContinuous(x, y = NULL, coef = "Pythagorean", r = 1)
x |
A matrix containing continuous data. |
y |
A matrix containing continuous data different from x. By default it is null. |
coef |
Coefficient to calculate continuous distances. By default we use Pythagorean distances. |
r |
For Minkowski distances. By default it is 1. |
The function calculates distances among individuals for matrices of continuous data using different distance measures. If two matrices are provided, distances among individuals, one from the first matrix and another from the second, are calculated. If only one matrix is provided, interdistances among its rows are calculated.
The following coefficients are calculated
1.- Pythagorean = sqrt(sum((y[i, ] - x[j, ])^2)/p)
2.- Taxonomic = sqrt(sum(((y[i,]-x[j,])^2)/r^2)/p)
3.- City = sum(abs(y[i,]-x[j,])/r)/p
4.- Minkowski = (sum((abs(y[i,]-x[j,])/r)^t)/p)^(1/t)
5.- Divergence = sqrt(sum((y[i,]-x[j,])^2/(y[i,]+x[j,])^2)/p)
6.- dif_sum = sum(abs(y[i,]-x[j,])/abs(y[i,]+x[j,]))/p
7.- Camberra = sum(abs(y[i,]-x[j,])/(abs(y[i,])+abs(x[j,])))
8.- Bray_Curtis = sum(abs(y[i,]-x[j,]))/sum(y[i,]+x[j,])
9.- Soergel = sum(abs(y[i,]-x[j,]))/sum(apply(rbind(y[i,],x[j,]),2,max))
10.- Ware_hedges = sum(abs(y[i,]-x[j,]))/sum(apply(rbind(y[i,],x[j,]),2,max))
A list with:
Data |
A matrix with the initial data (x matrix). |
SupData |
A matrix with the supplementary data (y matrix). |
D |
The matrix of distances. |
Coefficient |
The coefficient used. |
Laura Vicente-Gonzalez, Jose Luis Vicente-Villardon
Gower, J. C. (2006) Similarity dissimilarity and Distance, measures of. Encyclopedia of Statistical Sciences. 2nd. ed. Volume 12. Wiley
data(wine) X = wine[,4:21] D=DistContinuous(X)
data(wine) X = wine[,4:21] D=DistContinuous(X)
Connects two sets of points by lines in a rowwise manner. Adapted from Graffelman(2013).
Dlines(SetA, SetB, lin = "dotted", color = "black", ...)
Dlines(SetA, SetB, lin = "dotted", color = "black", ...)
SetA |
First set of points. |
SetB |
Second set of points. |
lin |
Line style. |
color |
Line color. |
... |
Any other graphical parameters. |
Connects two sets of points by lines.
NULL
Based on Graffelman (2013)
Jan Graffelman (2013). calibrate: Calibration of Scatterplot and Biplot Axes. R package version 1.7.2. http://CRAN.R-project.org/package=calibrate
## No examples
## No examples
Converts a factor into a binary matrix with as many columns as categories of the factor.
FactorToBinary(y, Name = NULL)
FactorToBinary(y, Name = NULL)
y |
A factor. |
Name |
Name to use in the final matrix. |
An indicator binary matrix.
Jose Luis Vicente-Villardon
y=factor(c(1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 2, 2, 2, 1, 1, 1)) FactorToBinary(y)
y=factor(c(1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 2, 2, 2, 1, 1, 1)) FactorToBinary(y)
Calculates the scales for the variables on a linear prediction biplot. There are several types of scales and values that can be shown on the graphical representation. See details.
GetScalesBiplot(Biplot, nticks = 4, TypeScale = "Complete", ValuesScale = "Original")
GetScalesBiplot(Biplot, nticks = 4, TypeScale = "Complete", ValuesScale = "Original")
Biplot |
Object of class PCA.Biplot. |
nticks |
Number of ticks for the biplot axes. |
TypeScale |
Type of scale to use : "Complete", "StdDev" or "BoxPlot". |
ValuesScale |
Values to show on the scale: "Original" or "Transformed". |
The function calculates the points on the biplot axes where the scales should be placed.
There are three types of scales when the transformations of the raw data are made by columns:
"Complete": Covers the whole range of the variable using the number of ticks specified in "nticks". A smaller number of points could be shown if some fall outside the range of the scatter.
"StdDev": The mean +/- 1, 2 and 3 times the standard deviation.A smaller number of points could be shown if some fall outside the range of the scatter.
"BoxPlot": Median, 25, 75 percentiles maximum and minimum values are shown. The extremes of the interquartile range are connected with a thicker line. A smaller number of points could be shown if some fall outside the range of the scatter.
There are two kinds of values that can be shown on the biplot axis:
"Original": The values before transformation. Only makes sense when the transformations are for each column.
"Transformed": The values after transformation, for example, after standardization.
Although the function is public, the end used will not normally use it.
A list with the following components:
Ticks |
A list containing the ticks for each variable. |
Labels |
A list containing the labels for each variable. |
Jose Luis Vicente-Villardon
Calculates the g-inverse of a squared matrix using the eigen decomposition and removing the eigenvalues smaller than a tolerance.
Ginv(X, tol = sqrt(.Machine$double.eps))
Ginv(X, tol = sqrt(.Machine$double.eps))
X |
Matrix to calculate the g-inverse. |
tol |
Tolerance. |
The function is useful to avoid singularities.
Returns the g-inverse.
Jose Luis Vicente-Villardon
data(iris) x=as.matrix(iris[,1:4]) S= t(x) Ginv(S)
data(iris) x=as.matrix(iris[,1:4]) S= t(x) Ginv(S)
Checks if a point is inside a box. The point is specified bi its x and y coordinates and the box with the minimum and maximum values on both coordinate axis: xmin, xmax, ymin, ymax. The vertices of the box are then (xmin, ymin), (xmax, ymin), (xmax, ymax) and (xmin, ymax).
inbox(x, y, xmin, xmax, ymin, ymax)
inbox(x, y, xmin, xmax, ymin, ymax)
x |
x coordinate of the point. |
y |
y coordinate of the point. |
xmin |
Minimum value of X. |
xmax |
Maximum value of X. |
ymin |
Minimum value of Y. |
ymax |
Maximum value of Y. |
Returns a logical value: TRUE if the point is inside the box and FALSE otherwise.
Jose Luis Vicente Villardon
inbox(0, 0, -1, 1, -1, 1)
inbox(0, 0, -1, 1, -1, 1)
Initial transformation of data before the construction of a biplot (or any other technique).
IniTransform(X, InitTransform = "None", transform = "Standardize columns")
IniTransform(X, InitTransform = "None", transform = "Standardize columns")
X |
Original Raw Data Matrix. |
InitTransform |
Previous transformation (Logarithm or logit). |
transform |
Transformation to use. See details. |
Possible Transformations are:
1.- "Raw Data": When no transformation is required.
2.- "Subtract the global mean": Eliminate an effect common to all the observations
3.- "Double centering" : Interaction residuals. When all the elements of the table are comparable. Useful for AMMI models.
4.- "Column centering": Remove the column means.
5.- "Standardize columns": Remove the column means and divide by its standard deviation.
6.- "Row centering": Remove the row means.
7.- "Standardize rows": Divide each row by its standard deviation.
8.- "Divide by the column means and center": The resulting dispersion is the coefficient of variation.
9.- "Normalized residuals from independence" for a contingency table.
The transformation can be provided to the function by using the string between the quotes or just the associated number.
The supplementary rows and columns are not used to calculate the parameters (means, standard deviations, etc). Some of the transformations are not compatible with supplementary data.
X |
Transformed data matrix. |
Jose Luis Vicente-Villardon
M. J. Baxter (1995) Standardization and Transformation in Principal Component Analysis, with Applications to Archaeometry. Journal of the Royal Statistical Society. Series C (Applied Statistics). Vol. 44, No. 4 (1995) , pp. 513-527
Kroonenberg, P. M. (1983). Three-mode principal component analysis: Theory and applications (Vol. 2). DSWO press. (Chapter 6)
data(iris) x=as.matrix(iris[,1:4]) x=IniTransform(x, transform=4) x
data(iris) x=as.matrix(iris[,1:4]) x=IniTransform(x, transform=4) x
Performs a Multivariate Analysis of Variance (MANOVA) based on matrix calculations. Is an extension of the function in the base package of R.
The function can take care of matrices of contrasts and matrices of linear combinations of variables in order to cope with complex designs.
MANOVA(Y, Group, C = NULL, M = NULL, Effects = NULL, InitialTransform = 5, AddOnes = FALSE, Contrasts = TRUE)
MANOVA(Y, Group, C = NULL, M = NULL, Effects = NULL, InitialTransform = 5, AddOnes = FALSE, Contrasts = TRUE)
Y |
A matrix containing the response variables. |
Group |
A factor containing the groups to compare (or the treatments). |
C |
A matrix of contrasts on the groups. |
M |
A matrix with the linear combinations of the variables to test. |
Effects |
A factor with the effects in the rows of C. |
InitialTransform |
Initial transformation of the response variables. |
AddOnes |
Add a column of ones to the design matrix. By default is false. |
Contrasts |
Should each contrast be tested separately?. By default is TRUE. |
Performs a general MANOVA to compare several groups or treatments. Additional contrasts can be tested using the contrasts matrix . This can also be separated into several effects.
Here we use an approach with matrices rather than te usual multivariate general linear model. Several designs can be obtained using the appropriate matrix of contrasts.
An object of class "MANOVA" and "Canonical.Biplot".
Laura Vicente-Gonzalez, Jose Luis Vicente-Villardon
Amaro, I. R., Vicente-Villardon, J. L., & Galindo-Villardon, M. P. (2004). Manova Biplot para arreglos de tratamientos con dos factores basado en modelos lineales generales multivariantes. Interciencia, 29(1), 26-32.
Gabriel KR (1971) The biplot graphic display of matrices with application to principal component analysis. Biometrika 58(3):453-467.
Gabriel, K. R. (1995). MANOVA biplots for two-way contingency tables. WJ Krzanowski (Ed.), Recent advances in descriptive multivariate analysis, Oxford University Press, Toronto. 227-268.
Gower y Hand (1996): Biplots. Chapman & Hall.
Varas, M. J., Vicente-Tavera, S., Molina, E., & Vicente-Villardon, J. L. (2005). Role of canonical biplot method in the study of building stones: an example from Spanish monumental heritage. Environmetrics, 16(4), 405-419.
Santana, M. A., Romay, G., Matehus, J., Vcente-Villardon, J. L., & Demey, J. R. (2009). simple and low-cost strategy for micropropagation of cassava (Manihot esculenta Crantz). African Journal of Biotechnology, 8(16).
data(wine) Y=as.matrix(wine[,4:21]) group=wine$Group manvin=MANOVA(Y, Group=group) summary(manvin)
data(wine) Y=as.matrix(wine[,4:21]) group=wine$Group manvin=MANOVA(Y, Group=group) summary(manvin)
The function estimates the parameters of the MANOVA for a set of contrasts and a set of linear combinations of the dependent variables.
MANOVA.Estimation(Y, X, C, M)
MANOVA.Estimation(Y, X, C, M)
Y |
The matrix of dependent variables. |
X |
The matrix of independent variables. |
C |
A matrix containing a set of contrasts on the columns of X. |
M |
A matrix containing a set of linear combinations of the columns of Y. |
The function estimates the parameters of the MANOVA for a set of contrasts contained in a matrix C and a set of linear combinations of the dependent variables in a matrix M. The function is actually used in a more general procedure called MANOVA.
Returns the main results of the MANOVA.
Jose Luis Vicente-Villardon, Laura Vicente-Gonzalez
Seber, G. A. (2009). Multivariate observations (Vol. 252). John Wiley & Sons.
Model based clustering using mixtures of gaussian distributions.
mgc(x, NG = 2, init = "km", RemoveOutliers = FALSE, ConfidOutliers = 0.995, tolerance = 1e-07, maxiter = 100, show = TRUE, ...)
mgc(x, NG = 2, init = "km", RemoveOutliers = FALSE, ConfidOutliers = 0.995, tolerance = 1e-07, maxiter = 100, show = TRUE, ...)
x |
The data matrix. |
NG |
Number of groups or clusters to obtain. |
init |
Initial centers can be obtained from k-means ("km") or at random ("rd"). |
RemoveOutliers |
Should the extreme values be removed to calculate the clusters? |
ConfidOutliers |
Percentage of the points to keep for the calculations when RemoveOutliers is true. |
tolerance |
Tolerance for convergence. |
maxiter |
Maximum number of iterations. |
show |
Should the likelihood at each iteration be shown? |
... |
Any other parameter that can affect k-means if that is the initial configuration. |
A basic algorithm for clustering with mixtures of gaussians with no restrictions on the covariance matrices.
Clusters.
Jose Luis Vicente-Villardon
X=as.matrix(iris[,1:4]) mod1=mgc(X,NG=3) plot(iris[,1:4], col=mod1$Classification) table(iris[,5],mod1$Classification)
X=as.matrix(iris[,1:4]) mod1=mgc(X,NG=3) plot(iris[,1:4], col=mod1$Classification) table(iris[,5],mod1$Classification)
Square matrix of ones
Ones(n)
Ones(n)
n |
Order of the matrix. |
Square matrix of ones.
A matrix of ones of order n.
Jose Luis Vicente-Villardon
Ones(6)
Ones(6)
The correct application of MANOVA needs normal and homocedastic data and the number of variables be much smaller than the number of individuals, but for many applications the conditions do not hold. To extend the application to this data Anderson develops PERMANOVA. This non-parametric test based on distances uses permutation to approximate the sampling distribution of the test statistic.
Contrasts and Effects can be added to the calculations.
PERMANOVA(Distance, group, C = NULL, Effects = NULL, nperm = 1000, seed = NULL, CoordPrinc = FALSE, dimens = 2, PCoA = "Standard", ProjectInd = TRUE, tol = 1e-04, DatosIni = TRUE, PostHoc="bonferroni")
PERMANOVA(Distance, group, C = NULL, Effects = NULL, nperm = 1000, seed = NULL, CoordPrinc = FALSE, dimens = 2, PCoA = "Standard", ProjectInd = TRUE, tol = 1e-04, DatosIni = TRUE, PostHoc="bonferroni")
Distance |
A list of three elements containing the data, the distances between individuals and type of distance used. |
group |
A factor containing the groups to compare. |
C |
Contrast matrix. By default it is null and the identity is used. |
Effects |
A factor with the effects in the rows of C. By default it is null and each row is considered as an effect. |
nperm |
Number of permutations to perform. By default is 1000. |
seed |
Seed to start permutations. By default is null. |
CoordPrinc |
Should the principal coordinates be calculated?. By default is FALSE. |
dimens |
Number of dimensions to choose in the PCoA. By default is 2. |
PCoA |
The type of Principal Coordinates Analysis. There are two possibilities: * Standard * Weighted By default is Standard. |
ProjectInd |
Show the row coordinates. By default is TRUE. |
tol |
Tolerance. |
DatosIni |
It contains the initial data. By default is TRUE. |
PostHoc |
Correction method. There are eight possibilities: *holm: Holm *hochberg: Hochberg *hommel: Hommel *bonferroni: Bonferroni. By default is this method. *BH:Benjamini & Hochberg *BY: Benjamini & Yekutieli *fdr: Benjamini & Hochberg *none |
The function performs a PERMANOVA Analysis.
The PERMANOVA function create a list that return:
call |
Function. |
Title |
Permutation based MANOVA. |
Type |
PERMANOVA. |
Distances |
A matrix containing the distances between individuals. |
C |
Contrasts Matrix. |
Initial |
Containing two matrices: * Global -> Global contrast. * Contrastes ->Contrasts for groups. |
DistMuestral |
Sample distribution of F-exp from permutations. |
pvalue |
Estimate p-valor for PERMANOVA. |
ExplainedVariance |
Explained variance by Principal Coordinates selected. |
Inertias |
Eigenvalue, Explained variance, Cumulative explained variance. |
MeanCoordinates |
Mean Coordinates by groups for the dimensions obtained in the Principal Coordinates Analysis. |
Qualities |
Qualities representation by groups for the dimensions of PCoA. |
CummulativeQualities |
Cumulative qualities representation. |
ClusterType |
Cluster type selected. |
Clusters |
Clusters created. |
ClusterNames |
Names of clusters. |
ClusterColors |
Colors of clusters, color name and HTML code. |
Laura Vicente-Gonzalez, Jose Luis Vicente-Villardon
Anderson, M. J. (2008). A new method for non-parametric multivariate analysis of variance. Austral ecology, 26(1):32–46.
Anderson, M. J. (2005). Permanova: a fortran computer program for permutational multivariate analysis of variance. Department of Statistics, University of Auckland, New Zealand, 24.
data(wine) X = wine[,4:21] X=IniTransform(X) D = DistContinuous (X) perwine=PERMANOVA(D, wine$Group) perwine C = matrix(c(1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1), nrow=3, byrow=TRUE) rownames(C)=c("C1", "C2", "C3") colnames(C)=levels(wine$Group) effects=factor(c(1,2,3)) levels(effects)=c("Origin", "Year", "Interaction") perwine2=PERMANOVA(D, wine$Group, C=C, Effects=effects, CoordPrinc = TRUE) summary(perwine2)
data(wine) X = wine[,4:21] X=IniTransform(X) D = DistContinuous (X) perwine=PERMANOVA(D, wine$Group) perwine C = matrix(c(1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1), nrow=3, byrow=TRUE) rownames(C)=c("C1", "C2", "C3") colnames(C)=levels(wine$Group) effects=factor(c(1,2,3)) levels(effects)=c("Origin", "Year", "Interaction") perwine2=PERMANOVA(D, wine$Group, C=C, Effects=effects, CoordPrinc = TRUE) summary(perwine2)
Estimation of the PERMANOVA parameters.
PERMANOVA.Estimation(D, X, C, Effects = NULL)
PERMANOVA.Estimation(D, X, C, Effects = NULL)
D |
A matrix of distances. |
X |
A matrix of independent variables. |
C |
Contrast matrix. By default it is null and the identity is used. |
Effects |
A factor with the effects in the rows of C. By default it is null and each row is considered as an effect. |
Estimation of the PERMANOVA parameters.
Global |
Significance for the global effect |
Contrastes |
Significance for each contrast |
Laura Vicente-Gonzalez, Jose Luis Vicente-Villardon
Anderson, M. J. (2008). A new method for non-parametric multivariate analysis of variance. Austral ecology, 26(1):32–46.
Anderson, M. J. (2005). Permanova: a fortran computer program for permutational multivariate analysis of variance. Department of Statistics, University of Auckland, New Zealand, 24.
This function makes a PERMANOVA from distancies matrix and factor for groups.
PerMANOVA.Simple(D, grupo, nperm = 999, seed = NULL, C = NULL)
PerMANOVA.Simple(D, grupo, nperm = 999, seed = NULL, C = NULL)
D |
A matrix containing the distances between individuals. |
grupo |
A factor containing the groups to compare. |
nperm |
Number of permutation that want to perform. By default it is 999. |
seed |
Seed to start permutations. By default it is null. |
C |
Contrast matrix. By default it is null. |
The PERMANOVA.Simple function create a list that return:
call |
Function |
nperm |
Number of permutation. |
Inicial |
Containing: * TSS -> Total sum of squares. * BSS -> Between groups sum of squares. * WSS -> Within groups sum of squares. * glt -> Total degrees of freedom. * glb -> Between groups degrees of freedom. * glw -> Within groups degrees of freedom. * Fexp -> Experimental F. |
Fvals |
F values of the permutation. |
pval |
Estimate p-valor for PERMANOVA. |
Laura Vicente-Gonzalez, Jose Luis Vicente-Villardon
Anderson, M. J. (2001). A new method for non-parametric multivariate analysis of variance. Austral ecology, 26(1):32–46.
Anderson, M. J. (2005). Permanova: a fortran computer program for permutational multivariate analysis of variance. Department of Statistics, University of Auckland, New Zealand, 24.
data(wine) X = wine[,4:21] Dist = DistContinuous (X) PerMANOVA.Simple(Dist$D, wine$Group)
data(wine) X = wine[,4:21] Dist = DistContinuous (X) PerMANOVA.Simple(Dist$D, wine$Group)
Plots the principal coordinates of the group centers and the bootstrap confidence regions.
## S3 method for class 'BootCanonAnalysis' plot(x, A1 = 1, A2 = 2, centred = FALSE, confidence = 0.9, PlotReplicates = TRUE, MeanCex = 1.5, MeanPch = 16, Title = "Bootstrap Canonical Analysis based on Distances", LabelMeans = TRUE, MeanLabels = NULL, MeanColors = NULL, SmartLabels = TRUE, BootstrapPlot = "el", PlotIndiv = FALSE, LabelInd = FALSE, IndLabels = NULL, IndColors = NULL, CexInd = 0.5, PchInd = 1, ConvexHullsInd = FALSE, ...)
## S3 method for class 'BootCanonAnalysis' plot(x, A1 = 1, A2 = 2, centred = FALSE, confidence = 0.9, PlotReplicates = TRUE, MeanCex = 1.5, MeanPch = 16, Title = "Bootstrap Canonical Analysis based on Distances", LabelMeans = TRUE, MeanLabels = NULL, MeanColors = NULL, SmartLabels = TRUE, BootstrapPlot = "el", PlotIndiv = FALSE, LabelInd = FALSE, IndLabels = NULL, IndColors = NULL, CexInd = 0.5, PchInd = 1, ConvexHullsInd = FALSE, ...)
x |
The object to plot. |
A1 |
Dimension to plot on the X axis. |
A2 |
Dimension to plot on the Y axis. |
centred |
Plot centers of the bootstrap regions. |
confidence |
Confidence for the bootstrap regions. |
PlotReplicates |
Should all the bootstrap replicates be plotted. |
MeanCex |
Size of the points and text representing the centroids of the groups. |
MeanPch |
Marks of the points and text representing the centroids of the groups. |
Title |
Main title of the graph. |
LabelMeans |
Should the groups be labelled? |
MeanLabels |
Labels for the group means. |
MeanColors |
Colors for the group means. |
SmartLabels |
Should the labels be placed in a smart way? |
BootstrapPlot |
Should the bootstrap regions be plotted? |
PlotIndiv |
Should the individuals be plotted? |
LabelInd |
Should individuals be labelled? |
IndLabels |
Labels for the individuals. |
IndColors |
Colors for the rows (individuals). |
CexInd |
Sizes for the rows (individuals). |
PchInd |
Marks for the rows (individuals). |
ConvexHullsInd |
Convex hulls containing the individuals of each group. |
... |
Any other graphical parameters. |
Plots the principal coordinates of the means of the groups with the confidence bootstrap region.
The plot.
Laura Vicente-Gonzalez, Jose Luis Vicente-Villardon
Plot a concentration ellipse obtained from ConcEllipse
.
## S3 method for class 'ellipse' plot(x, add = TRUE, labeled = FALSE, center = FALSE, centerlabel = "Center", initial = FALSE, ...)
## S3 method for class 'ellipse' plot(x, add = TRUE, labeled = FALSE, center = FALSE, centerlabel = "Center", initial = FALSE, ...)
x |
An object with class |
add |
Should the ellipse be added to the current plot? |
labeled |
Should the ellipse be labelled with the confidence level? |
center |
Should the center be plotted? |
centerlabel |
Label for the center. |
initial |
Should the initial data be plotted? |
... |
Any other graphical parameter that can affects the plot (as color, etc ...). |
Plots an ellipse containing a specified percentage of the data.
No value returned.
Jose Luis Vicente-Villardon
Meulman, J. J., & Heiser, W. J. (1983). The display of bootstrap solutions in multidimensional scaling. Murray Hill, NJ: Bell Laboratories.
Linting, M., Meulman, J. J., Groenen, P. J., & Van der Kooij, A. J. (2007). Stability of nonlinear principal components analysis: An empirical study using the balanced bootstrap. Psychological Methods, 12(3), 359.
data(iris) dat=as.matrix(iris[1:50,1:2]) plot(iris[,1], iris[,2],col=iris[,5], asp=1) E=ConcEllipse(dat, confidence=0.95) plot(E, add=TRUE, center=TRUE)
data(iris) dat=as.matrix(iris[1:50,1:2]) plot(iris[,1], iris[,2],col=iris[,5], asp=1) E=ConcEllipse(dat, confidence=0.95) plot(E, add=TRUE, center=TRUE)
Plots the results of a MANOVA Biplot.
## S3 method for class 'MANOVA' plot(x, A1 = 1, A2 = 2, ScaleGraph = TRUE, PlotGroups = TRUE, PlotVars = TRUE, PlotInd = TRUE, WhatInds=NULL,WhatVars=NULL, WhatGroups=NULL, IndLabels=NULL, VarLabels=NULL, GroupLabels=NULL, AbbreviateLabels=FALSE, LabelInd=TRUE, LabelVars = TRUE, CexGroup=1, PchGroup=16, margin=0.1, AddLegend=FALSE, ShowAxes=FALSE, LabelAxes=FALSE, LabelGroups=TRUE, PlotCircle = TRUE, ConvexHulls = FALSE, TypeCircle = "M", ColorGroups = NULL, ColorVars = NULL, LegendPos="topright", ColorInd = NULL, voronoi = TRUE, mode="a", TypeScale = "Complete", ValuesScale = "Original", MinQualityVars = 0, dpg = 0, dpi=0, dp=0, PredPoints=0, PlotAxis = FALSE, CexInd = NULL, CexVar = NULL, PchInd = NULL, PchVar = NULL, ColorVar=NULL, ShowAxis=FALSE, VoronoiColor="black", ShowBox=FALSE, ShowTitle=TRUE,PlotClus = FALSE, TypeClus = "ch", ClustConf = 1, ClustCenters = FALSE, UseClusterColors = TRUE, CexClustCenters=1, ...)
## S3 method for class 'MANOVA' plot(x, A1 = 1, A2 = 2, ScaleGraph = TRUE, PlotGroups = TRUE, PlotVars = TRUE, PlotInd = TRUE, WhatInds=NULL,WhatVars=NULL, WhatGroups=NULL, IndLabels=NULL, VarLabels=NULL, GroupLabels=NULL, AbbreviateLabels=FALSE, LabelInd=TRUE, LabelVars = TRUE, CexGroup=1, PchGroup=16, margin=0.1, AddLegend=FALSE, ShowAxes=FALSE, LabelAxes=FALSE, LabelGroups=TRUE, PlotCircle = TRUE, ConvexHulls = FALSE, TypeCircle = "M", ColorGroups = NULL, ColorVars = NULL, LegendPos="topright", ColorInd = NULL, voronoi = TRUE, mode="a", TypeScale = "Complete", ValuesScale = "Original", MinQualityVars = 0, dpg = 0, dpi=0, dp=0, PredPoints=0, PlotAxis = FALSE, CexInd = NULL, CexVar = NULL, PchInd = NULL, PchVar = NULL, ColorVar=NULL, ShowAxis=FALSE, VoronoiColor="black", ShowBox=FALSE, ShowTitle=TRUE,PlotClus = FALSE, TypeClus = "ch", ClustConf = 1, ClustCenters = FALSE, UseClusterColors = TRUE, CexClustCenters=1, ...)
x |
An object of class "MANOVA.Biplot". |
A1 |
Dimension for the first axis. 1 is the default. |
A2 |
Dimension for the second axis. 2 is the default. |
ScaleGraph |
Rescale the coordinates to optimal matching. |
PlotGroups |
Should the group centers be plotted? |
PlotVars |
Should the variables be plotted? |
PlotInd |
Should the individuals be plotted? |
WhatInds |
What individuals should be plotted? A vector. |
WhatVars |
What variables should be plotted? A vector. |
WhatGroups |
What groups should be plotted? A vector. |
IndLabels |
Labels for the individuals. |
VarLabels |
Labels for the variables. |
GroupLabels |
Labels for the groups. |
AbbreviateLabels |
Should the labels be Abbreviated for simplicity of the graph? |
LabelInd |
Should the individuals be labelled? |
LabelVars |
Should the variables be labelled? |
CexGroup |
Size of the points for groups. |
PchGroup |
Mark of the points for groups. |
margin |
Margin for labels (in percentage). |
AddLegend |
Should a legend be added? |
ShowAxes |
Should the axes be shown? |
LabelAxes |
Should the axes be labelled? |
LabelGroups |
Should the groups be labelled? |
PlotCircle |
Should the confidence regions for the groups be plotted? |
ConvexHulls |
Should the convex hulls containing the individuals for each group be plotted? |
TypeCircle |
Type of confidence region: Univariate (U), Bonferroni(B), Multivariate (M) or Classical (C). By default is "M". |
ColorGroups |
User colors for the groups. Default colors will be used if NULL. |
ColorVars |
User colors for the variables. Default colors will be used if NULL. |
LegendPos |
Position of the legend. |
ColorInd |
User colors for the individuals. Default colors will be used if NULL. |
voronoi |
Should the Voronoi diagram with the prediction regions for each group be plotted? |
mode |
Mode of the biplot: "p", "a", "b", "h", "ah" and "s". See details. |
TypeScale |
Type of scale to use : "Complete", "StdDev" or "BoxPlot". See details. |
ValuesScale |
Values to show on the scale: "Original" or "Transformed". |
MinQualityVars |
Minimum quality of representation for a variable to be plotted. |
dpg |
A set of indices with the variables that will show projections onto the variables. |
dpi |
A set of indices with the individuals that will show the projections. |
dp |
A set of indices with the variables that will show the projections of the individuals. |
PredPoints |
A vector with integers. The group centers listed in the vector are projected onto all the variables. |
PlotAxis |
Not Used |
CexInd |
Size of the points for individuals. |
CexVar |
Size of the points for variables. |
PchInd |
Markers of the points for individuals. |
PchVar |
Markers of the points for variables. |
ColorVar |
Colors of the points for variables. |
ShowAxis |
Should axis scales be shown? |
VoronoiColor |
Color for the Voronoi diagram. |
ShowBox |
Should a box around the points be plotted? |
ShowTitle |
Should Title be shown? |
PlotClus |
Should the clusters be plotted? |
TypeClus |
Type of plot for the clusters. ("ch"- Convex Hull, "el"- Ellipse or "st"- Star) |
ClustConf |
Percent of points included in the cluster. Only the ClusConf percent of the points nearest to the center will be used to calculate the cluster. |
ClustCenters |
Should the cluster centers be plotted? |
UseClusterColors |
Should the cluster colors be used in the plot? |
CexClustCenters |
Size of the cluster centres. |
... |
Any other graphical parameter. |
The function plots the results of a MANOVA Biplot. The coordinates for Groups, Individuals and Variables can be shown or not on the plot, each of the three can also be labeled separately. The are parameters to control the way each different set of coordinates is plotted and labeled.
There are several modes for plotting the biplot.
"p".- Points (Rows and Columns are represented by points)
"a" .- Arrows (The traditional representation with points for rows and arrows for columns)
"b" .- The arrows for the columns are extended to both extremes of the plot and labeled outside the plot area.
"h" .- The arrows for the columns are extended to the positive extreme of the plot and labeled outside the plot area.
"ah" .- Same as arrows but labeled outside the plot area.
"s" .- The directions (or biplot axes) have a graded scale for prediction of the original values.
The TypeScale argument applies only to the "s" mode. There are three types:
"Complete" .- An equally spaced scale covering the whole range of the data is calculates.
"StdDev" .- Mean with one, two and three standard deviations
"BoxPlot" .- Box-Plot like Scale (Median, 25 and 75 percentiles, maximum and minimum values.)
The ValuesScale argument applies only to the "s" mode and controls if the labels show the Original ot Transformed values.
Some of the initial transformations are not compatible with some of the types of biplots and scales. For example, It is not possible to recover by projection the original values when you double centre de data. In that case you have the residuals for interaction and only the transformed values make sense.
A plot is returned.
Jose Luis Vicente-Villardon, Laura Vicente-Gonzalez
Gabriel, K. R. (1972). Analysis of meteorological data by means of canonical decomposition and biplots. Journal of Applied Meteorology, 11(7), 1071-1077.
Amaro, I. R., Vicente-Villardon, J. L., & Galindo Villardon, M. P. (2004). Manova Biplot para arreglos de tratamientos con dos factores basado en modelos lineales generales multivariantes. Interciencia, 29(1), 26-32.
Sierra, C., Ruiz-Barzola, O., Menendez, M., Demey, J. R., & Vicente-Villardon, J. L. (2017). Geochemical interactions study in surface river sediments at an artisanal mining area by means of Canonical (MANOVA)-Biplot. Journal of Geochemical Exploration, 175, 72-81.
data(wine) X=wine[,4:21] manbip=MANOVA(X, Group=wine$Group) plot(manbip, TypeCircle="B", Voronoi=FALSE)
data(wine) X=wine[,4:21] manbip=MANOVA(X, Group=wine$Group) plot(manbip, TypeCircle="B", Voronoi=FALSE)
Plots the results of a MANOVA Biplot
## S3 method for class 'MANOVA.Biplot' plot(x, A1 = 1, A2 = 2, ScaleGraph = TRUE, PlotGroups = TRUE, PlotVars = TRUE, PlotInd = TRUE, WhatInds = NULL, WhatVars = NULL, WhatGroups = NULL, IndLabels = NULL, VarLabels = NULL, GroupLabels = NULL, AbbreviateLabels = FALSE, LabelInd = TRUE, LabelVars = TRUE, CexGroup = 1, PchGroup = 16, margin = 0.1, AddLegend = FALSE, ShowAxes = FALSE, LabelAxes = FALSE, LabelGroups = TRUE, PlotCircle = TRUE, ConvexHulls = FALSE, TypeCircle = "M", ColorGroups = NULL, ColorVars = NULL, LegendPos = "topright", ColorInd = NULL, voronoi = TRUE, mode = "a", TypeScale = "Complete", ValuesScale = "Original", MinQualityVars = 0, dpg = 0, dpi = 0, dp = 0, PredPoints = 0, PlotAxis = FALSE, CexInd = NULL, CexVar = NULL, PchInd = NULL, PchVar = NULL, ColorVar = NULL, ShowAxis = FALSE, VoronoiColor = "black", ShowBox = FALSE, ShowTitle = TRUE, PlotClus = FALSE, TypeClus = "ch", ClustConf = 1, ClustCenters = FALSE, UseClusterColors = TRUE, CexClustCenters = 1, ...)
## S3 method for class 'MANOVA.Biplot' plot(x, A1 = 1, A2 = 2, ScaleGraph = TRUE, PlotGroups = TRUE, PlotVars = TRUE, PlotInd = TRUE, WhatInds = NULL, WhatVars = NULL, WhatGroups = NULL, IndLabels = NULL, VarLabels = NULL, GroupLabels = NULL, AbbreviateLabels = FALSE, LabelInd = TRUE, LabelVars = TRUE, CexGroup = 1, PchGroup = 16, margin = 0.1, AddLegend = FALSE, ShowAxes = FALSE, LabelAxes = FALSE, LabelGroups = TRUE, PlotCircle = TRUE, ConvexHulls = FALSE, TypeCircle = "M", ColorGroups = NULL, ColorVars = NULL, LegendPos = "topright", ColorInd = NULL, voronoi = TRUE, mode = "a", TypeScale = "Complete", ValuesScale = "Original", MinQualityVars = 0, dpg = 0, dpi = 0, dp = 0, PredPoints = 0, PlotAxis = FALSE, CexInd = NULL, CexVar = NULL, PchInd = NULL, PchVar = NULL, ColorVar = NULL, ShowAxis = FALSE, VoronoiColor = "black", ShowBox = FALSE, ShowTitle = TRUE, PlotClus = FALSE, TypeClus = "ch", ClustConf = 1, ClustCenters = FALSE, UseClusterColors = TRUE, CexClustCenters = 1, ...)
x |
An object of class "MANOVA.Biplot" |
A1 |
Dimension for the first axis. 1 is the default. |
A2 |
Dimension for the second axis. 2 is the default. |
ScaleGraph |
Reescale the coordinates to optimal matching. |
PlotGroups |
Shoud the group centers be plotted? |
PlotVars |
Should the variables be plotted? |
PlotInd |
Should the individuals be plotted? |
WhatInds |
What individuals should be plooted? A vector. |
WhatVars |
What variables should be plooted? A vector. |
WhatGroups |
What groups should be plooted? A vector. |
IndLabels |
Labels for the individuals |
VarLabels |
Labels for the variables |
GroupLabels |
Labels for the groups |
AbbreviateLabels |
Should the labels be Abbreviated for simplicity of the graph? |
LabelInd |
Should the individuaqls be labelled? |
LabelVars |
Should the variables be labelled? |
CexGroup |
Size of the points for groups |
PchGroup |
Mark of the points for groups |
margin |
Margin for labels (in percentage) |
AddLegend |
Should a legend be added? |
ShowAxes |
Should the axes be shown? |
LabelAxes |
Should the axes be labelled? |
LabelGroups |
Should the groups be labelled? |
PlotCircle |
Should the confidence regions for the groups be plotted? |
ConvexHulls |
Should the convex hulls containing the individuals for each group be plotted? |
TypeCircle |
Type of confidence region: Univariate (U), Bonferroni(B), Multivariate (M) or Classical (C) |
ColorGroups |
User colors for the groups. Default colors will be used if NULL. |
ColorVars |
User colors for the variables. Default colors will be used if NULL. |
LegendPos |
Position of the legend. |
ColorInd |
User colors for the individuals. Default colors will be used if NULL. |
voronoi |
Should the voronoi diagram with the prediction regións for each group be plotted? |
mode |
Mode of the biplot: "p", "a", "b", "h", "ah" and "s". |
TypeScale |
Type of scale to use : "Complete", "StdDev" or "BoxPlot" |
ValuesScale |
Values to show on the scale: "Original" or "Transformed" |
MinQualityVars |
Minimum quality of representation for a variable to be plotted |
dpg |
A set of indices with the variables that will show projections onto the variables |
dpi |
A set of indices with the individuals that will show the projections |
dp |
A set of indices with the variables that will show the projections of the individuals |
PredPoints |
A vector with integers. The group centers listed in the vector are projected onto all the variables. |
PlotAxis |
Not Used |
CexInd |
Size of the points for individuals. |
CexVar |
Size of the points for variables. |
PchInd |
Marhers of the points for individuals. |
PchVar |
Markers of the points for variables. |
ColorVar |
Colors of the points for variables. |
ShowAxis |
Should axis scales be shown? |
VoronoiColor |
Color for the Voronoi diagram |
ShowBox |
Should a box around the poitns be plotted? |
ShowTitle |
Should Title be shown? |
PlotClus |
Should the clusters be plotted? |
TypeClus |
Type of cluster to plot (convex hull, ellipse or star) |
ClustConf |
Confidence level for the clusters (percentage plotted) |
ClustCenters |
Should the cluster centres be plotted? |
UseClusterColors |
Use cluster colors for individuals |
CexClustCenters |
Size of the cluster centers |
... |
Any other graphical parameter |
The function plots the results of a MANOVA Biplot. The coordinates for Groups, Individuals and Variables can be shown or not on the plot, each of the three can also be labeled separately. The are parameters to control the way each different set of coordinates is plotted and labeled.
There are several modes for plotting the biplot.
"p".- Points (Rows and Columns are represented by points)
"a" .- Arrows (The traditional representation with points for rows and arrows for columns)
"b" .- The arrows for the columns are extended to both extremes of the plot and labeled outside the plot area.
"h" .- The arrows for the columns are extended to the positive extreme of the plot and labeled outside the plot area.
"ah" .- Same as arrows but labeled outside the plot area.
"s" .- The directions (or biplot axes) have a graded scale for prediction of the original values.
The TypeScale argument applies only to the "s" mode. There are three types:
"Complete" .- An equally spaced scale covering the whole range of the data is calculates.
"StdDev" .- Mean with one, two and three stadard deviations
"BoxPlot" .- Box-Plot like Scale (Median, 25 and 75 percentiles, maximum and minimum values.)
The ValuesScale argument applies only to the "s" mode and controls if the labels show the Original ot Transformed values.
Some of the initial transformations are not compatible with some of the types of biplots and scales. For example, It is not possible to recover by projection the original values when you double centre de data. In that case you have the residuals for interaction and only the transformed values make sense.
A plot is returned
Jose Luis Vicente Villardon, Laura Vicente Gonzalez
Gabriel, K. R. (1972). Analysis of meteorological data by means of canonical decomposition and biplots. Journal of Applied Meteorology, 11(7), 1071-1077.
Amaro, I. R., Vicente-Villardón, J. L., & Galindo Villardón, M. P. (2004). Manova Biplot para arreglos de tratamientos con dos factores basado en modelos lineales generales multivariantes. Interciencia, 29(1), 26-32.
Sierra, C., Ruíz-Barzola, O., Menéndez, M., Demey, J. R., & Vicente-Villardón, J. L. (2017). Geochemical interactions study in surface river sediments at an artisanal mining area by means of Canonical (MANOVA)-Biplot. Journal of Geochemical Exploration, 175, 72-81.
data(wine) X=wine[,4:21] manbip=MANOVA(X, Group=wine$Group) plot(manbip, TypeCircle="U", Voronoi=FALSE)
data(wine) X=wine[,4:21] manbip=MANOVA(X, Group=wine$Group) plot(manbip, TypeCircle="U", Voronoi=FALSE)
Plots the principal coordinates of the group centers a the bootstrap confidence regions.
## S3 method for class 'PERMANOVA' plot(x, A1 = 1, A2 = 2, ScaleGraph = TRUE, ShowAxis = FALSE, ShowAxes = FALSE, LabelAxes = TRUE, margin = 0.1, ShowBox = TRUE, PlotGroups = TRUE, LabelGroups = TRUE, CexGroup = 1.5, PchGroup = 16, ColorGroup = NULL, voronoi = TRUE, VoronoiColor = "black", PlotInd = FALSE, LabelInd = TRUE, CexInd = 0.8, PchInd = 3, ColorInd = NULL, WhatInds = NULL, IndLabels = NULL, PlotVars = TRUE, LabelVar = TRUE, CexVar = NULL, PchVar = NULL, ColorVar = NULL, WhatVars = NULL, VarLabels = NULL, mode = "a", TypeScale = "Complete", ValuesScale = "Original", SmartLabels = TRUE, AddLegend = TRUE, LegendPos = "topright", PlotCircle = TRUE, ConvexHulls = FALSE, TypeCircle = "M", MinQualityVars = 0, dpg = 0, dpi = 0, PredPoints = 0, PlotClus = TRUE, TypeClus = "ch", ClustConf = 1, CexClustCenters=1,ClustCenters = FALSE, UseClusterColors = TRUE, ...)
## S3 method for class 'PERMANOVA' plot(x, A1 = 1, A2 = 2, ScaleGraph = TRUE, ShowAxis = FALSE, ShowAxes = FALSE, LabelAxes = TRUE, margin = 0.1, ShowBox = TRUE, PlotGroups = TRUE, LabelGroups = TRUE, CexGroup = 1.5, PchGroup = 16, ColorGroup = NULL, voronoi = TRUE, VoronoiColor = "black", PlotInd = FALSE, LabelInd = TRUE, CexInd = 0.8, PchInd = 3, ColorInd = NULL, WhatInds = NULL, IndLabels = NULL, PlotVars = TRUE, LabelVar = TRUE, CexVar = NULL, PchVar = NULL, ColorVar = NULL, WhatVars = NULL, VarLabels = NULL, mode = "a", TypeScale = "Complete", ValuesScale = "Original", SmartLabels = TRUE, AddLegend = TRUE, LegendPos = "topright", PlotCircle = TRUE, ConvexHulls = FALSE, TypeCircle = "M", MinQualityVars = 0, dpg = 0, dpi = 0, PredPoints = 0, PlotClus = TRUE, TypeClus = "ch", ClustConf = 1, CexClustCenters=1,ClustCenters = FALSE, UseClusterColors = TRUE, ...)
x |
An object of class "PERMANOVA" |
A1 |
Dimension for the first axis. 1 is the default. |
A2 |
Dimension for the second axis. 2 is the default. |
ScaleGraph |
Resale the coordinates to optimal matching. |
ShowAxis |
Should the axis passing trough the origin be plotted? |
ShowAxes |
Should the axes be shown? |
LabelAxes |
Should the axes be labelled? |
margin |
Margin for labels (in percentage). |
ShowBox |
Should a box around the points be plotted? |
PlotGroups |
Should the group centers be plotted? |
LabelGroups |
Should the groups be labelled? |
CexGroup |
Size of the points for groups. |
PchGroup |
Mark of the points for groups. |
ColorGroup |
User colors for the groups. Default colors will be used if NULL. |
voronoi |
Should the Voronoi diagram with the prediction regions for each group be plotted? |
VoronoiColor |
Color for the Voronoi diagram. |
PlotInd |
Should the individuals be plotted? |
LabelInd |
Should the individuals be labelled? |
CexInd |
Size of the points for individuals. |
PchInd |
Markers of the points for individuals. |
ColorInd |
User colors for the individuals. Default colors will be used if NULL. |
WhatInds |
What individuals should be plotted? A vector. |
IndLabels |
Labels for the individuals. |
PlotVars |
Should the variables be plotted? |
LabelVar |
Should the variables be labelled? |
CexVar |
Size of the points for variables. |
PchVar |
Markers of the points for variables. |
ColorVar |
Colors of the points for variables. |
WhatVars |
What variables should be plotted? A vector. |
VarLabels |
Labels for the variables. |
mode |
Mode of the biplot: "p", "a", "b", "h", "ah" and "s". |
TypeScale |
Type of scale to use : "Complete", "StdDev" or "BoxPlot". |
ValuesScale |
Values to show on the scale: "Original" or "Transformed". |
SmartLabels |
Should the labels be plotted in a smart way? |
AddLegend |
Should a legend be added? |
LegendPos |
Position of the legend. |
PlotCircle |
Should the confidence regions for the groups be plotted? |
ConvexHulls |
Should the convex hulls containing the individuals for each group be plotted? |
TypeCircle |
Type of confidence region: Univariate (U), Bonferroni(B), Multivariate (M) or Classical (C). By default is "M". |
MinQualityVars |
Minimum quality of representation for a variable to be plotted. |
dpg |
A set of indices with the variables that will show projections onto the variables. |
dpi |
A set of indices with the individuals that will show the projections. |
PredPoints |
A vector with integers. The group centers listed in the vector are projected onto all the variables. |
PlotClus |
Should the clusters be plotted? |
TypeClus |
Type of plot for the clusters. ("ch"- Convex Hull, "el"- Ellipse or "st"- Star) |
ClustConf |
Percent of points included in the cluster. only the ClusConf percent of the points nearest to the center will be used to calculate the cluster. |
CexClustCenters |
Size of the cluster centers. |
ClustCenters |
Should the cluster centers be plotted. |
UseClusterColors |
Should the cluster colors be used in the plot. |
... |
Any other graphical parameter. |
Plots the principal coordinates of the group centers a the bootstrap confidence regions.
The plot.
Laura Vicente-Gonzalez, Jose Luis Vicente-Villardon
data(wine) X = wine[,4:21] X=IniTransform(X) D = DistContinuous (X) perwine=PERMANOVA(D, wine$Group, CoordPrinc=TRUE) plot(perwine)
data(wine) X = wine[,4:21] X=IniTransform(X) D = DistContinuous (X) perwine=PERMANOVA(D, wine$Group, CoordPrinc=TRUE) plot(perwine)
Highlights several groups or clusters on a biplot representation.
PlotClustersBiplot(A, Groups = Ones(c(nrow(A), 1)), TypeClus = "st", ClusterColors = NULL, ClusterNames = NULL, centers = TRUE, ClustConf = 1, Legend = FALSE, LegendPos = "topright", CexClustCenters = 1, ...)
PlotClustersBiplot(A, Groups = Ones(c(nrow(A), 1)), TypeClus = "st", ClusterColors = NULL, ClusterNames = NULL, centers = TRUE, ClustConf = 1, Legend = FALSE, LegendPos = "topright", CexClustCenters = 1, ...)
A |
Coordinates of the points in the scattergram. |
Groups |
Factor defining the groups to be highlighted. |
TypeClus |
Type of representation of the clusters. For the moment just a convex hull but in the future ellipses and stars will be added. |
ClusterColors |
A vector of colors with as many elements as clusters. If |
ClusterNames |
A vector of names with as many elements as clusters. |
centers |
Logical variable to control if centres of the clusters are plotted. |
ClustConf |
Percent of points included in the cluster. Only the ClusConf percent of the points nearest to the center will be used to calculate the cluster. |
Legend |
Should a legend be plotted? |
LegendPos |
Position of the legend. |
CexClustCenters |
Size of the centers. |
... |
Any other graphical parameters. |
The clusters to plot should be added to the biplot object using the function AddClusterToBiplot
.
It takes effects on a plot.
Jose Luis Vicente-Villardon
Creates a contrast C matrix of post hoc comparisons among groups.
PostHocComp(grupo)
PostHocComp(grupo)
grupo |
A factor containing the groups or treatments. |
Creates a contrast C matrix of post hoc comparisons among groups. The rows of the contrast matrix are not orthogonal.
The PostHocComp function return a matrix to compare the levels of groups introduced.
Laura Vicente-Gonzalez and Jose Luis Vicente-Villardon
data(wine) PostHocComp(wine$Group)
data(wine) PostHocComp(wine$Group)
Simple Procrustes Analysis for two matrices
ProcrustesSimple(X, Y, centre = FALSE)
ProcrustesSimple(X, Y, centre = FALSE)
X |
Matrix of the first configuration. |
Y |
Matrix of the second configuration. |
centre |
Should the matrices be centered before the calculations? |
Orthogonal Procrustes Analysis for two configurations X and Y. The first configuration X is used as a reference and the second, Y, is transformed to match the reference as much as possible. X = s Y T + 1t +E = Z + E
An object of class Procrustes
.This has components:
X |
First Configuration. |
Y |
Second Configuration. |
Yrot |
Second Configuration after the transformation. |
T |
Rotation Matrix. |
t |
Translation Vector. |
s |
Scale Factor. |
rsss |
Residual Sum of Squares. |
fit |
Goodness of fit as percent of explained variance. |
correlations |
Correlations among the columns of X and Z. |
Jose Luis Vicente-Villardon
Ingwer Borg, I. & Groenen, P. J.F. (2005). Modern Multidimensional Scaling. Theory and Applications. Second Edition. Springer
Hunting spiders data transformed into Presence/Absence.
data("spiders")
data("spiders")
A data frame with 28 observations of presence/absence on the following 12 hunting spider species.
Alopacce
a factor with levels Absent
Present
of the species Alopecosa accentuata.
Alopcune
a factor with levels Absent
Present
of the species Alopecosa cuneata.
Alopfabr
a factor with levels Absent
Present
of the species Alopecosa fabrilis.
Arctlute
a factor with levels Absent
Present
of the species Arctosa lutetiana.
Arctperi
a factor with levels Absent
Present
of the species Arctosa perita.
Auloalbi
a factor with levels Absent
Present
of the species Aulonia albimana.
Pardlugu
a factor with levels Absent
Present
of the species Pardosa lugubris.
Pardmont
a factor with levels Absent
Present
of the species Pardosa monticola.
Pardnigr
a factor with levels Absent
Present
of the species Pardosa nigriceps.
Pardpull
a factor with levels Absent
Present
of the species Pardosa pullata.
Trocterr
a factor with levels Absent
Present
of the species Trochosa terricola.
Zoraspin
a factor with levels Absent
Present
of the species Zora spinimana.
van der Aart, P. J. M., and Smeenk-Enserink, N. (1975) Correlations between distributions of hunting spiders (Lycos- idae, Ctenidae) and environmental characteristics in a dune area. Netherlands Journal of Zoology 25, 1-45.
data(spiders)
data(spiders)
Hunting spiders data transformed into 1/0.
data("spidersb")
data("spidersb")
A data frame with 28 observations of presence/absence of 12 hunting spider species
Presence/Absence of the species Alopecosa accentuata
Presence/Absence of the species Alopecosa cuneata
Presence/Absence of the species Alopecosa fabrilis
Presence/Absence of the species Arctosa lutetiana
Presence/Absence of the species Arctosa perita
Presence/Absence of the species Aulonia albimana
Presence/Absence of the species Pardosa lugubris
Presence/Absence of the species Pardosa monticola
Presence/Absence of the species Pardosa nigriceps
Presence/Absence of the species Pardosa pullata
Presence/Absence of the species Trochosa terricola
Presence/Absence of the species Zora spinimana
van der Aart, P. J. M., and Smeenk-Enserink, N. (1975) Correlations between distributions of hunting spiders (Lycos- idae, Ctenidae) and environmental characteristics in a dune area. Netherlands Journal of Zoology 25, 1-45.
data(spidersb)
data(spidersb)
Summarizes the results of a Bootstrap Manova based on distances.
## S3 method for class 'BootDisMANOVA' summary(object, Latex = FALSE, ...)
## S3 method for class 'BootDisMANOVA' summary(object, Latex = FALSE, ...)
object |
An object of class "BootDisMANOVA". |
Latex |
Should Latex tables be provided? |
... |
Any other parameter. |
Summarizes the results of a Bootstrap Manova based on distances including Latex tables.
Prints the results.
Laura Vicente-Gonzalez, Jose Luis Vicente-Villardon
data(wine) X = wine[,4:21] D = DistContinuous (X) bootwine=BootDisMANOVA(D, wine$Group) summary(bootwine)
data(wine) X = wine[,4:21] D = DistContinuous (X) bootwine=BootDisMANOVA(D, wine$Group) summary(bootwine)
Plots labels of points in a scattergram. labels for points with positive x
are placed on the right of
the points, and labels for points with negative values on the left.
TextSmart(A, Labels, CexPoints = 1, ColorPoints = "black", ...)
TextSmart(A, Labels, CexPoints = 1, ColorPoints = "black", ...)
A |
Coordinates of the points for the scattergram. |
Labels |
Labels for the points. |
CexPoints |
Size of the labels. |
ColorPoints |
Colors of the labels. |
... |
Additional graphical arguments. |
The function is used to improve the readability of the labels in a scattergram.
No value returned.
Jose Luis Vicente-Villardon
Comparison of young wines of Ribera de Duero and Toro.
data("wine")
data("wine")
A data frame with 45 observations on the following 21 variables.
Year
A factor with levels 1986
1987
Origin
A factor with levels Ribera
Toro
Group
A factor with levels R86
R87
T86
T87
A
Alcoholic content (percentage)
VA
volatil acidity - g acetic acid/l
TA
Total tritable acidity - g tartaric acid/l
FA
Fixed acidity - g tartaric acid/l
pH
pH
TPR
Total phenolics - g gallic acid /l - Folin
TPS
Total phenolics - Somers
V
Substances reactive to vanilin - mg catechin/l
PC
Procyanidins - mg cyanidin/l
ACR
Total Anthocyanins - mg/l - method 1
ACS
Total Anthocyanins - mg/l - methods 2
ACC
Malvidin - malvidin-3-glucoside mg/l
CI
Color density -
CI2
Color density 2
H
Wine Hue Color
I
Degree of Ionization - Percent
CA
Chemical Age
VPC
ratio V/PC
Comparison of young wines of Ribera de Duero and Toro.
Rivas-Gonzalo, J. C., Gutierrez, Y., Polanco, A. M., Hebrero, E., Vicente-Villardon, J. L., Galindo, P., & Santos-Buelga, C. (1993). Biplot analysis applied to enological parameters in the geographical classification of young red wines. American journal of enology and viticulture, 44(3), 302-308.
Rivas-Gonzalo, J. C., Gutierrez, Y., Polanco, A. M., Hebrero, E., Vicente-Villardon, J. L., Galindo, P., & Santos-Buelga, C. (1993). Biplot analysis applied to enological parameters in the geographical classification of young red wines. American journal of enology and viticulture, 44(3), 302-308.
data(wine)
data(wine)
Matrix of zeros as in Matlab.
Zeros(n)
Zeros(n)
n |
Dimension of the matrix. |
A matrix of zeros.
Jose Luis Vicente-Villardon
Zeros(6)
Zeros(6)