*! version 0.31

Title

crossmat -- A wrapper for tabulate that returns
calculated values in matrices as well as showing them in the log

Syntax

crossmat varlist(min=1 max=2) [if] [in] [weight]
[, options]

Main
label Use values labels as row and column names when possible.

missing treat missing values like other values.

exact(integer) The non-negative integer # is a multiplier on
the amount of memory that the command is permitted to consume.
Default is 0, ie not set. If set as a positive integer (start with 1) and two
variables are given as arguments Fisher's exact test is reported.

verbose show the Stata commands and output behind crossmat.
For validation purposes.

Description

crossmat is a wrapper on tabulate that returns all
calculated values as matrices.

Examples

Below is a set of examples. You can copy the code and insert it in the
command window or you can just click once on each blue line below.
Then the command is automatically moved to the command window and executed.

Note that there is progression in the examples such a command line may require
some of the previous lines to show the intended properly.

In this example estimates and their confidence intervals for two regression
models are combined into one summary matrix.

`"sysuse auto, clear"'

One can get tabulate outputs with one variable:

`"crossmat rep78"'

The command as such prints nothing in the log. What can be retrieved is
seen by:

`"return list"'

One can get tabulate outputs with one variable, eg using
{help matprint: matprint:

`"matprint (r(counts), r(pct)), d((0,1))"'

One can get tabulate outputs with two variables:

`"crossmat rep78 foreign, exact(1) missing"'

This can be retrieved:

`"return list"'

The martrices can be viewed by matprint:

`"matprint r(counts), d(0)"'

`"matprint r(expected), d(2)"'

`"matprint r(chi2), d(3)"'

`"matprint r(lrchi2), d(3)"'

`"matprint r(tests), d((3,0,3))"'

`"matprint r(greeks), d(3)"'

`"matprint 100 * r(pct), d(1)"'

`"matprint 100 * r(rpct), d(1)"'

`"matprint 100 * r(cpct), d(1)"'

Stored results

crossmat stores the following in r():

Matrices

r(counts) The count table

r(expected) The expected values from the independence assumption

r(chi2) The Pearson chisquare parts of the independence test

r(lrchi2) The likelihood ratio chisquare parts of the independence test

r(tests) The test summary

r(greeks) The greek estimates

r(pct) The percentages

r(rpct) The row percentages

r(cpct) The column percentages

To see more examples

Authors and support

Author:

Niels Henrik Bruun,

Aalborg University Hospital

Support:

niels.henrik.bruun@gmail.com