📄 matrix_accum.hlp
字号:
{smcl}
{* 09feb2005}{...}
{cmd:help matrix accum}, {cmd:help matrix glsaccum},
{cmd:help matrix vecaccum}, {cmd:help matrix opaccum}
{hline}
{title:Title}
{p2colset 5 25 27 2}{...}
{p2col :{hi:[P] matrix accum} {hline 2}}Form cross-product matrices{p_end}
{p2colreset}{...}
{title:Syntax}
{p 8 25 2}{cmdab:mat:rix} {cmdab:ac:cum} {it:A} {cmd:=} {varlist}
{ifin} {weight}
[{cmd:,} {cmdab:noc:onstant} {cmdab:d:eviations}
{cmdab:m:eans:(}{it:M}{cmd:)}]
{p 8 25 2}{cmdab:mat:rix} {cmdab:glsa:ccum} {it:A} {cmd:=} {varlist}
{ifin} {weight} {cmd:,}
{cmdab:gr:oup:(}{it:groupvar}{cmd:)}
{cmdab:gl:smat:(}{it:W}|{it:stringvar}{cmd:)}
{cmdab:r:ow:(}{it:rowvar}{cmd:)} [{cmdab:noc:onstant}]
{p 8 25 2}{cmdab:mat:rix} {cmd:opaccum} {it:A} {cmd:=} [{varlist}]
{ifin} {cmd:,} {cmdab:gr:oup:(}{it:groupvar}{cmd:)}
{cmdab:op:var:(}{it:opvar}{cmd:)} [{cmdab:noc:onstant}]
{p 8 25 2}{cmdab:mat:rix} {cmdab:veca:ccum} {it:a} {cmd:=} {varlist}
{ifin} {weight} [{cmd:,} {cmdab:noc:onstant}]
{phang}
{cmd:aweight}s, {cmd:fweight}s, {cmd:iweight}s, and {cmd:pweight}s are
allowed; see {help weight}.{p_end}
{phang}
{it:varlist} may contain time-series operators; see {help tsvarlist}.
{title:Description}
{pstd}
{cmd:matrix accum} accumulates cross-product matrices from the data to form
{it:A} = X'X.
{pstd}
{cmd:matrix glsaccum} accumulates cross-product matrices from the data
using a specified inner weight matrix to form {it:A} = X'{it:B}X, where {it:B}
is a block diagonal matrix.
{pstd}
{cmd:matrix opaccum} accumulates cross-product matrices from the data using
an inner weight matrix formed from the outer product of a variable in the
data to form
{center:A = X1'e1e1'X1 + X2'e2e2'X2 + ... + X{it:k}'e{it:k}e{it:k}'X{it:k}}
{pstd}
where X{it:i} is a matrix of observations from the {it:i}th group of the
{it:varlist} variables and e{it:i} is a vector formed from the observations
in the {it:i}th group of the {it:opvar} variable.
{pstd}
{cmd:matrix vecaccum} accumulates the first variable against remaining
variables to form a row vector of accumulated inner products to form
{it:a} = x1'X where X = (x2, x3,...).
{title:Options}
{phang}
{cmd:noconstant} suppresses the addition of a "constant" to the X
matrix. If {cmd:noconstant} is not specified, it is as if a column of 1s is
added to X before the accumulation begins.
{phang}
{cmd:deviations}, allowed only with {cmd:matrix accum}, causes the
accumulation to be performed in terms of deviations from the mean. If
{cmd:noconstant} is not specified, the accumulation of X is done in terms of
deviations, but the added row and column of sums are not in deviation format
(in which case they would be zeros). With {cmd:noconstant} specified, the
resulting matrix divided through by N-1, where N is the number of
observations, is a covariance matrix.
{phang}
{cmd:means(}{it:M}{cmd:)}, allowed only with {cmd:accum}, creates
matrix {it:M}: 1 x (p+1) or 1 x p (depending whether {cmd:noconstant} is also
specified) containing the means of X.
{phang}
{cmd:group(}{it:groupvar}{cmd:)} is required with {cmd:glsaccum} and
{cmd:opaccum} and is not allowed otherwise. In the two cases where it is
required, it specifies the name of a variable that identifies groups of
observations. The data must be sorted by {it:groupvar}.
{pmore}
In {cmd:glsaccum}, {it:groupvar} identifies the observations to be
individually weighted by {cmd:glsmat()}.
{pmore}
In {cmd:opaccum}, {it:groupvar} identifies the observations to be weighted by
the outer product of {cmd:opvar()}.
{phang}
{cmd:glsmat(}{it:W}|{it:stringvar}{cmd:)}, required with
{cmd:glsaccum} and not allowed otherwise, specifies the name of the matrix or
the name of a string variable in the data that contains the name of the matrix
that is to be used to weight the observations in the {cmd:group()}.
{it:stringvar} must be {cmd:str8} or less.
{phang}
{cmd:row(}{it:rowvar}{cmd:)}, required with {cmd:glsaccum} and not
allowed otherwise, specifies the name of a numeric variable containing the row
numbers that specify the row and column of the {cmd:glsmat()} matrix to use in
the inner-product calculation.
{phang}
{cmd:opvar(}{it:opvar}{cmd:)}, required with {cmd:opaccum}, specifies the
variable used to form the vector whose outer product forms the weighting
matrix.
{title:Examples}
{phang}{cmd:. matrix accum XpX = price weight mpg}{p_end}
{phang}{cmd:. matrix accum Cov = price weight mpg, deviations noconstant}
{phang}{cmd:. matrix opaccum A = x1 x2, group(id) opvar(e)}
{title:Also see}
{psee}
Manual: {bf:[P] matrix accum}
{psee}
Online: {helpb matrix}, {helpb ml}
{p_end}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -