⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mkmat.hlp

📁 是一个经济学管理应用软件 很难找的 但是经济学学生又必须用到
💻 HLP
字号:
{smcl}
{* 09feb2005}{...}
{cmd:help mkmat}, {cmd:help svmat}, {cmd:help matname} {right:dialogs:  {bf:{dialog mkmat}}  {bf:{dialog svmat}}}
{hline}

{title:Title}

{p2colset 5 25 27 2}{...}
{p2col :{hi:[P] matrix mkmat} {hline 2}}Convert variables to matrix and vice versa{p_end}
{p2colreset}{...}


{title:Syntax}

{p 8 14 2}{cmd:mkmat} {varlist} {ifin}
[{cmd:,} {cmdab:mat:rix:(}{it:matname}{cmd:)} {cmdab:nomis:sing}]

{p 8 14 2}{cmd:svmat} {dtype} {it:A} [{cmd:,}
{cmdab:n:ames:(col}|{cmd:eqcol}|{cmd:matcol}|{it:string}{cmd:)}]

{p 8 16 2}{cmd:matname} {it:A} {it:namelist} [{cmd:,}
{cmdab:r:ows:(}{it:range}{cmd:)} {cmdab:c:olumns:(}{it:range}{cmd:)}
{cmdab:e:xplicit}]


{pstd}
where {it:A} is the name of an existing matrix, {it:type} is a storage type
for new variables, and {it:namelist} is one of

{phang2}1){space 2}a {it:varlist}, i.e., names of existing variables, possibly
	abbreviated;

{phang2}2){space 2}{cmd:_cons} and the names of existing variables, possibly
	abbreviated;

{phang2}3){space 2}arbitrary names when option {cmd:explicit} is specified.

{pstd}
To reset problem-size limits, see {helpb matsize}.


{title:Description}

{pstd}
{cmd:mkmat} stores the variables listed in {it:varlist} in column vectors of
the same name, that is, N x 1 matrices, where N = {cmd:_N}, the number of
observations in the dataset.  Optionally, they can be stored as an N x k
matrix, where k is the number of variables in {it:varlist}.

{pstd}
{cmd:svmat} takes a matrix and stores its columns as new variables.  It is
the reverse of the {cmd:mkmat} command, which creates a matrix from existing
variables.

{pstd}
{cmd:matname} renames the rows and columns of a matrix.  {cmd:matname}
differs from the {cmd:matrix rownames} and {cmd:matrix colnames} commands in
that {cmd:matname} expands {it:varlist} abbreviations and also allows a
restricted range for the rows and columns.  See {helpb matrix rownames}.


{title:Options}

{phang}
{cmd:matrix(}{it:matname}{cmd:)} requests that the vectors be combined
in a matrix, instead of creating the column vectors.

{phang}
{cmd:nomissing} specifies that observations with missing values be
excluded.

{phang}
{cmd:names(}{cmd:col}|{cmd:eqcol}|{cmd:matcol}|{it:string}{cmd:)}
specifies how the new variables are to be named.

{pmore}
{cmd:names(col)} uses the column names of the matrix to name the variables.

{pmore}
{cmd:names(eqcol)} uses the equation names prefixed to the column names.

{pmore}
{cmd:names(matcol)} uses the matrix name prefixed to the column names.

{pmore}
{cmd:names(}{it:string}{cmd:)} names the variables
    {it:string}{hi:1}, {it:string}{hi:2}, ... {it:string}n, where {it:string}
    is a user-specified {it:string} and n is the number of columns of the
    matrix.

{pmore}
If {cmd:names()} is not specified, the variables are named
    {it:A}{hi:1}, {it:A}{hi:2}, ..., where {it:A} is the name of the matrix.

{phang}
{cmd:rows(}{it:range}{cmd:)} and {cmd:columns(}{it:range}{cmd:)}
specify the rows and columns of the matrix to rename.  The number of rows
or columns specified must be equal to the number of names in
{it:namelist}.  If both {cmd:rows()} and {cmd:columns()} are given, the
specified rows are named {it:namelist}, and the specified columns are also
named {it:namelist}.  The range must be given in one of the following forms:

{p 12 26 2}{cmd:rows(.)}{space 5}renames all the rows;{p_end}
{p 12 26 2}{cmd:rows(2..8)}{space 2}renames rows 2 through 8;{p_end}
{p 12 26 2}{cmd:rows(3)}{space 5}renames only row 3;{p_end}
{p 12 26 2}{cmd:rows(4...)}{space 2}renames row 4 to the last row.

{pmore}If neither {cmd:rows()} nor {cmd:columns()} is given,
    {cmd:rows(.)} {cmd:columns(.)} is the default.

{phang}{cmd:explicit} suppresses the expansion of {it:varlist} abbreviations
and omits the verification that the names are those of existing variables.
That is, the names in {it:namelist} are used explicitly and can be any valid
row or column names.


{title:Remarks on {cmd:mkmat}}

{pstd}
{cmd:mkmat} provides a useful addition to Stata's matrix commands, but only
for small datasets.

{pstd}
Stata limits matrices to being no more than {helpb matsize} x {helpb matsize}
which, with your current settings, means {ccl matsize} x {ccl matsize}.
(The upper limit is {ccl max_matsize} x {ccl max_matsize}.)  Such limits make
loading data into matrices generally impractical.

{pstd}
Matrices in statistical applications tend to have dimension k x k, n x k,
and n x n, where k is small and n large.  Terms dealing with data are of the
generic form X'WZ, X: n x k1, W: n x n, Z: n x k2, and thus X'WZ: k1 x k2.  In
statistical formulas, W is given by formula (which is often W=I) and, in fact,
never needs to be stored in its entirety.  Even were it not for Stata's
{cmd:matsize} limit, forming X'WZ from individual matrices is, computerwise,
inefficient.

{pstd}
Stata's {cmd:matrix accum} command directly forms matrices of the form
X'WZ; see {helpb matrix accum}.

{pstd}
Programs for creating data matrices such as {cmd:mkmat} are useful for
pedagogical purposes and in specific applications where Stata's matsize
constraint is not binding.  On the other hand, it is important that general
tools not be implemented in this way.


{title:Examples}

{phang}{cmd:. mkmat mpg}{p_end}
{phang}{cmd:. mkmat foreign weight displ, matrix(X)}{p_end}
{phang}{cmd:. matrix b = invsym(X'*X) * X'*mpg}

{phang}{cmd:. regress mpg weight gear_ratio foreign}{p_end}
{phang}{cmd:. matrix c = e(b)'}{p_end}
{phang}{cmd:. svmat double c, name(bvector)}{p_end}
{phang}{cmd:. list bvector1 in 1/5}

{phang}{cmd:. mkmat bvector1 if bvector1!=.}{p_end}
{phang}{cmd:. matrix list bvector1}{p_end}
{phang}{cmd:. matrix d = bvector1'}{p_end}
{phang}{cmd:. matname d wei gr for _cons, c(.)}{p_end}
{phang}{cmd:. mat list d}


{title:Also see}

{psee}
Manual:  {bf:[P] matrix mkmat}

{psee}
Online:  {helpb matrix}
{p_end}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -