Package 'PERMANOVA'

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

Help Index


Add Clusters to a Biplot Object

Description

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.

Usage

AddClusterToBiplot(Bip, NGroups = 3, ClusterType = "hi", Groups = NULL,
Original = FALSE, ...)

Arguments

Bip

A Biplot object obtained from any biplot procedure. It has to be a list containing a field called Bip$RowCoordinates in order to calculate the clusters when necessary.

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 hclust and kmeans procedures.

Details

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.

Value

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 ClusterType.

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 hclust, kmeans or MGC

Author(s)

Jose Luis Vicente-Villardon, Laura Vicente-Gonzalez

References

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.

See Also

For clusters not provided by the user the function uses the standard procedures in hclust and kmeans.


Checks if a vector is binary

Description

Checks if all the entries of a vector are 0 or 1.

Usage

BinaryVectorCheck(x)

Arguments

x

The vector to check

Value

The logical result.

Author(s)

Jose Luis Vicente-Villardon

Examples

x=c(0, 0, 0, 0,  1, 1, 1, 2)
BinaryVectorCheck(x)

Draws a variable on a biplot

Description

Draws a continuous variable on a biplot.

Usage

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, ...)

Arguments

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

Details

See plot.PCA.Biplot

Value

No value returned

Author(s)

Jose Luis Vicente-Villardon


Multivariate Analysis of Variance based on Distances and Bootstrap

Description

Multivariate Analysis of variance based on distances and Bootstrap.

Usage

BootDisMANOVA(Distance, groups, C = NULL, Effects = NULL, nB = 1000, seed = NULL,
CoordPrinc = FALSE, dimens = 2, PCoA = "Standard", ProjectInd = TRUE, tol = 1e-04,
DatosIni = TRUE)

Arguments

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.

Details

Multivariate Analysis of Variance based on distances and Bootstrap.

Value

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.

Author(s)

Laura Vicente-Gonzalez, Jose Luis Vicente-Villardon

References

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.

Examples

data(wine)
X = wine[,4:21]
D = DistContinuous (X)
bootwine=BootDisMANOVA(D, wine$Group)
bootwine

Canonical Analysis based on Distances

Description

Canonical Analysis based on distances. Confidence Regions for the mean vectors are calculated using bootstrap.

Usage

BootDistCanonicalAnalysis(Distance, groups, dimens = NULL, nB = 100, seed = NULL,
PCoA = "Standard", ProcrustesRot = TRUE, DatosIni = TRUE, tol = 1e-04)

Arguments

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

Details

Calculates a Canonical Analysis based on distance matrices with confidence regions based on bootstrap resampling.

Value

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

Author(s)

Laura Vicente-Gonzalez, Jose Luis Vicente-Villardon

References

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.

Examples

data(wine)
X=wine[,4:21]
Dist=DistContinuous(X)
canon=BootDistCanonicalAnalysis(Dist, groups=wine$Group, nB=10)

Draws a circle.

Description

Draws a circle for a given radius at the specified center with the given color.

Usage

Circle2(radius = 1, origin = c(0, 0), col = 1, ...)

Arguments

radius

Radius of the circle.

origin

Centre of the circle.

col

Color of the circle.

...

Additional graphical parameters.

Details

Draws a circle for a given radius at the specified center with the given color.

Value

No value is returned.

Author(s)

Jose Luis Vicente-Villardon

Examples

plot(0,0)
Circle2(1,c(0,0))

Non-parametric concentration ellipses

Description

Calculates non-parametric concentration ellipses for a two-dimensional set of points

Usage

ConcEllipse(data, center = NULL, confidence = 1, npoints = 100)

Arguments

data

A two dimensional set of points.

center

Center of the data.

confidence

Confidence for the concentration ellipse.

npoints

Number of points to plot.

Details

Calculates non-parametric concentration ellipses for a two-dimensional set of points using distances to the center.

Value

data

Original data

confidence

Percent of points selected for the ellipse

ellipse

points to plot the ellipse

center

center of the ellipse

Author(s)

Laura Vicente-Gonzalez, Jose Luis Vicente-Villardon

References

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.

Examples

x=runif(30)
y=x+rnorm(30)*0.3
plot(x, y)
el=ConcEllipse(cbind(x,y), confidence=0.95)
plot(el)

Construction of contrasts for several factors

Description

Constructs the contrasts for main effects and interaction for a dataframe of factors.

Usage

ConstructContrasts(Factors, MaxOrderIter = 2)

Arguments

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.

Details

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.

Value

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.

Author(s)

Jose Luis Vicente-Villardon, Laura Vicente-Gonzalez

References

Bapat, R. B. (2012). Linear algebra and linear models. Springer Science & Business Media.

Examples

ConstructContrasts(wine[,1:2])

