Learn R Programming

distributional (version 0.5.0)

variance: Variance

Description

[Stable]

A generic function for computing the variance of an object.

Usage

variance(x, ...)

# S3 method for numeric variance(x, ...)

# S3 method for matrix variance(x, ...)

# S3 method for numeric covariance(x, ...)

Arguments

x

An object.

...

Additional arguments used by methods.

Details

The implementation of variance() for numeric variables coerces the input to a vector then uses stats::var() to compute the variance. This means that, unlike stats::var(), if variance() is passed a matrix or a 2-dimensional array, it will still return the variance (stats::var() returns the covariance matrix in that case).

See Also

variance.distribution(), covariance()