The CATMOD Procedure

Example 32.5 Log-Linear Model, Structural and Sampling Zeros

(View the complete code for this example.)

This example illustrates a log-linear model of independence, by using data that contain structural zero frequencies as well as sampling (random) zero frequencies.

In a population of six squirrel monkeys, the joint distribution of genital display with respect to active or passive role was observed. The data are from Fienberg (1980, Table 8-2). Since a monkey cannot have both the active and passive roles in the same interaction, the diagonal cells of the table are structural zeros. See Agresti (2002) for more information about the quasi-independence model.

The DATA step replaces the structural zeros with missing values, and the MISSING=STRUCTURAL option is specified in the MODEL statement to remove these zeros from the analysis. The ZERO=SAMPLING option treats the off-diagonal zeros as sampling zeros. Also, the row for Monkey 't' is deleted since it contains all zeros; therefore, the cell frequencies predicted by a model of independence are also zero. In addition, the CONTRAST statement compares the behavior of the two monkeys labeled 'u' and 'v'. See the section Structural and Sampling Zeros with Raw Data for information about how to perform this analysis when you have raw data. The following statements produce Output 32.5.1 through Output 32.5.8:

data Display;
   input Active $ Passive $ wt @@;
   if Active ne 't';
   if Active eq Passive then wt=.;
   datalines;
r r  0   r s  1   r t  5   r u  8   r v  9   r w  0
s r 29   s s  0   s t 14   s u 46   s v  4   s w  0
t r  0   t s  0   t t  0   t u  0   t v  0   t w  0
u r  2   u s  3   u t  1   u u  0   u v 38   u w  2
v r  0   v s  0   v t  0   v u  0   v v  0   v w  1
w r  9   w s 25   w t  4   w u  6   w v 13   w w  0
;
title 'Behavior of Squirrel Monkeys';
proc catmod data=Display;
   weight wt;
   model Active*Passive=_response_ /
         missing=structural zero=sampling
         freq pred=freq noparm oneway;
   loglin Active Passive;
   contrast 'Passive, U vs. V' Passive 0 0 0 1 -1;
   contrast 'Active,  U vs. V' Active  0 0 1 -1;
   title2 'Test Quasi-Independence for the Incomplete Table';
quit;

Output 32.5.1: Log-Linear Model Analysis with Zero Frequencies

Behavior of Squirrel Monkeys
Test Quasi-Independence for the Incomplete Table

The CATMOD Procedure

Data Summary
ResponseActive*PassiveResponse Levels25
Weight VariablewtPopulations1
Data SetDISPLAYTotal Frequency220
Frequency Missing0Observations25


The results of the ONEWAY option are shown in Output 32.5.2. Monkey 't' does not show up as a value for the Active variable since that row was removed.

Output 32.5.2: Output from the ONEWAY option

One-Way Frequencies
VariableValueFrequency
Activer23
 s93
 u46
 v1
 w57
Passiver40
 s29
 t24
 u60
 v64
 w3


Sampling zeros are displayed as 0 in Output 32.5.4. The Response Number column corresponds to the value displayed in the "Response Profiles" table in Output 32.5.3.

Output 32.5.3: Profiles

Population Profiles
SampleSample Size
1220

Response Profiles
ResponseActivePassive
1rs
2rt
3ru
4rv
5rw
6sr
7st
8su
9sv
10sw
11ur
12us
13ut
14uv
15uw
16vr
17vs
18vt
19vu
20vw
21wr
22ws
23wt
24wu
25wv


Output 32.5.4: Frequency of Response by Response Number

Response Frequencies
SampleResponse Number
1 2 3 4 5 6 7 8 9 10111213141516171819202122232425
11589029144640231382000019254613


The analysis of variance table (Output 32.5.5) shows that the model of independence does not fit since the likelihood ratio test for the interaction is significant. In other words, active and passive behaviors of the squirrel monkeys are dependent behavior roles.

Output 32.5.5: Analysis of Variance Table

Maximum Likelihood Analysis of Variance
SourceDF Chi-SquarePr > ChiSq
Active456.58<.0001
Passive547.94<.0001
Likelihood Ratio15135.17<.0001


If the model fit these data, then the contrasts in Output 32.5.6 show that monkeys 'u' and 'v' appear to have similar passive behavior patterns but very different active behavior patterns.

Output 32.5.6: Contrasts between Monkeys 'u' and 'v'

Contrasts of Maximum Likelihood Estimates
ContrastDFChi-SquarePr > ChiSq
Passive, U vs. V11.310.2524
Active, U vs. V114.870.0001