Cumulative sums

Description

Cumulative sums.

Usage

Cumsum(X, dimens = 1)

Arguments

X

Data Matrix.

dimens

Dimension for summing.

Details

Cumulative sums within rows (dimens=1) or columns (dimens=2) of a data matrix.

Value

A matrix of the same size as X with cumulative sums within each row or each column.

Author(s)

Jose Luis Vicente-Villardon

Examples

data(wine)
X=wine[,4:21]
Cumsum(X,1)
Cumsum(X,2)

Distances for binary data

Description

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.

Usage

DistBinary(x, y = NULL, coefficient = "Simple_Matching", transformation = "sqrt(1-S)")

Arguments

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.

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)

Value

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.

Author(s)

Laura Vicente-Gonzalez, Jose Luis Vicente-Villardon

References

Gower, J. C. (2006) Similarity dissimilarity and Distance, measures of. Encyclopedia of Statistical Sciences. 2nd. ed. Volume 12. Wiley

Examples

data(spidersb)
DD=DistBinary(spidersb)

Distances among individuals with continuous data

Description

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.

Usage

DistContinuous(x, y = NULL, coef = "Pythagorean", r = 1)

Arguments

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.

Details

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))

Value

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.

Author(s)

Laura Vicente-Gonzalez, Jose Luis Vicente-Villardon

References

Gower, J. C. (2006) Similarity dissimilarity and Distance, measures of. Encyclopedia of Statistical Sciences. 2nd. ed. Volume 12. Wiley

Examples

data(wine)
X = wine[,4:21]
D=DistContinuous(X)

Connects two sets of points by lines

Description

Connects two sets of points by lines in a rowwise manner. Adapted from Graffelman(2013).

Usage

Dlines(SetA, SetB, lin = "dotted", color = "black", ...)

Arguments

SetA

First set of points.

SetB

Second set of points.

lin

Line style.

color

Line color.

...

Any other graphical parameters.

Details

Connects two sets of points by lines.

Value

NULL

Author(s)

Based on Graffelman (2013)

References

Jan Graffelman (2013). calibrate: Calibration of Scatterplot and Biplot Axes. R package version 1.7.2. http://CRAN.R-project.org/package=calibrate

Examples

## No examples

Converts a Factor into its indicator matrix

Description

Converts a factor into a binary matrix with as many columns as categories of the factor.

Usage

FactorToBinary(y, Name = NULL)

Arguments

y

A factor.

Name

Name to use in the final matrix.

Value

An indicator binary matrix.

Author(s)

Jose Luis Vicente-Villardon

Examples

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 biplot

Description

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.

Usage

GetScalesBiplot(Biplot, nticks = 4, TypeScale = "Complete", ValuesScale = "Original")

Arguments

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".

Details

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.

Value

A list with the following components:

Ticks

A list containing the ticks for each variable.

Labels

A list containing the labels for each variable.

Author(s)

Jose Luis Vicente-Villardon


G inverse

Description

Calculates the g-inverse of a squared matrix using the eigen decomposition and removing the eigenvalues smaller than a tolerance.

Usage

Ginv(X, tol = sqrt(.Machine$double.eps))

Arguments

X

Matrix to calculate the g-inverse.

tol

Tolerance.

Details

The function is useful to avoid singularities.

Value

Returns the g-inverse.

Author(s)

Jose Luis Vicente-Villardon

Examples

data(iris)
x=as.matrix(iris[,1:4])
S= t(x) 
Ginv(S)

Checks if a point is inside a box

Description

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).

Usage

inbox(x, y, xmin, xmax, ymin, ymax)

Arguments

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.

Value

Returns a logical value: TRUE if the point is inside the box and FALSE otherwise.

Author(s)

Jose Luis Vicente Villardon

Examples

inbox(0, 0, -1, 1, -1, 1)

Initial transformation of a data matrix

Description

Initial transformation of data before the construction of a biplot (or any other technique).

Usage

IniTransform(X, InitTransform = "None", transform = "Standardize columns")

Arguments

X

Original Raw Data Matrix.

InitTransform

Previous transformation (Logarithm or logit).

transform

Transformation to use. See details.

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.

Value

X

Transformed data matrix.

Author(s)

Jose Luis Vicente-Villardon

References

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)

Examples

data(iris)
x=as.matrix(iris[,1:4])
x=IniTransform(x, transform=4)
x

Multivariate Analysis of Variance (MANOVA)

Description

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.

Usage

MANOVA(Y, Group, C = NULL, M = NULL, Effects = NULL, InitialTransform = 5,
AddOnes = FALSE, Contrasts = TRUE)

Arguments

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.

Details

Performs a general MANOVA to compare several groups or treatments. Additional contrasts can be tested using the contrasts matrix C\bf{C}. 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.

