help for pwcov

Generate pairwise covariances

pwcov varlist [if exp] [in range] [weight] [, print save ]


pwcov computes the pairwise covariances between a number of variables, using the available observations on each pair of variables to generate the sample covariances. fweights and pweights are allowed.


print indicates that the matrix of covariances be printed.

save indicates that four new variables should be created: pw_t, pw_tk, pw_cov and pw_N. The first two variables give the row and column indices of the covariance, provided in the third variable, while pw_N provides the number of observations used to compute that covariance. These variables are added to the current data set, and must not already exist.


. webuse grunfeld . reshape wide invest mvalue kstock time , i(year) j(company)

. pwcov invest1 invest2 invest3 invest4 invest5, print save


Christopher F. Baum, Boston College baum@bc.edu


The development of this routine was inspired by Peter Gottschalk.

Also see

On-line: pwcorr