- Home
- CRAN
**compositions**: Compositional Data Analysis**varAcomp**: Variances and covariances of amounts and compositions

# Variances and covariances of amounts and compositions

### Description

Compute the (co)variance matrix in the several approaches of compositional and amount data analysis.

### Usage

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | ```
var(x,...)
## Default S3 method:
var(x, y=NULL, na.rm=FALSE, use, ...)
## S3 method for class 'acomp'
var(x,y=NULL,...,robust=getOption("robust"),
use="all.obs",giveCenter=FALSE)
## S3 method for class 'rcomp'
var(x,y=NULL,...,robust=getOption("robust"),
use="all.obs",giveCenter=FALSE)
## S3 method for class 'aplus'
var(x,y=NULL,...,robust=getOption("robust"),
use="all.obs",giveCenter=FALSE)
## S3 method for class 'rplus'
var(x,y=NULL,...,robust=getOption("robust"),
use="all.obs",giveCenter=FALSE)
## S3 method for class 'rmult'
var(x,y=NULL,...,robust=getOption("robust"),
use="all.obs",giveCenter=FALSE)
cov(x,y=x,...)
## Default S3 method:
cov(x, y=NULL, use="everything",
method=c("pearson", "kendall", "spearman"), ...)
## S3 method for class 'acomp'
cov(x,y=NULL,...,robust=getOption("robust"),
use="all.obs",giveCenter=FALSE)
## S3 method for class 'rcomp'
cov(x,y=NULL,...,robust=getOption("robust"),
use="all.obs",giveCenter=FALSE)
## S3 method for class 'aplus'
cov(x,y=NULL,...,robust=getOption("robust"),
use="all.obs",giveCenter=FALSE)
## S3 method for class 'rplus'
cov(x,y=NULL,...,robust=getOption("robust"),
use="all.obs",giveCenter=FALSE)
## S3 method for class 'rmult'
cov(x,y=NULL,...,robust=getOption("robust"),
use="all.obs",giveCenter=FALSE)
``` |

### Arguments

`x` |
a dataset, eventually of amounts or compositions |

`y` |
a second dataset, eventually of amounts or compositions |

`na.rm` |
see |

`use` |
see |

`method` |
see |

`...` |
further arguments to |

`robust` |
A description of a robust estimator. FALSE for the classical estimators. See robustnessInCompositions for further details. |

`giveCenter` |
If TRUE the center used in the variance calculation is reported as a "center" attribute. This is especially necessary for robust estimations, where a reasonable center can not be computed independently for the me variance calculation. |

### Details

The basic functions of `var`

,
`cov`

are turned to
S3-generics. The original versions are copied to the default
method. This allows us to introduce generic methods to handle
variances and covariances of other data types, such as amounts or
compositions.

If classed amounts or compositions are involved, they are transformed
with their corresponding transforms, using the centered default
transform (`cdt`

). That implies that the variances have to
be interpreded in a log scale level for `acomp`

and
`aplus`

.

We should be aware that variance matrices of compositions
(`acomp`

and `rcomp`

) are
singular. They can be transformed to the correponding nonsingular
variances of ilr or ipt-space by `clrvar2ilr`

.

In R versions older than v2.0.0, `var`

and
`cov`

were defined in package “base” instead of in “stats”.
This might produce some misfunction.

### Value

The variance matrix of x or the covariance matrix of x and y.

### Author(s)

K.Gerald v.d. Boogaart http://www.stat.boogaart.de

### See Also

`cdt`

, `clrvar2ilr`

, `clo`

,
`mean.acomp`

, `acomp`

, `rcomp`

,
`aplus`

, `rplus`

, `variation`

### Examples

1 2 3 4 5 6 7 8 9 10 11 12 13 | ```
data(SimulatedAmounts)
meanCol(sa.lognormals)
var(acomp(sa.lognormals))
var(rcomp(sa.lognormals))
var(aplus(sa.lognormals))
var(rplus(sa.lognormals))
cov(acomp(sa.lognormals5[,1:3]),acomp(sa.lognormals5[,4:5]))
cov(rcomp(sa.lognormals5[,1:3]),rcomp(sa.lognormals5[,4:5]))
cov(aplus(sa.lognormals5[,1:3]),aplus(sa.lognormals5[,4:5]))
cov(rplus(sa.lognormals5[,1:3]),rplus(sa.lognormals5[,4:5]))
cov(acomp(sa.lognormals5[,1:3]),aplus(sa.lognormals5[,4:5]))
svd(var(acomp(sa.lognormals)))
``` |

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker. Vote for new features on Trello.