Output 32.5.7 displays the predicted response functions and Output 32.5.8 displays predicted cell frequencies (from the PRED=FREQ option), but since the model does not fit, these should be ignored. Note that, since the response function is the generalized logit with the 25th response as the baseline, the observed response functions for the sampling zeros are missing.

Output 32.5.7: Response Function Predicted Values

Maximum Likelihood Predicted Values for Response Functions
Function
Number
ObservedPredictedResidual
FunctionStandard
Error
FunctionStandard
Error
1-2.564951.037749-0.973550.339019-1.5914
2-0.955510.526235-1.725040.3454380.769529
3-0.485510.449359-0.527510.3092540.042007
4-0.367720.433629-0.739270.2490060.371543
5..-3.560520.634104.
60.8023460.3337750.3205890.266290.481758
70.0741080.385164-0.299340.2956340.37345
81.2636920.3141050.8981840.2508570.365508
9-1.178650.5717720.6864310.173396-1.86509
10..-2.134820.608071.
11-1.87180.759555-0.24150.287218-1.63031
12-1.466340.640513-0.109940.303568-1.3564
13-2.564951.037749-0.861430.314794-1.70352
141.0726370.3213080.1243460.2043450.94829
15-1.87180.759555-2.69690.6174330.8251
16..-4.147871.024508.
17..-4.016321.030062.
18..-4.767811.032457.
19..-3.570281.020794.
20-2.564951.037749-6.603281.1612894.038332
21-0.367720.433629-0.365840.202959-0.00188
220.6539260.34194-0.234290.2327940.888212
23-1.178650.571772-0.985770.239408-0.19288
24-0.773190.4935480.2117540.185007-0.98494


Output 32.5.8: Predicted Frequencies

Maximum Likelihood Predicted Values for Frequencies
ActivePassiveObservedPredictedResidual
FrequencyStandard
Error
FrequencyStandard
Error
rs10.9977255.2595081.36156-4.25951
rt52.2105122.4807260.6910662.519274
ru82.7765258.2159481.855146-0.21595
rv92.9379966.6480491.509322.351951
rw000.3957690.240268-0.39577
sr295.01769619.185993.1479159.814007
st143.62064810.321722.1695993.678284
su466.03173434.184634.42870611.81537
sv41.98173527.660963.722788-23.661
sw001.64670.952712-1.6467
ur21.40777110.93642.12322-8.9364
us31.72020112.474072.554336-9.47407
ut10.9977255.8835831.380655-4.88358
uv385.60681415.76732.68469222.2327
uw21.4077710.9386520.5516451.061348
vr000.2199660.221779-0.21997
vs000.2508930.253706-0.25089
vt000.1183380.120314-0.11834
vu000.3919240.393255-0.39192
vw10.9977250.0188790.0217280.981121
wr92.9379969.6576451.808656-0.65765
ws254.70734411.015532.27501913.98447
wt41.9817355.1956381.184452-1.19564
wu62.41585717.20752.772098-11.2075
wv133.49740213.923692.24158-0.92369


Structural and Sampling Zeros with Raw Data

The preceding PROC CATMOD step uses cell count data as input. Prior to invoking the CATMOD procedure, structural and sampling zeros are easily identified and manipulated in a single DATA step. For the situation where structural or sampling zeros (or both) exist and the input data set is raw data, use the following steps:

  1. Run PROC FREQ on the raw data (see Chapter 41: The FREQ Procedure). In the TABLES statement, list all dependent and independent variables, separated by asterisks, and use the SPARSE option and the OUT= option. This creates an output data set that contains all possible zero frequencies. Since the tabled output can be huge, you should also specify the NOPRINT option in the TABLES statement.

  2. Use a DATA step to change the zero frequencies associated with either sampling zeros or structural zeros to missing.

  3. Use the resulting data set as input to PROC CATMOD, specify the statement WEIGHT COUNT to use adjusted frequencies, and specify the ZERO= and MISSING= options to define your sampling and structural zeros.

For example, suppose the data set RawDisplay contains the raw data for the squirrel monkey data. The following statements show how to obtain the same analysis as shown previously:

proc freq data=RawDisplay;
   tables Active*Passive / sparse out=Combos noprint;
run;
data Combos2;
   set Combos;
   if Active ne 't';
   if Active eq Passive then count=.;
run;
proc catmod data=Combos2;
   weight count;
   model Active*Passive=_response_ /
         zero=sampling missing=structural
         freq pred=freq noparm noresponse;
   loglin Active Passive;
quit;

The first IF statement in the DATA step is needed only for this particular example; since observations for Monkey 't' were deleted from the Display data set, they also need to be deleted from Combos2.