Stata 11 help for tabulate twoway

help tabulate, help tabi, help tab2 dialogs: tabulate tab2 tabi -------------------------------------------------------------------------------

Title

[R] tabulate twoway -- Two-way tables of frequencies

Syntax

Two-way tables

tabulate varname1 varname2 [if] [in] [weight] [, options]

Two-way tables for all possible combinations - a convenience tool

tab2 varlist [if] [in] [weight] [, options]

Immediate form of two-way tabulations

tabi #11 #12 [...] \ #21 #22 [...] [\ ...] [, options]

options description ------------------------------------------------------------------------- Main chi2 report Pearson's chi-squared exact[(#)] report Fisher's exact test gamma report Goodman and Kruskal's gamma lrchi2 report likelihood-ratio chi-squared taub report Kendall's tau-b V report Cramér's V cchi2 report Pearson's chi-squared in each cell column report relative frequency within its column of each cell row report relative frequency within its row of each cell clrchi2 report likelihood-ratio chi-squared in each cell cell report the relative frequency of each cell expected report expected frequency in each cell nofreq do not display frequencies missing treat missing values like other values wrap do not wrap wide tables [no]key report/suppress cell contents key nolabel display numeric codes rather than value labels nolog do not display enumeration log for Fisher's exact test * firstonly show only tables that include the first variable in varlist

Advanced matcell(matname) save frequencies in matname; programmer's option matrow(matname) save unique values of varname1 in matname matcol(matname) save unique values of varname2 in matname # replace replace current data with given cell frequencies

+ all equivalent to specifying chi2 lrchi2 V gamma taub ------------------------------------------------------------------------- * firstonly is available only for tab2. # replace is available only for tabi. + all does not appear in the dialog box. by is allowed only with tabulate2 and tab2; see [D] by. fweights, aweights, and iweights are allowed by tabulate. fweights are allowed by tab2. See weight.

Menu

tabulate

Statistics > Summaries, tables, and tests > Tables > Two-way tables with measures of association

tab2

Statistics > Summaries, tables, and tests > Tables > All possible two-way tabulations

tabi

Statistics > Summaries, tables, and tests > Tables > Table calculator

Description

tabulate produces two-way tables of frequency counts, along with various measures of association, including the common Pearson's chi-squared, the likelihood-ratio chi-squared, Cramér's V, Fisher's exact test, Goodman and Kruskal's gamma, and Kendall's tau-b.

Line size is respected. That is, if you resize the Results window before running tabulate, the resulting two-way tabulation will take advantage of the available horizontal space. Stata for Unix(console) users can instead use the set linesize command to take advantage of this feature.

tab2 produces all possible two-way tabulations of the variables specified in varlist.

tabi displays the r x c table using the values specified; rows are separated by '\'. If no options are specified, it is as if exact were specified for 2 x 2 tables and chi2 were specified otherwise. See immed for a general description of immediate commands.

See [R] tabulate oneway if you want one-way tables of frequencies. See [R] table and [R] tabstat if you want one-, two-, or n-way tables of frequencies and a wide variety of statistics. See [R] tabulate, summarize() for a description of tabulate with the summarize() option; it produces tables (breakdowns) of means and standard deviations. table is better than tabulate, summarize(), but tabulate, summarize() is faster. See [ST] epitab for 2 x 2 tables with statistics of interest to epidemiologists.

Options

+------+ ----+ Main +-------------------------------------------------------------

chi2 calculates and displays Pearson's chi-squared for the hypothesis that the rows and columns in a two-way table are independent. chi2 may not be specified if aweights or iweights are specified.

