Next: hotellval() Up: Multivariate Macros Help File Previous: goodfit()   Contents

# groupcovar()

Usage:
 ```groupcovar(groups, y), factor or vector of positive integers groups, REAL matrix y with no MISSING values ```

Keywords: covariance, descriptive statistics
```groupcovar(G, y), where G is a length N factor or vector of positive
integers and y is a REAL N by p data matrix with no MISSING values,
computes group means and the pooled sample covariance matrix for the
groups defined by the elements of G.  It is an error if no group has at
least 2 members.

The result is structure(n:n, means:ybar, covariance:V).
n = vector(n1, ...,ng) is the vector of group sample sizes, where g =
max(G).
ybar is a g by p REAL matrix with ybar[i,] = sample mean for
group i.  When group i is empty, ybar[i,] is all MISSING.
V is the pooled variance-covariance matrix.  When all the groups are
non-empty, V = ((n1-1)*S1 + (n2-1)*S2 + ... + (ng-1)*Sg)/(N - g)
where S1, ..., Sg are the sample variance-covariance matrices for
the g groups.