- acomp: Aitchison compositions
- acomp: Aitchison compositions
- acomparith: Power transform in the simplex
- acomparith: Power transform in the simplex
- acompmargin: Marginal compositions in Aitchison Compositions
- acompmargin: Marginal compositions in Aitchison Compositions
- Activity10: Activity patterns of a statistician for 20 days
- Activity10: Activity patterns of a statistician for 20 days
- Activity31: Activity patterns of a statistician for 20 days
- Activity31: Activity patterns of a statistician for 20 days
- alr: Additive log ratio transform
- alr: Additive log ratio transform
- AnimalVegetation: Animal and vegetation measurement
- AnimalVegetation: Animal and vegetation measurement
- aplus: Amounts analysed in log-scale
- aplus: Amounts analysed in log-scale
- aplusarithm: vectorial arithmetic for data sets with aplus class
- apt: Additive planar transform
- apt: Additive planar transform
- ArcticLake: Artic lake sediment samples of different water depth
- ArcticLake: Artic lake sediment samples of different water depth
- arrows3d: arrows in 3D, based on package rgl
- arrows3d: arrows in 3D, based on package rgl
- asdataframe: Convert "compositions" classes to data frames
- asdataframe: Convert "compositions" classes to data frames
- axis3d: Drawing a 3D coordiante system to a plot, based on package...
- axis3d: Drawing a 3D coordiante system to a plot, based on package...
- balancebase: Compute balances for a compositional dataset.
- balancebase: Compute balances for a compositional dataset.
- barplot: Bar charts of amounts
- barplot: Bar charts of amounts
- Bayesite: Permeabilities of bayesite
- Bayesite: Permeabilities of bayesite
- binary: Treating binary and g-adic numbers
- binary: Treating binary and g-adic numbers
- biplot3d: Three-dimensional biplots, based on package rgl
- biplot3d: Three-dimensional biplots, based on package rgl
- Blood23: Blood samples
- Blood23: Blood samples
- Boxite: Compositions and depth of 25 specimens of boxite
- Boxite: Compositions and depth of 25 specimens of boxite
- boxplot: Displaying compositions and amounts with box-plots
- boxplot: Displaying compositions and amounts with box-plots
- ccomp: Count compositions
- ccomp: Count compositions
- ccompgof: Compositional Goodness of fit test
- ccompgof: Compositional Goodness of fit test
- cdt: Centered default transform
- cdt: Centered default transform
- ClamEast: Color-size compositions of 20 clam colonies from East Bay
- ClamEast: Color-size compositions of 20 clam colonies from East Bay
- ClamWest: Color-size compositions of 20 clam colonies from West Bay
- ClamWest: Color-size compositions of 20 clam colonies from West Bay
- clo: Closure of a composition
- clo: Closure of a composition
- clr: Centered log ratio transform
- clr: Centered log ratio transform
- clr2ilr: Convert between clr and ilr, and between cpt and ipt.
- clr2ilr: Convert between clr and ilr, and between cpt and ipt.
- clusterfinder: Heuristics to find subpopulations of outliers
- clusterfinder: Heuristics to find subpopulations of outliers
- codadendrogram: Dendrogram representation of acomp or rcomp objects
- codadendrogram: Dendrogram representation of acomp or rcomp objects
- coloredbiplot: A biplot providing somewhat easier access to details of the...
- coloredbiplot: A biplot providing somewhat easier access to details of the...
- colorsforoutliers: Create a color/char palette or for groups of outliers
- colorsforoutliers: Create a color/char palette or for groups of outliers
- CompLinModCo: Compositional Linear Model of Coregionalisation
- CompLinModCo: Compositional Linear Model of Coregionalisation
- compmiss: The policy of treatment of missing values in the...
- compmiss: The policy of treatment of missing values in the...
- compOKriging: Compositional Ordinary Kriging
- compOKriging: Compositional Ordinary Kriging
- compositions: library(compositions)
- compositions: library(compositions)
- ConfRadius: Helper to compute confidence ellipsoids
- ConfRadius: Helper to compute confidence ellipsoids
- cor: Correlations of amounts and compositions
- cor: Correlations of amounts and compositions
- Coxite: Compositions, depths and porosities of 25 specimens of coxite
- Coxite: Compositions, depths and porosities of 25 specimens of coxite
- cpt: Centered planar transform
- cpt: Centered planar transform
- DiagnosticProb: Diagnostic probabilities
- DiagnosticProb: Diagnostic probabilities
- dist: Distances in variouse approaches
- dist: Distances in variouse approaches
- ellipses: Draw ellipses
- ellipses: Draw ellipses
- endmemberCoordinates: Recast amounts as mixtures of end-members
- endmemberCoordinates: Recast amounts as mixtures of end-members
- Firework: Firework mixtures
- Firework: Firework mixtures
- fitdirichlet: Fitting a Dirichlet distribution
- fitdirichlet: Fitting a Dirichlet distribution
- fitsamemean: Fit Same Mean Different Variance Model
- fitsamemean: Fit Same Mean Different Variance Model
- gausstest: Classical Gauss Test
- gausstest: Classical Gauss Test
- geometricmean: The geometric mean
- geometricmean: The geometric mean
- getdetectionlimit: Gets the detection limit stored in the data set
- getdetectionlimit: Gets the detection limit stored in the data set
- Glacial: Compositions and total pebble counts of 92 glacial tills
- Glacial: Compositions and total pebble counts of 92 glacial tills
- goftests: Compositional Goodness of fit test
- goftests: Compositional Goodness of fit test
- groupparts: Group amounts of parts
- groupparts: Group amounts of parts
- gsiadd: Internal functions: Parallel operations of single and...
- gsiadd: Internal functions: Parallel operations of single and...
- gsiaddclass: Internal function: give a derived subclass to an object
- gsiaddclass: Internal function: give a derived subclass to an object
- gsicall: Internal functions of the compositions package
- gsicall: Internal functions of the compositions package
- gsiclosespread: Internal functions of the compositions package
- gsiclosespread: Internal functions of the compositions package
- gsicoorinfo: Internal functions of the compositions package
- gsicoorinfo: Internal functions of the compositions package
- gsicsum: Internal function: row and column sums of matrices
- gsidiagExtract: Internal functions: Get the diagonal of a matrix
- gsidiagExtract: Internal functions: Get the diagonal of a matrix
- gsidiagGenerate: Internal functions: Generate a diagonal matrix
- gsidiagGenerate: Internal functions: Generate a diagonal matrix
- gsidrop: Internal functions: A conditional drop
- gsidrop: Internal functions: A conditional drop
- gsieps: Internal variable: Negligible differences
- gsieps: Internal variable: Negligible differences
- gsieq: Internal function: Checking equality of IEEE special numbers
- gsieq: Internal function: Checking equality of IEEE special numbers
- gsiexpandrcomp: Internal function: Scaling rcomp
- gsiexpandrcomp: Internal function: Scaling rcomp
- gsifiltercall: Calling from a function with the own parameters
- gsifiltercall: Calling from a function with the own parameters
- gsigetbalstruct: An auxiliary functions to compute user-defined ilr and ipt...
- gsigetbalstruct: An auxiliary functions to compute user-defined ilr and ipt...
- gsigetD: Interal function: Get number of samples and number of parts...
- gsigetD: Interal function: Get number of samples and number of parts...
- gsiinternal: Environment containing the old gsi functions
- gsiinternal: Environment containing the old gsi functions
- gsiinvperm: Internal function: Invert a permutation
- gsiinvperm: Internal function: Invert a permutation
- gsiisSingleRow: Internal function: Can something be considered as a single...
- gsiisSingleRow: Internal function: Can something be considered as a single...
- gsimap01: Internal functions: Storing integers as reals
- gsimap01: Internal functions: Storing integers as reals
- gsimargin: Internal function: Compute a desired compositional margin
- gsimargin: Internal function: Compute a desired compositional margin
- gsimerge2signary: Auxiliary functions to compute user-defined ilr and ipt...
- gsimerge2signary: Auxiliary functions to compute user-defined ilr and ipt...
- gsipairrelativeMatrix: Internal functions of the compositions package
- gsipairrelativeMatrix: Internal functions of the compositions package
- gsipairs: Internal functions of the compositions package
- gsipairs: Internal functions of the compositions package
- gsiplain: Internal function: Convert to plain vector or matrix
- gsiplain: Internal function: Convert to plain vector or matrix
- gsiplotmargin: Internal functions of the compositions package
- gsiplotmargin: Internal functions of the compositions package
- gsiPrinBal: The canonical basis in the clr plane used for ilr and ipt...
- gsiPrinBal: The canonical basis in the clr plane used for ilr and ipt...
- gsirecode: Internal function: Recode missings with IEEE number and vice...
- gsirecode: Internal function: Recode missings with IEEE number and vice...
- gsireset3d: Internal functions of the compositions package
- gsisimshape: Internal function: Reshape an object to the shape type of...
- gsisimshape: Internal function: Reshape an object to the shape type of...
- gsispreadToIsoSpace: Internal functions of the compositions package
- gsispreadToIsoSpace: Internal functions of the compositions package
- gsisvdsolve: Internal function: Solves singular and non square equation...
- gsisvdsolve: Internal function: Solves singular and non square equation...
- gsitextpanel: Internal function: A panel displaying a label only
- gsitextpanel: Internal function: A panel displaying a label only
- gsivarwithlosts: Internal function: computes variance of compositional data...
- gsivarwithlosts: Internal function: computes variance of compositional data...
- Hongite: Compositions of 25 specimens of hongite
- Hongite: Compositions of 25 specimens of hongite
- HotellingsTsq: Hotellings T square distribution
- HotellingsTsq: Hotellings T square distribution
- HouseholdExp: Household Expenditures
- HouseholdExp: Household Expenditures
- Hydrochem: Hydrochemical composition data set of Llobregat river basin...
- Hydrochem: Hydrochemical composition data set of Llobregat river basin...
- idt: Isometric default transform
- idt: Isometric default transform
- iit: Isometric identity transform
- iit: Isometric identity transform
- ilr: Isometric log ratio transform
- ilr: Isometric log ratio transform
- ilrBase: The canonical basis in the clr plane used for ilr and ipt...
- ilrBase: The canonical basis in the clr plane used for ilr and ipt...
- ilt: Isometric log transform
- ilt: Isometric log transform
- ipt: Isometric planar transform
- ipt: Isometric planar transform
- isAcomp: Check for compositional data type
- isAcomp: Check for compositional data type
- ismahalanobisoutlier: Checking for outliers
- ismahalanobisoutlier: Checking for outliers
- isoportion: Isoportion- and Isoproportion-lines
- isoportion: Isoportion- and Isoproportion-lines
- jura: The jura dataset
- jura: The jura dataset
- kingtetrahedron: Ploting composition into rotable tetrahedron
- kingtetrahedron: Ploting composition into rotable tetrahedron
- Kongite: Compositions of 25 specimens of kongite
- Kongite: Compositions of 25 specimens of kongite
- lines: Draws connected lines from point to point.
- lines: Draws connected lines from point to point.
- logratioVariogram: Empirical variograms for compositions
- logratioVariogram: Empirical variograms for compositions
- lrvgram: vgram2lrvgram
- lrvgram: vgram2lrvgram
- mahalanobisdist: Compute Mahalanobis distances based von robust Estimations
- matmult: inner product for matrices and vectors
- matmult: inner product for matrices and vectors
- matmultacomp: inner product for datasets with a vector space structure
- matmultacomp: inner product for datasets with a vector space structure
- meanAcomp: Mean amounts and mean compositions
- meanAcomp: Mean amounts and mean compositions
- meanrow: The arithmetic mean of rows or columns
- meanrow: The arithmetic mean of rows or columns
- Metabolites: Steroid metabolite patterns in adults and children
- Metabolites: Steroid metabolite patterns in adults and children
- missingProjector: Returns a projector the the observed space in case of...
- missingProjector: Returns a projector the the observed space in case of...
- missingsummary: Classify and summarize missing values in a dataset
- missingsummary: Classify and summarize missing values in a dataset
- mix2compositions: Transformations from 'mixtures' to 'compositions' classes
- mix2compositions: Transformations from 'mixtures' to 'compositions' classes
- mixRead: Reads a data file in a mixR format
- mixRead: Reads a data file in a mixR format
- mvar: Metric summary statistics of real, amount or compositional...
- mvar: Metric summary statistics of real, amount or compositional...
- names: The names of the parts
- names: The names of the parts
- norm: Vector space norm
- norm: Vector space norm
- normalize: Normalize vectors to norm 1
- normalize: Normalize vectors to norm 1
- oneOrDataset: Treating single compositions as one-row datasets
- oneOrDataset: Treating single compositions as one-row datasets
- outlierclassifier: Detect and classify compositional outliers.
- outlierclassifier: Detect and classify compositional outliers.
- outlierplot: Plot various graphics to analyse outliers.
- outlierplot: Plot various graphics to analyse outliers.
- outliers: Analysing outliers in compositions.
- outliers: Analysing outliers in compositions.
- pairwisePlot: Creates a paneled plot like pairs for two different datasets.
- pairwisePlot: Creates a paneled plot like pairs for two different datasets.
- parametricMat: Unique parametrisations for matrices.
- parametricMat: Unique parametrisations for matrices.
- perturbe: Perturbation of compositions
- plot: Ternary diagrams
- plot: Ternary diagrams
- plot3d: plot in 3D based on rgl
- plot3d: plot in 3D based on rgl
- plot3dacomp: 3D-plot of compositional data
- plot3dacomp: 3D-plot of compositional data
- plot3daplus: 3D-plot of positive data
- plot3daplus: 3D-plot of positive data
- plot3drmult: plot in 3D based on rgl
- plot3drmult: plot in 3D based on rgl
- plot3drplus: plot in 3D based on rgl
- plot3drplus: plot in 3D based on rgl
- plotlogratioVariogram: Empirical variograms for compositions
- plotlogratioVariogram: Empirical variograms for compositions
- plotmissingsummary: Plot a Missing Summary
- plotmissingsummary: Plot a Missing Summary
- plotpos: Displaying amounts in scatterplots
- plotpos: Displaying amounts in scatterplots
- PogoJump: Honk Kong Pogo-Jumps Championship
- PogoJump: Honk Kong Pogo-Jumps Championship
- powerofmatrix: power transform of a matrix
- powerofmatrix: power transform of a matrix
- princompacomp: Principal component analysis for Aitchison compositions
- princompacomp: Principal component analysis for Aitchison compositions
- princompaplus: Principal component analysis for amounts in log geometry
- princompaplus: Principal component analysis for amounts in log geometry
- princomprcomp: Principal component analysis for real compositions
- princomprcomp: Principal component analysis for real compositions
- princomprmult: Principal component analysis for real data
- princomprmult: Principal component analysis for real data
- princomprplus: Principal component analysis for real amounts
- princomprplus: Principal component analysis for real amounts
- print: Printing compositional data.
- print: Printing compositional data.
- pwlrPlot: Plots of pairwise logratio against a covariable.
- pwlrPlot: Plots of pairwise logratio against a covariable.
- qqnorm: Normal quantile plots for compositions and amounts
- qqnorm: Normal quantile plots for compositions and amounts
- R2: R square
- R2: R square
- raitchison: Aitchison Distribution
- raitchison: Aitchison Distribution
- ratioLoadings: Loadings of relations of two amounts
- ratioLoadings: Loadings of relations of two amounts
- rcomp: Compositions as elements of the simplex embedded in the...
- rcomp: Compositions as elements of the simplex embedded in the...
- rcomparithm: Arithmetic operations for compositions in a real geometry
- rcomparithm: Arithmetic operations for compositions in a real geometry
- rcompmargin: Marginal compositions in real geometry
- rcompmargin: Marginal compositions in real geometry
- rDirichlet: Dirichlet distribution
- rDirichlet: Dirichlet distribution
- readgeoeas: Reads a data file in a geoeas format
- readgeoeas: Reads a data file in a geoeas format
- replot: Modify parameters of compositional plots.
- replot: Modify parameters of compositional plots.
- rlnorm: The multivariate lognormal distribution
- rlnorm: The multivariate lognormal distribution
- rmahalanobis: Compute distributions of empirical Mahalanobis distances...
- rmahalanobis: Compute distributions of empirical Mahalanobis distances...
- rmult: Simple treatment of real vectors
- rmult: Simple treatment of real vectors
- rmultarithm: vectorial arithmetic for datasets in a classical vector scale
- rmultarithm: vectorial arithmetic for datasets in a classical vector scale
- rmultmatmult: inner product for datasets with vector scale
- rmultmatmult: inner product for datasets with vector scale
- rnorm: Normal distributions on special spaces
- rnorm: Normal distributions on special spaces
- robustness: Handling robustness issues and outliers in compositions.
- robustness: Handling robustness issues and outliers in compositions.
- rplus: Amounts i.e. positive numbers analysed as objects of the real...
- rplus: Amounts i.e. positive numbers analysed as objects of the real...
- rplusarithm: vectorial arithmetic for data sets with rplus class
- rplusarithm: vectorial arithmetic for data sets with rplus class
- rpois: Simulate count compositions without overdispersion
- rpois: Simulate count compositions without overdispersion
- runif: The uniform distribution on the simplex
- runif: The uniform distribution on the simplex
- scalar: Parallel scalar products
- scalar: Parallel scalar products
- scale: Normalizing datasets by centering and scaling
- scale: Normalizing datasets by centering and scaling
- Sediments: Proportions of sand, silt and clay in sediments specimens
- Sediments: Proportions of sand, silt and clay in sediments specimens
- segments: Draws straight lines from point to point.
- segments: Draws straight lines from point to point.
- SerumProtein: Serum Protein compositions of blood samples
- SerumProtein: Serum Protein compositions of blood samples
- ShiftOperators: Shifts of machine operators
- ShiftOperators: Shifts of machine operators
- simplemissingplot: Ternary diagrams
- simplemissingplot: Ternary diagrams
- SimulatedAmounts: Simulated amount datasets
- SimulatedAmounts: Simulated amount datasets
- simulatemissing: Artifical simulation of various kinds of missings/polluted...
- simulatemissing: Artifical simulation of various kinds of missings/polluted...
- Skulls: Measurement of skulls
- Skulls: Measurement of skulls
- SkyeAFM: AFM compositions of 23 aphyric Skye lavas
- SkyeAFM: AFM compositions of 23 aphyric Skye lavas
- split: Splitting datasets in groups given by factors
- straight: Draws straight lines.
- straight: Draws straight lines.
- summaryAcomp: Summarizing a compositional dataset in terms of ratios
- summaryAcomp: Summarizing a compositional dataset in terms of ratios
- summaryAplus: Summaries of amounts
- summaryAplus: Summaries of amounts
- summaryRcomp: Summary of compositions in real geometry
- summaryRcomp: Summary of compositions in real geometry
- sumprojector: Compute the global projector to the observed subspace.
- sumprojector: Compute the global projector to the observed subspace.
- Supervisor: Proportions of supervisor's statements assigned to different...
- Supervisor: Proportions of supervisor's statements assigned to different...
- ternaryAxis: Axis for ternary diagrams
- ternaryAxis: Axis for ternary diagrams
- tests: Compositional Goodness of fit test
- tests: Compositional Goodness of fit test
- totals: Total sum of amounts
- totals: Total sum of amounts
- tryDebugger: Empirical variograms for compositions
- ult: Uncentered log transform
- ult: Uncentered log transform
- varAcomp: Variances and covariances of amounts and compositions
- varAcomp: Variances and covariances of amounts and compositions
- variation: Variation matrices of amounts and compositions
- variation: Variation matrices of amounts and compositions
- variograms: Variogram functions
- variograms: Variogram functions
- varmlm: Residual variance of a model
- varmlm: Residual variance of a model
- vcovAcomp: Variance covariance matrix of parameters in compositional...
- vcovAcomp: Variance covariance matrix of parameters in compositional...
- vgmFit: Compositional variogram model fitting
- vgmFit: Compositional variogram model fitting
- WhiteCells: White-cell composition of 30 blood samples by two different...
- WhiteCells: White-cell composition of 30 blood samples by two different...
- Yatquat: Yatquat fruit evaluation
- Yatquat: Yatquat fruit evaluation
- zeroreplace: Zero-replacement routine
- zeroreplace: Zero-replacement routine