exact[(#)] displays the significance calculated by Fisher's exact test and may be applied to r x c as well as to 2 x 2 tables. For 2 x 2 tables, both one- and two-sided probabilities are displayed. For r x c tables, one-sided probabilities are displayed. The optional positive integer # is a multiplier on the amount of memory that the command is permitted to consume. The default is 1. This option should not be necessary for reasonable r x c tables. If the command terminates with error 910, try exact(2). The maximum row or column dimension allowed when computing Fisher's exact test is the maximum row or column dimension for tabulate (see limits).

gamma displays Goodman and Kruskal's gamma along with its asymptotic standard error. gamma is appropriate only when both variables are ordinal. gamma may not be specified if aweights or iweights are specified.

lrchi2 displays the likelihood-ratio chi-squared statistic. lrchi2 may not be specified if aweights or iweights are specified.

taub displays Kendall's tau-b along with its asymptotic standard error. taub is appropriate only when both variables are ordinal. taub may not be specified if aweights or iweights are specified.

V (note capitalization) displays Cramér's V. V may not be specified if aweights or iweights are specified.

cchi2 displays each cell's contribution to Pearson's chi-squared in a two-way table.

column displays the relative frequency of each cell within its column in a two-way table.

row displays the relative frequency of each cell within its row in a two-way table.

clrchi2 displays each cell's contribution to the likelihood-ratio chi-squared in a two-way table.

cell displays the relative frequency of each cell in a two-way table.

expected displays the expected frequency of each cell in a two-way table.

nofreq suppresses the printing of the frequencies.

missing requests that missing values be treated like other values in calculations of counts, percentages, and other statistics.

wrap requests that Stata take no action on wide, two-way tables to make them readable. Unless wrap is specified, wide tables are broken into pieces to enhance readability.

[no]key suppresses or forces the display of a key above two-way tables. The default is to display the key if more than one cell statistic is requested, and otherwise to omit it. key forces the display of the key. nokey suppresses its display.

nolabel causes the numeric codes to be displayed rather than the value labels.

nolog suppresses the display of the log for Fisher's exact test. Using Fisher's exact test requires counting all tables that have a probability exceeding that of the observed table given the observed row and column totals. The log counts down each stage of the network computations, starting from the number of columns and counting down to 1, displaying the number of nodes in the network at each stage. A log is not displayed for 2 x 2 tables.

firstonly, available only with tab2, shows only those tables that include the first variable in varlist. Use this option to interact one variable with a set of others.

+----------+ ----+ Advanced +---------------------------------------------------------

matcell(matname) saves the reported frequencies in matname. This option is for use by programmers.

matrow(matname) saves the numeric values of the r x 1 row stub in matname. This option is for use by programmers. matrow() may not be specified if the row variable is a string.

matcol(matname) saves the numeric values of the 1 x c column stub in matname. This option is for use by programmers. matcol() may not be specified if the column variable is a string.

replace indicates that the immediate data specified as arguments to the tabi command be left as the current data in place of whatever data there were.

The following option is available with tabulate but is not shown in the dialog box:

all is equivalent to specifying chi2 lrchi2 V gamma taub. Note the omission of exact. When all is specified, no may be placed in front of the other options. all noV requests all association measures except Cramér's V (and Fisher's exact). all exact requests all association measures, including Fisher's exact test. all may not be specified if aweights or iweights are specified.

Limits

Two-way tables may have a maximum of 1,200 rows and 80 columns (Stata/MP and Stata/SE), 300 rows and 20 columns (Stata/IC), or 160 rows and 20 columns (Small Stata). If larger tables are needed, see [R] table.

Examples

--------------------------------------------------------------------------- Setup . webuse citytemp2

Two-way table of frequencies . tabulate region agecat

Include row percentages . tabulate region agecat, row

Include column percentages . tabulate region agecat, column

Include cell percentages . tabulate region agecat, cell

Include row percentages, suppress frequency counts . tabulate region agecat, row nofreq

Include chi-squared test for independence of rows and columns . tabulate region agecat, chi2

--------------------------------------------------------------------------- Setup . webuse dose

Include all measures of association, except Fisher's exact test . tabulate dose function, all

Include all measures of association, including Fisher's exact test . tabulate dose function, all exact

--------------------------------------------------------------------------- Immediate form . tabi 30 18 \ 18 14

Immediate form, 2 x 3 table . tabi 30 18 38 \ 13 7 22

Add Fisher's exact test . tabi 30 18 38 \ 13 7 22, chi2 exact

3 by 2 table, all measures of association . tabi 30 13 \ 18 7 \ 38 22, all exact ---------------------------------------------------------------------------

Saved results

tabulate, tab2, and tabi save the following in r():

Scalars r(N) number of observations r(r) number of rows r(c) number of columns r(chi2) Pearson's chi-squared r(p) significance of Pearson's chi-squared r(gamma) gamma r(p1_exact) one-sided Fisher's exact p r(p_exact) Fisher's exact p r(chi2_lr) likelihood-ratio chi-squared r(p_lr) significance of likelihood-ratio chi-squared r(CramersV) Cramér's V r(ase_gam) ASE of gamma r(ase_taub) ASE of tau_b r(taub) tau_b

r(p1_exact) is defined only for 2 x 2 tables. Also, the matrow(), matcol(), and matcell() options allow you to obtain the row values, column values, and frequencies, respectively.

Also see

Manual: [R] tabulate twoway

Help: [D] collapse, [ST] epitab, [SVY] svy: tabulate oneway, [SVY] svy: tabulate twoway, [R] table, [R] tabstat, [R] tabulate, summarize(), [R] tabulate oneway, [XT] xttab


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