Stata 15 help for matlist

[P] matlist -- Display a matrix and control its format

Syntax

One common display format for every column

matlist matrix_exp [, style_options general_options]

Each column with its own display format

matlist matrix_exp , cspec(cspec) rspec(rspec) [general_options]

style_options Description ------------------------------------------------------------------------- lines(lstyle) lines style; default between headers/labels and data border(bspec) border style; default none border same as border(all) format(%fmt) display format; default is format(%9.0g) twidth(#) row-label width; default is twidth(12) left(#) left indent for tables; default is left(0) right(#) right indent for tables; default is right(0) -------------------------------------------------------------------------

lstyle Lines are drawn ... ------------------------------------------------------------------------- oneline between headers/labels and data; default with no equations eq between equations; default when equations are present rowtotal same as oneline plus line before last row coltotal same as oneline plus line before last column rctotal same as oneline plus line before last row and column rows between all rows; between row labels and data columns between all columns; between column header and data cells between all rows and columns none suppress all lines -------------------------------------------------------------------------

bspec Border lines are drawn ... ------------------------------------------------------------------------- none no border lines are drawn; the default all around all four sides rows at the top and bottom columns at the left and right left at the left right at the right top at the top bottom at the bottom -------------------------------------------------------------------------

general_options Description ------------------------------------------------------------------------- title(string) title displayed above table tindent(#) indent title # spaces rowtitle(string) title to display above row names names(rows) display row names names(columns) display column names names(all) display row and column names; the default names(none) suppress row and column names nonames same as names(none) showcoleq(ceq) specify how column equation names are displayed roweqonly display only row equation names coleqonly display only column equation names colorcoleq(txt|res) display mode (color) for column equation names; default is txt keepcoleq keep columns of the same equation together aligncolnames(ralign) right-align column names aligncolnames(lalign) left-align column names aligncolnames(center) center column names noblank suppress blank line before tables nohalf display full matrix even if symmetric nodotz display missing value .z as blank underscore display underscores as blanks in row and column names linesize(#) overrule linesize setting -------------------------------------------------------------------------

ceq Equation names are displayed ------------------------------------------------------------------------- first over the first column only; the default each over each column combined centered over all associated columns lcombined left-aligned over all associated columns rcombined right-aligned over all associated columns -------------------------------------------------------------------------

Description

matlist displays a matrix, allowing you to control the display format. Row and column names are used as the row and column headers. Equation names are displayed in a manner similar to estimation results.

Columns may have different formats, and lines may be shown between each column. You cannot format rows of the matrix differently.

matlist is an extension of the matrix list command (see [P] matrix utility).

Style options

lines(lstyle) specifies where lines are drawn in the display of matrix_exp. The following values of lstyle are allowed:

oneline draws lines separating the row and column headers from the numerical entries. This is the default if the matrix_exp has no equation names.

eq draws horizontal and vertical lines between equations. This is the default if the matrix_exp has row or column equation names.

rowtotal is the same as oneline and has a line separating the last row (the totals) from the rest.

coltotal is the same as oneline and has a line separating the last column (the totals) from the rest.

rctotal is the same as oneline and has lines separating the last row and column (the totals) from the rest.

rows draws horizontal lines between all rows and one vertical line between the row-label column and the first column with numerical entries.

columns draws vertical lines between all columns and one horizontal line between the headers and the first numeric row.

cells draws horizontal and vertical lines between all rows and columns.

none suppresses all horizontal and vertical lines.

border[(bspec)] specifies the type of border drawn around the table. bspec is any combination of the following values:

none draws no outside border lines; the default all draws all four outside border lines rows draws horizontal lines in the top and bottom margins columns draws vertical lines in the left and right margins left draws a line in the left margin right draws a line in the right margin top draws a line in the top margin bottom draws a line in the bottom margin

border without an argument is equivalent to border(all), or, equivalently, border(left right top bottom).

format(%fmt) specifies the format for displaying the individual elements of the matrix. The default is format(%9.0g).

twidth(#) specifies the width of the row-label column (first column). The default is twidth(12).

left(#) specifies that the table be indented # spaces; the default is left(0). To indent the title, see the tindent() option.

right(#) specifies that the right margin of the table be # spaces in from the page margin. The default is right(0). The right margin affects the number of columns that are displayed before wrapping.

General options

title(string) adds string as the title displayed before the matrix. matlist has no default title or header.

tindent(#) specifies the indentation for the title; the default is tindent(0).

rowtitle(string) specifies that string be used as a column header for the row labels. This option is allowed only when both row and column labels are displayed.

names(rows|columns|all|none) specifies whether the row and column names are displayed; the default is names(all), which displays both.

nonames suppresses row and column names and is a synonym for names(none).

showcoleq(ceq) specifies how column equation names are displayed. The following ceq are allowed:

first displays an equation name over the first column associated with the name; this is the default.

each displays an equation name over each column.

combined displays an equation name centered over all columns associated with that name.

lcombined displays an equation name left-aligned over all columns associated with that name.

rcombined displays an equation name right-aligned over all columns associated with that name.

If necessary, equation names are truncated to the width of the field in which the names are displayed. With combined, lcombined, and rcombined, the field comprises all columns and the associated separators for the equation.

roweqonly specifies that only row equation names be displayed in the output. This option may not be combined with names(columns), names(none), or nonames.

coleqonly specifies that only column equation names be displayed in the output. This option may not be combined with names(rows), names(none), or nonames.

colorcoleq(txt|res) specifies the mode (color) used for the column equation names that appear in the first displayed row. Specifying txt (the default) displays the equation name in the same color used to display text. Specifying res displays the name in the same color used to display results.

keepcoleq specifies that columns of the same equation should be kept together if possible.

aligncolnames(ralign|lalign|center) specifies the alignment for the column names. ralign indicates alignment to the right, lalign indicates alignment to the left, and center indicates centering. aligncolnames(ralign) is the default.

noblank suppresses printing a blank line before the matrix. This is useful in programs.

nohalf specifies that, even if the matrix is symmetric, the full matrix be printed. The default is to print only the lower triangle in such cases.

nodotz specifies that .z missing values should be listed as a field of blanks rather than as .z.

underscore converts underscores to blanks in row and column names.

linesize(#) specifies the width of the page for formatting the table. Specifying a value of linesize() wider than your screen width can produce truly ugly output on the screen, but that output can nevertheless be useful if you are logging output and later plan to print the log on a wide printer.

Required options for the second syntax

cspec(cspec) specifies the formatting of the columns and the separators of the columns,

where cspec is [sep [qual] %#s] sep nspec [nspec [...]]

and where sep is [o#] &|| [o#]

+-----------------------+ qual is |qual Description | |-----------------------| | s standard font | | b boldface font | | i italic font | | t text mode | | e error mode | | c command mode | | L left-aligned | | R right-aligned | | C centered | | w# field width # | +-----------------------+

nspec is [qual] nfmt sep

and nfmt is %#.#{f|g}

The first (optional) part, [spec [qual] %#s], of cspec specifies the formatting for the column containing row names. It is required if the row names are part of the display; see the names() option. The number of nspecs should equal the number of columns of matname.

In a separator specification, sep, | specifies that a vertical line be drawn. & specifies that no line be drawn. The number of spaces before and after the separator may be specified with o#; these default to one space, except that by default no spaces are included before the first column and after the last column.

Here are examples for a matrix with two columns (three columns when you count the column containing the row labels):

cspec(& %16s & %9.2f & %7.4f &) specifies that the first column, containing row labels, be displayed using 16 characters; the second column, with format %9.2f; and the third column, with format %7.4f. No vertical lines are drawn. The number of spaces before and after the table is 0. Columns are separated with two spaces.

cspec(&o2 %16s o2&o2 %9.2f o2&02 %7.4f o2&) specifies more white around the columns (two spaces everywhere, for a total of four spaces between columns).

cspec(|%16s|%9.2f|%7.4f|) displays the columns in the same way as the first example but draws vertical lines before and after each column.

cspec(| b %16s | %9.2f & %7.4f |) specifies that vertical lines be drawn before and after all columns, except between the two columns with numeric entries. The first column is displayed in the boldface font.

rspec(rspec) specifies where horizontal lines be drawn. rspec consists of a sequence of characters, optionally separated by white space. - (or synonym |) specifies that a line be drawn. & indicates that no line be drawn. When matname has r rows, r+2 characters are required if column headers are displayed, and r+1 characters are required otherwise. The first character specifies whether a line is to be drawn before the first row of the table; the second, whether a line is to be drawn between the first and second row, etc.; and the last character, whether a line is to be drawn after the last row of the table.

You cannot add blank lines before or after the horizontal lines.

For example, in a table with column headers and three numeric rows,

rspec(||&&|) or equivalently rspec(--&&-) specifies that horizontal lines be drawn before the first and second rows and after the last row, but not elsewhere.

Examples

All numeric columns formatted the same

. matrix A = (1, 2 \ 3, 4 \ 5, 6)

. matrix list A

. matlist A

. matlist A, border(rows) rowtitle(rows) left(4)

. matlist 2*A, border(all) lines(none) format(%6.1f) names(rows) twidth(8) left(4) title(Guess what, a title)

All numeric columns formatted differently . matrix Htest = ( 12.30, 2, .00044642 \ 2.17, 1, .35332874 \ 8.81, 3, .04022625 \ 20.05, 6, .00106763 )

. matrix rownames Htest = trunk length weight overall

. matrix colnames Htest = chi2 df p

. matrix list Htest

. matlist Htest

. matlist Htest, rowtitle(Variables) title(Test results) cspec(o4& %12s | %8.0g & %5.0f & %8.4f o2&) rspec(&-&&--)

With extended missing values

. matrix Z = ( .z, 1 \ .c, .z )

. matrix rownames Z = row_1 row_2

. matrix colnames Z = col1 col2

. matlist Z

. matlist Z, nodotz underscore


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