------------------------------------------------------------------------------- help for covariancemat -------------------------------------------------------------------------------

Generate a matrix of covariances

covariancemat varlist [if exp] [in range] [weight], covarmat(mat)

Description

covariancemat generates a matrix of the covariances of the variables in varlist. The result is a square p-by-p matrix, where p is the number of variables in varlist.

aweights, fweights, pweights, and iweights are allowed; aweight is the default. See help weights.

covariancemat was written for use by mahapick, mahascore, and mahascores, but may be of use in other circumstances.

Options

covarmat(mat) is required; it specifies the name of the matrix to be created. If mat already exists as a scalar or matrix, it will be overwritten. The row- and column names of mat will be the variable names in varlist.

Remarks

Since the covariances are computed together, they are necessarily computed on the set of observations that are nonmissing for all variables in varlist. Thus, the results may differ from pairwise computations of covariances, depending on the presence of missing values. (This corresponds to the common option of variancemat of the mahapick package.)

This partly replicates functionality and borrows some code from corrmat by Shannon Driver of Stata Corporation.

Examples

. covariancemat age income numkids, covarmat(m)

. covariancemat age income numkids if numkids>0 [aw= wgt1], covarmat(m)

Author David Kantor. Email kantor.d@att.net if you observe any problems.

Also See mahapick, mahascore, mahascores, mahascore2, screenmatches, variancemat, stackids. See mahapick.ado for another example of the use of