📄 _getcovcorr.hlp
字号:
{smcl}
{* 10mar2005}{...}
{cmd:help _getcovcorr} {right:also see: {help undocumented}}
{hline}
{title:Title}
{p 4 21 2}
{cmd:_getcovcorr} {hline 2} Programmer's utility for parsing correlation and
covariance matrix options
{title:Syntax}
{p 8 20 2}
{cmd:_getcovcorr} {it:matname} [ {cmd:,} {it:options} ]
{p2colset 5 26 28 2}{...}
{p2col:{it:options}}description{p_end}
{p2line}
{p2col:{opt cor:relation}}return a correlation matrix{p_end}
{p2col:{opt cov:ariance}}return a covariance matrix{p_end}
{p2col:{opt sh:ape(shape)}}shape (storage method) of {it:matname}{p_end}
{p2col:{opt nam:es(namelist)}}namelist; required with vectorized input{p_end}
{p2col:{opt sds(vector)}}vector of standard deviations{p_end}
{p2col:{opt me:ans(vector)}}vector of means{p_end}
{p2col:{opt force}}fixes input problems (see below){p_end}
{p2line}
{p2col:{it:shape}}{it:matname} is stored as a{p_end}
{p2line}
{p2col:{opt f:ull}}square symmetric matrix{p_end}
{p2col:{opt l:ower}}vector of rowwise lower triangle (with diagonal){p_end}
{p2col:{opt u:pper}}vector of rowwise lower triangle (with diagonal){p_end}
{p2line}
{p2colreset}{...}
{title:Description}
{pstd}
{cmd:_getcovcorr} processes the options related to correlation or covariance
matrices, checks for errors, and returns the information in standard form in
{cmd:r()}. The options processed by {cmd:_getcovcorr} allow users to specify
the correlation or covariance matrix {it:matname} in several ways. It can be
a square symmetric matrix or a vector representing the lower or upper triangle
of the matrix.
{title:Options}
{phang}
{opt correlation} and {opt covariance}
declare that a correlation or covariance matrix is to be returned in
{cmd:r(C)} and that {cmd:r(Ctype)} is to be set to "{cmd:correlation}" or
"{cmd:covariance}", respectively.
{pmore}
By default, if {it:matname} represents a correlation matrix, a correlation
matrix will be returned. Likewise, if {it:matname} represents a
covariance matrix, a covariance matrix will be returned.
{cmd:correlation} and {cmd:covariance} may be used to override the
default.
{pmore}
If {it:matname} represents a correlation matrix, and you specify the
{cmd:covariance} option, then you must also provide the standard
deviations with the {cmd:sds()} option.
{phang}
{opt shape(mode)}
specifies the shape or storage method for the covariance or correlation
matrix {it:matname}. The following storage methods are supported:
{phang2}
{opt full}
specifies that {it:matname} is stored as a symmetric {it:k}x{it:k} matrix.
{phang2}
{opt lower}
specifies that {it:matname} is stored in a vector in rowwise
lower-triangle order. The vector is verified to have {it:k}({it:k}+1)/2
elements (representing {it:k} variables), and are placed in the following
order:
{pin3}
C(11) C(21) C(22) C(31) C(32) C(33) ... C({it:k}1)
C({it:k}2) ... C({it:k}{it:k})
{phang2}
{opt upper}
specifies that {it:matname} is recorded in a vector in rowwise
upper-triangle order. The vector is verified to have {it:k}({it:k}+1)/2
elements (representing {it:k} variables), and are placed in the following
order:
{pin3}
C(11) C(12) C(13) ... C(1{it:k})
C(22) C(23) ... C(2{it:k}) ... C({it:k}-1{it:k}-1)
C({it:k}-1{it:k}) C({it:k}{it:k})
{pmore}
Specifying {cmd:shape(full)} is optional if {it:matname} is square.
Specifying either {cmd:shape(lower)} or {cmd:shape(upper)} is required
for the vectorized storage methods. See {help storage_modes} for examples.
{phang}
{opt names(namelist)}
specifies a list of {it:k} different names for the row and column names of
{cmd:r(C)}. {cmd:names()} is required with {cmd:cstorage(lower)} or
{cmd:cstorage(upper)}. {opt names()} implies {opt force}.
{phang}
{opt sds(vector)},
a row or column vector with {it:k} positive elements, specifies the
standard deviations, and is allowed only when {it:matname} is represented
as a correlation matrix. The standard deviations are returned in the row
vector {cmd:r(sds)}.
{phang}
{opt means(vector)},
a row or column vector with {it:k} elements, specifies the means
corresponding with the correlation or covariance matrix. This is not used
in the construction of {cmd:r(C)}, but is checked for conformability.
The means are returned in the row vector {cmd:r(means)}.
{phang}
{opt force} suppresses the check that matrix name stripes match. The option
{opt names()} automatically implies {opt force}.
{title:Remarks}
{pstd}
{cmd:_getcovcorr} does the following.
{phang}
1. If {it:matname} is a vector, the corresponding full symmetric matrix is
constructed. This matrix may represent either a covariance or correlation
matrix.
{phang}
2. From the input covariance or correlation matrix one of the following is
constructed.
{phang2}
A. A correlation matrix (if {cmd:correlation} was specified).
{phang2}
B. A covariance matrix (if {cmd:covariance} was specified). If
{it:matname} represents a correlation matrix, then a covariance is
constructed from {it:matname} using the standard deviations provided
by {cmd:sds()}.
{pmore}
The resulting matrix is checked for symmetry and that diagonal elements
are strictly positive (1 if {cmd:correlation}).
{phang}
3. An error message is produced if {it:matname}, {cmd:sds()}, or
{cmd:means()} contain {help missing:missing values} or are not
conformable. Unless {cmd:force} or {cmd:names()} are specified, an error
is also produced if the name stripes do not agree.
{phang}
4. {cmd:r(means)} and {cmd:r(sds)} are returned as row vectors if
{cmd:means()} and {cmd:sds()} are specified.
{title:Saved results}
{cmd:_getcovcorr} save in {cmd:r()}:
Macro
{cmd:r(Ctype)} {cmd:correlation} or {cmd:covariance}
Matrices
{cmd:r(C)} The correlation or covariance matrix
{cmd:r(sds)} vector of std deviations (if {cmd:sds()} specified)
{cmd:r(means)} vector of means (if {cmd:means()} specified)
{title:Also see}
{psee}
Online: {helpb factor},
{helpb pca}
{p_end}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -