Learn R Programming

easyCODA (version 0.40.2)

VAR: Variance of a vector of observations, dividing by n rather than n-1

Description

This function computes the usual variance but divides by n, not by n-1.

Usage

VAR(x)

Value

The value of the variance.

Arguments

x

Vector of values for which variance is computed

Author

Michael Greenacre

Details

To think of each of n observations weighted by 1/n this function VAR computes squared deviations from the mean and averages them. Thus, the sum of squared deviations is divided by n rather than by n-1, as for the unbiased estimate of the variance.

References

Greenacre, M. (2018), Compositional Data Analysis in Practice, Chapman & Hall / CRC.

See Also

LR.VAR, CLOSE

Examples

Run this code
data(cups)
cups <- CLOSE(cups)

# variances using base R function var
apply(cups, 2, var)

# variances using easyCODA function VAR
apply(cups, 2, VAR)

Run the code above in your browser using DataLab