Value

An object of class "MANOVA" and "Canonical.Biplot".

Author(s)

Laura Vicente-Gonzalez, Jose Luis Vicente-Villardon

References

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).

Examples

data(wine)
Y=as.matrix(wine[,4:21])
group=wine$Group
manvin=MANOVA(Y, Group=group)
summary(manvin)

Estimation of the MANOVA parameters.

Description

The function estimates the parameters of the MANOVA for a set of contrasts and a set of linear combinations of the dependent variables.

Usage

MANOVA.Estimation(Y, X, C, M)

Arguments

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.

Details

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.

Value

Returns the main results of the MANOVA.

Author(s)

Jose Luis Vicente-Villardon, Laura Vicente-Gonzalez

References

Seber, G. A. (2009). Multivariate observations (Vol. 252). John Wiley & Sons.


Mixture Gaussian Clustering

Description

Model based clustering using mixtures of gaussian distributions.

Usage

mgc(x, NG = 2, init = "km", RemoveOutliers = FALSE, ConfidOutliers = 0.995,
tolerance = 1e-07, maxiter = 100, show = TRUE, ...)

Arguments

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.

Details

A basic algorithm for clustering with mixtures of gaussians with no restrictions on the covariance matrices.

Value

Clusters.

Author(s)

Jose Luis Vicente-Villardon

Examples

X=as.matrix(iris[,1:4])
mod1=mgc(X,NG=3)
plot(iris[,1:4], col=mod1$Classification)
table(iris[,5],mod1$Classification)

Matrix of ones

Description

Square matrix of ones

Usage

Ones(n)

Arguments

n

Order of the matrix.

Details

Square matrix of ones.

Value

A matrix of ones of order n.

Author(s)

Jose Luis Vicente-Villardon

Examples

Ones(6)

PERMANOVA: MANOVA based on distances

Description

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.

Usage

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")

Arguments

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

Details

The function performs a PERMANOVA Analysis.

Value

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.

Author(s)

Laura Vicente-Gonzalez, Jose Luis Vicente-Villardon

References

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.

Examples

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

Description

Estimation of the PERMANOVA parameters.

Usage

PERMANOVA.Estimation(D, X, C, Effects = NULL)

Arguments

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.

Details

Estimation of the PERMANOVA parameters.

Value

Global

Significance for the global effect

Contrastes

Significance for each contrast

Author(s)

Laura Vicente-Gonzalez, Jose Luis Vicente-Villardon

References

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.


PERMANOVA from a matrix of distancies

Description

This function makes a PERMANOVA from distancies matrix and factor for groups.

Usage

PerMANOVA.Simple(D, grupo, nperm = 999, seed = NULL, C = NULL)

Arguments

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.

Value

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.

Author(s)

Laura Vicente-Gonzalez, Jose Luis Vicente-Villardon

References

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.

Examples

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

Description

Plots the principal coordinates of the group centers and the bootstrap confidence regions.

Usage

## 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, ...)

Arguments

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.

Details

Plots the principal coordinates of the means of the groups with the confidence bootstrap region.

Value

The plot.

Author(s)

Laura Vicente-Gonzalez, Jose Luis Vicente-Villardon


Plot a concentration ellipse

Description

Plot a concentration ellipse obtained from ConcEllipse.

Usage

## S3 method for class 'ellipse'
plot(x, add = TRUE, labeled = FALSE, center = FALSE, centerlabel = "Center",
initial = FALSE, ...)

Arguments

x

An object with class ellipse obtained from ConcEllipse.

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 ...).

Details

Plots an ellipse containing a specified percentage of the data.

Value

No value returned.

Author(s)

Jose Luis Vicente-Villardon

References

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.

See Also

ConcEllipse

Examples

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

Description

Plots the results of a MANOVA Biplot.

Usage

## 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, ...)

Arguments

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.

Details

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.

Value

A plot is returned.

Author(s)

Jose Luis Vicente-Villardon, Laura Vicente-Gonzalez

References

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.

Examples

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

Description

Plots the results of a MANOVA Biplot

Usage

## 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, ...)

Arguments

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

Details

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.

Value

A plot is returned

Author(s)

Jose Luis Vicente Villardon, Laura Vicente Gonzalez

References

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.

Examples

data(wine)
X=wine[,4:21]
manbip=MANOVA(X, Group=wine$Group)
plot(manbip, TypeCircle="U", Voronoi=FALSE)

Plots the results of the PERMANOVA function

Description

Plots the principal coordinates of the group centers a the bootstrap confidence regions.

Usage

## 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, ...)

Arguments

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.

Details

Plots the principal coordinates of the group centers a the bootstrap confidence regions.

Value

The plot.

Author(s)

