mosmat Macro interface for mosaic matrices mosmat

Visualizing Categorical Data: mosmat

$Version: 1.1 (10 Nov 2000)
Michael Friendly
York University

The mosmat macro ( [download] get

Macro interface for mosaic matrices

The MOSMAT macro provides an easily used macro interface to the MOSAICS and MOSMAT SAS/IML programs, to create a scatterplot matrix of mosaic displays for all pairs of categorical variables.

Each pairwise plot shows the marginal frequencies to the order specified by the PLOTS= parameter. When PLOTS=2, these are the bivariate margins, and the residuals from marginal independence are shown by shading. When PLOTS >2, the observed frequencies in a higher-order marginal table are displayed, and the model fit to that marginal table is determined by the FITTYPE= parameter.


The parameters for the mosaic macro are like those of the SAS/IML programs, except:

Specifies the name of the input dataset. Should contain one observation per cell, the variables listed in VAR= and COUNT=. [Default: DATA=_LAST_]
Specifies the names of the factor variables for the contingency table. Abbreviated variable lists (e.g., V1-V3) are not allowed. The levels of the factor variables may be character or numeric, but are used as is in the input data. Upper/lower case in the variable names is respected in the diagonal label panels. You may omit the VAR= variables if variable names are used in the VORDER= parameter.
Specifies the name of the frequency variable in the dataset. The COUNT= variable must be specified.
The PLOTS= parameter determines the number of table variables displayed in each pairwise mosaic. [Default: PLOTS=2]
For a user-specified model, config= gives the terms in the model, separated by '/'. For example, to fit the model of no-three-way association, specify CONFIG=1 2 / 1 3 / 2 3, or (using variable names) CONFIG = A B / A C / B C. Note that the numbers refer to the variables after they have been reordered, either sorting the data set, or by the VORDER= parameter.
Specifies either the names of the variables or their indices in the desired order in the mosaic. Note that the using the VORDER= parameter keeps the factor levels in their order in the data.
Specifies whether and how the input data set is to be sorted to produce the desired order of variables in the mosaic. SORT=YES sorts the data in the reverse order that they are listed in the VAR= paraemter, so that the variables are entered in the order given in the VAR= parameter. Otherwise, SORT= lists the variable names, possibly with the DESENDING or NOTSORTED options in the reverse of the desired order. e.g., SORT=C DESCENDING B DESCENDING A.


%include vcd(mosmat);        *-- or include in an autocall library;
%include catdata(berkeley);
proc format;
   value admit 1="Admit" 0="Reject" ;
   value dept  1="A" 2="B" 3="C" 4="D" 5="E" 6="F";
   value $sex  'M'='Male'   'F'='Female';
%table(data=berkeley, var=Admit Gender Dept, weight=freq, char=Y,
        format=admit admit. gender $sex. dept dept., 
		  order=data, out=berkeley);

%mosmat(data=berkeley, vorder=Admit Gender Dept, sort=no, htext=3.5);
%mosmat(data=berkeley, vorder=Admit Gender Dept, sort=no, htext=3.5,
	plots=3, fittype=CONDIT);

See also

mosaic Macro interface for mosaic displays
mosaics SAS/IML programs for mosaic displays
sort Generalized dataset sorting by format or statistic
table Construct a grouped frequency table, with recoding