------------------------------------------------------------------------------- help for

covariancemat-------------------------------------------------------------------------------

Generate a matrix of covariances

covariancematvarlist[ifexp] [inrange] [weight], covarmat(mat)

Description

covariancematgenerates a matrix of the covariances of the variables invarlist. The result is a square p-by-p matrix, where p is the number of variables invarlist.

aweights,fweights,pweights, andiweights are allowed;aweightis the default. See help weights.

covariancematwas 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. Ifmatalready exists as a scalar or matrix, it will be overwritten. The row- and column names ofmatwill be the variable names invarlist.

RemarksSince 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 thecommonoption of variancemat of the mahapick package.)This partly replicates functionality and borrows some code from

corrmatby Shannon Driver of Stata Corporation.

Examples

. covariancemat age income numkids, covarmat(m)

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

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

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