Laura Vicente-Gonzalez, Jose Luis Vicente-Villardon

Examples

data(wine)
X = wine[,4:21]
X=IniTransform(X)
D = DistContinuous (X)
perwine=PERMANOVA(D, wine$Group, CoordPrinc=TRUE)
plot(perwine)

Plot clusters on a biplot.

Description

Highlights several groups or clusters on a biplot representation.

Usage

PlotClustersBiplot(A, Groups = Ones(c(nrow(A), 1)), TypeClus = "st", ClusterColors =
NULL, ClusterNames = NULL, centers = TRUE, ClustConf = 1, Legend = FALSE, LegendPos =
"topright", CexClustCenters = 1, ...)

Arguments

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 NULL the function selects the rainbow colors.

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.

Details

The clusters to plot should be added to the biplot object using the function AddClusterToBiplot.

Value

It takes effects on a plot.

Author(s)

Jose Luis Vicente-Villardon

See Also

AddClusterToBiplot


Post Hoc pairwise comparisons

Description

Creates a contrast C matrix of post hoc comparisons among groups.

Usage

PostHocComp(grupo)

Arguments

grupo

A factor containing the groups or treatments.

Details

Creates a contrast C matrix of post hoc comparisons among groups. The rows of the contrast matrix are not orthogonal.

Value

The PostHocComp function return a matrix to compare the levels of groups introduced.

Author(s)

Laura Vicente-Gonzalez and Jose Luis Vicente-Villardon

Examples

data(wine)
PostHocComp(wine$Group)

Simple Procrustes Analysis

Description

Simple Procrustes Analysis for two matrices

Usage

ProcrustesSimple(X, Y, centre = FALSE)

Arguments

X

Matrix of the first configuration.

Y

Matrix of the second configuration.

centre

Should the matrices be centered before the calculations?

Details

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

Value

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.

Author(s)

Jose Luis Vicente-Villardon

References

Ingwer Borg, I. & Groenen, P. J.F. (2005). Modern Multidimensional Scaling. Theory and Applications. Second Edition. Springer


Hunting Spiders Data

Description

Hunting spiders data transformed into Presence/Absence.

Usage

data("spiders")

Format

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.

Source

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.

Examples

data(spiders)

Hunting Spiders Data

Description

Hunting spiders data transformed into 1/0.

Usage

data("spidersb")

Format

A data frame with 28 observations of presence/absence of 12 hunting spider species

Alopacce

Presence/Absence of the species Alopecosa accentuata

Alopcune

Presence/Absence of the species Alopecosa cuneata

Alopfabr

Presence/Absence of the species Alopecosa fabrilis

Arctlute

Presence/Absence of the species Arctosa lutetiana

Arctperi

Presence/Absence of the species Arctosa perita

Auloalbi

Presence/Absence of the species Aulonia albimana

Pardlugu

Presence/Absence of the species Pardosa lugubris

Pardmont

Presence/Absence of the species Pardosa monticola

Pardnigr

Presence/Absence of the species Pardosa nigriceps

Pardpull

Presence/Absence of the species Pardosa pullata

Trocterr

Presence/Absence of the species Trochosa terricola

Zoraspin

Presence/Absence of the species Zora spinimana

Source

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.

Examples

data(spidersb)

Summarizes the results of a Bootstrap Manova based on distances

Description

Summarizes the results of a Bootstrap Manova based on distances.

Usage

## S3 method for class 'BootDisMANOVA'
summary(object, Latex = FALSE, ...)

Arguments

object

An object of class "BootDisMANOVA".

Latex

Should Latex tables be provided?

...

Any other parameter.

Details

Summarizes the results of a Bootstrap Manova based on distances including Latex tables.

Value

Prints the results.

Author(s)

Laura Vicente-Gonzalez, Jose Luis Vicente-Villardon

Examples

data(wine)
X = wine[,4:21]
D = DistContinuous (X)
bootwine=BootDisMANOVA(D, wine$Group)
summary(bootwine)

Labels of a Scatter

Description

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.

Usage

TextSmart(A, Labels, CexPoints = 1, ColorPoints = "black", ...)

Arguments

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.

Details

The function is used to improve the readability of the labels in a scattergram.

Value

No value returned.

Author(s)

Jose Luis Vicente-Villardon


Wine data

Description

Comparison of young wines of Ribera de Duero and Toro.

Usage

data("wine")

Format

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

Details

Comparison of young wines of Ribera de Duero and Toro.

Source

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.

References

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.

Examples

data(wine)

Matrix of zeros

Description

Matrix of zeros as in Matlab.

Usage

Zeros(n)

Arguments

n

Dimension of the matrix.

Value

A matrix of zeros.

Author(s)

Jose Luis Vicente-Villardon

Examples

Zeros(6)