-------------------------------------------------------------------------------
help for mstdize
-------------------------------------------------------------------------------

Marginal standardization of two-way tables

mstdize varname rowtotvar coltotvar [if exp] [in range] , by(rowvar colvar) [ generate(newvar) tolerance(#) tabdisp_options ]

Description

mstdize takes a table of varname, with rows indexed by rowvar and columns indexed by colvar, and produces a new table containing varname scaled such that the row totals are given by rowtotvar and the column totals given by coltotvar.

Remarks

The algorithm is

0. Initialise guess = varname

1. Loop until max (| guess - previous guess |) <= tolerance previous guess = guess guess = guess * target row total / guess row total guess = guess * target col total / guess col total

The total over rows of the column totals should equal the total over columns of the row totals. That is, the two should lead to the same grand total.

This procedure is known by many different names in several different disciplines, including statistics, economics and engineering. Some are

biproportional matrices iterative proportional fitting raking RAS technique

Options

by() indicates rowvar and colvar and is required.

generate() generates a new variable containing scaled values.

tolerance() is a technical option indicating the criterion for convergence. This is the largest acceptable absolute difference between each guess and the previous guess (and also between the two totals of totals). Default 0.001.

tabdisp_options are options of tabdisp. Default center format(%9.2f).

Examples

Data used by Smith (1976), quoted by Agresti (1990, p.197; 2002, p.345): . input freq schooling attitude . 209 1 1 . 101 1 2 . 237 1 3 . 151 2 1 . 126 2 2 . 426 2 3 . 16 3 1 . 21 3 2 . 138 3 3 . end . gen r = 100 . gen c = 100 . mstdize freq r c, by(schooling attitude)

Data used by Friedlander (1961), quoted by Bishop et al. (1975, p.98): . input freq age status . 1306 1 1 . 83 1 2 . 0 1 3 . 619 2 1 . 765 2 2 . 3 2 3 . 263 3 1 . 1194 3 2 . 9 3 3 . 173 4 1 . 1372 4 2 . 28 4 3 . 171 5 1 . 1393 5 2 . 51 5 3 . 159 6 1 . 1372 6 2 . 81 6 3 . 208 7 1 . 1350 7 2 . 108 7 3 . 1116 8 1 . 4100 8 2 . 2329 8 3 . end . gen rt = . . tokenize 1412 1402 1450 1541 1681 1532 1662 7644 . qui forval i = 1/8 { . replace rt = ``i'' if age == `i' . } . gen ct = . . tokenize 3988 11702 2634 . qui forval j = 1/3 { . replace ct = ``j'' if status == `j' . } . mstdize freq rt ct , by(age status)

References

Agresti, A. 1990. Categorical data analysis. New York: John Wiley.

Agresti, A. 2002. Categorical data analysis. Hoboken, NJ: John Wiley.

Bishop, Y.M.M., Fienberg, S.E. and Holland, P.W. 1975. Discrete multivariate analysis. Cambridge, MA: MIT Press.

Friedlander, D. 1961. A technique for estimating a contingency table given the marginal totals and some supplementary data. Journal of the Royal Statistical Society Series A 124: 412-420.

Smith, K.W. 1976. Table standardization and table shrinking: aids in the traditional analysis of contingency tables. Social Forces 54: 669-693.

Author

Nicholas J. Cox, Durham University, U.K. n.j.cox@durham.ac.uk