Learn R Programming

robust (version 0.3-0)

cov: Classical Covariance Estimation

Description

Computes an estimate of the covariance/correlation matrix and location vector using classical methods.

Usage

cov(data, corr = FALSE, center = TRUE, distance = TRUE, na.action = na.fail, unbiased = TRUE)

Arguments

data
a numeric matrix or data frame containing the data.
corr
a logical flag. If corr = TRUE then the estimated correlation matrix is computed.
center
a logical flag or a numeric vector of length p (where p is the number of columns of x) specifying the center. If center = TRUE then the center is estimated. Otherwise the center is taken to be 0.
distance
a logical flag. If distance = TRUE the Mahalanobis distances are computed.
na.action
a function to filter missing data. The default na.fail produces an error if missing values are present. An alternative is na.omit which deletes observations that contain one or more missing values.
unbiased
a logical flag. If unbiased = TRUE then an unbiased estimate of the covariance matrix is computed. If unbiased = FALSE then a maximum likelihood estimate is computed.

Value

  • an object of class "cov" with components:
  • callan image of the call that produced the object with all the arguments named.
  • cova numeric matrix containing the estimate of the covariance/correlation matrix.
  • centera numeric vector containing the estimate of the location vector.
  • dista numeric vector containing the Mahalanobis distances. Only present if distance = TRUE in the call.
  • corra logical flag. If corr = TRUE then cov contains an estimate of the correlation matrix of x.

Details

This function is intended to produce an object similar to that produced by the covRob in the robust library but fit using classical methods.

See Also

covRob, var, cov.wt.

Examples

Run this code
data(stack.dat)
  cov(stack.dat)

Run the code above in your browser using DataLab