Next: daentervar() Up: Multivariate Macros Help File Previous: compf()   Contents

covar()

Usage:
covar(x), REAL matrix x with no MISSING values, returns
  structure(n:sampleSize,mean:xbar,covariance:s)



Keywords: covariance, descriptive statistics
covar(x), where x is a REAL matrix with no MISSING values computes the
sample mean and variance-covariance matrix of x.  It returns
         structure(n:N, mean:xbar, covariance:s)
where N = nrows(x) is the sample size, xbar is a row vector of the
sample means of the columns, and s is the sample variance-covariance
matrix (with divisor N - 1).

Macro covar() is obsolete but is retained for backward compatibility.

Essentially the same output can be obtained from tabs(y, count:T,
covar:T, mean:T) which returns structure(mean:means, covar:s,count:n).
The components of covar() output differ from those of tabs() in three
ways:
 (a) Component names ('covariance' instead of 'covar' and 'n'
     instead of 'count')
 (b) The value of 'mean' is a row vector (1 by ncols(x)) for covar() and
     a (column) vector for tabs()
 (c) The value of covar() component 'n' is the scalar N, while tabs()
     component 'count' is rep(N,ncols(x)), with a count for each column
     of x

See also tabs() and groupcovar().


Gary Oehlert 2003-01-15