Stata 15 help for storage modes

Title

storage modes -- Storage modes for correlation and covariance matrices

Description

The three storage modes for specifying the correlation or covariance matrix in corr2data and drawnorm will be illustrated with a correlation structure C of 4 variables. In full storage model, this structure can be entered as a 4x4 Stata matrix:

. matrix C = ( 1.0000, 0.3232, 0.1112, 0.0066 \ /// 0.3232, 1.0000, 0.6608, -0.1572 \ /// 0.1112, 0.6608, 1.0000, -0.1480 \ /// 0.0066, -0.1572, -0.1480, 1.0000 )

Elements within a row are separated by commas, and rows are separated by a backslash \. We use the input continuation operator /// for convenient multiline input; see [P] comments. In this storage mode, you probably want to set the row and column names to the variables:

. matrix rownames C = price trunk headroom rep78 . matrix colnames C = price trunk headroom rep78

This correlation structure can be entered more conveniently in one of the two vectorized storage modes. In these modes, you enter the lower triangle or the upper triangle of C in rowwise order; these two storage modes differ only in the order in which the k(k+1)/2 matrix elements are recorded. The lower storage mode for C is comprised of a vector with 4(4+1)/2=10 elements, that is, a 1x10 or 10x1 Stata matrix, with one row or column,

. matrix C = ( 1.0000, /// 0.3232, 1.0000, /// 0.1112, 0.6608, 1.0000, /// 0.0066, -0.1572, -0.1480, 1.0000 )

or more compactly as

. matrix C = ( 1, 0.3232, 1, 0.1112, 0.6608, 1, 0.0066, -0.1572, -0.1480, 1 )

As an alternative vectorization, C may be entered in upper storage mode as a vector with 4(4+1)/2=10 elements, that is, a 1x10 or 10x1 Stata matrix,

. matrix C = ( 1.0000, 0.3232, 0.1112, 0.0066, /// 1.0000, 0.6608, -0.1572, /// 1.0000, -0.1480, /// 1.0000 )

or more compactly as

. matrix C = ( 1, 0.3232, 0.1112, 0.0066, 1, 0.6608, -0.1572, 1, -0.1480, 1 )


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index